class Gem::TargetRbConfig
TargetConfig 是一个 RbConfig
对象的包装器,它为查询 *部署目标平台* 的配置提供了一致的接口,该平台是 gem 计划运行的平台。
TargetConfig 通常从正在运行的 Ruby 进程的 RbConfig
创建,但也可以从磁盘上的 RbConfig
文件创建,用于交叉编译 gem。
属性
公共类方法
源代码
# File lib/rubygems/target_rbconfig.rb, line 25 def self.for_running_ruby new(::RbConfig, nil) end
为运行 RubyGems 的平台创建一个 TargetRbConfig
。
源代码
# File lib/rubygems/target_rbconfig.rb, line 33 def self.from_path(rbconfig_path) namespace = Module.new do |m| # Load the rbconfig.rb file within a new anonymous module to avoid # conflicts with the rbconfig for the running platform. Kernel.load rbconfig_path, m end rbconfig = namespace.const_get(:RbConfig) new(rbconfig, rbconfig_path) end
从给定路径的 RbConfig
文件创建一个 TargetRbConfig
。通常用于交叉编译 gem。
源代码
# File lib/rubygems/target_rbconfig.rb, line 17 def initialize(rbconfig, path) @rbconfig = rbconfig @path = path end
公共实例方法
源代码
# File lib/rubygems/target_rbconfig.rb, line 47 def [](key) @rbconfig::CONFIG[key] end
查询给定键的配置。