Class: Gem::TargetRbConfig
- Inherits:
-
Object
- Object
- Gem::TargetRbConfig
- Defined in:
- lib/rubygems/target_rbconfig.rb
Overview
A TargetConfig is a wrapper around an RbConfig object that provides a consistent interface for querying configuration for *deployment target platform*, where the gem being installed is intended to run on.
The TargetConfig is typically created from the RbConfig of the running Ruby process, but can also be created from an RbConfig file on disk for cross- compiling gems.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
-
.for_running_ruby ⇒ Object
Creates a TargetRbConfig for the platform that RubyGems is running on.
-
.from_path(rbconfig_path) ⇒ Object
Creates a TargetRbConfig from the RbConfig file at the given path.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Queries the configuration for the given key.
-
#initialize(rbconfig, path) ⇒ TargetRbConfig
constructor
A new instance of TargetRbConfig.
Constructor Details
#initialize(rbconfig, path) ⇒ TargetRbConfig
Returns a new instance of TargetRbConfig.
17 18 19 20 |
# File 'lib/rubygems/target_rbconfig.rb', line 17 def initialize(rbconfig, path) @rbconfig = rbconfig @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
15 16 17 |
# File 'lib/rubygems/target_rbconfig.rb', line 15 def path @path end |
Class Method Details
.for_running_ruby ⇒ Object
Creates a TargetRbConfig for the platform that RubyGems is running on.
25 26 27 |
# File 'lib/rubygems/target_rbconfig.rb', line 25 def self.for_running_ruby new(::RbConfig, nil) end |
.from_path(rbconfig_path) ⇒ Object
Creates a TargetRbConfig from the RbConfig file at the given path. Typically used for cross-compiling gems.
33 34 35 36 37 38 39 40 41 42 |
# 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 |
Instance Method Details
#[](key) ⇒ Object
Queries the configuration for the given key.
47 48 49 |
# File 'lib/rubygems/target_rbconfig.rb', line 47 def [](key) @rbconfig::CONFIG[key] end |