123456789_123456789_123456789_123456789_123456789_

Class: Gem::TargetRbConfig

Relationships & Source Files
Inherits: Object
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.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

  • #[](key)

    Queries the configuration for the given key.

Constructor Details

.new(rbconfig, path) ⇒ TargetRbConfig

[ GitHub ]

  
# File 'lib/rubygems/target_rbconfig.rb', line 17

def initialize(rbconfig, path)
  @rbconfig = rbconfig
  @path = path
end

Class Method Details

.for_running_ruby

Creates a TargetRbConfig for the platform that RubyGems is running on.

[ GitHub ]

  
# File 'lib/rubygems/target_rbconfig.rb', line 25

def self.for_running_ruby
  new(::RbConfig, nil)
end

.from_path(rbconfig_path)

Creates a TargetRbConfig from the RbConfig file at the given path. Typically used for cross-compiling gems.

[ GitHub ]

  
# 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 Attribute Details

#path (readonly)

[ GitHub ]

  
# File 'lib/rubygems/target_rbconfig.rb', line 15

attr_reader :path

Instance Method Details

#[](key)

Queries the configuration for the given key.

[ GitHub ]

  
# File 'lib/rubygems/target_rbconfig.rb', line 47

def [](key)
  @rbconfig::CONFIG[key]
end