Class: Rake::CompilerConfig
- Inherits:
-
Object
- Object
- Rake::CompilerConfig
- Defined in:
- lib/rake/compiler_config.rb
Instance Method Summary collapse
- #find(ruby_version, gem_platform) ⇒ Object
-
#initialize(config_path) ⇒ CompilerConfig
constructor
A new instance of CompilerConfig.
Constructor Details
#initialize(config_path) ⇒ CompilerConfig
Returns a new instance of CompilerConfig.
3 4 5 6 |
# File 'lib/rake/compiler_config.rb', line 3 def initialize(config_path) require "yaml" @config = YAML.load_file(config_path) end |
Instance Method Details
#find(ruby_version, gem_platform) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rake/compiler_config.rb', line 8 def find(ruby_version, gem_platform) gem_platform = Gem::Platform.new(gem_platform) @config.each do |config_name, config_location| # There are two variations we might find in the rake-compiler config.yml # # 1. config_name: rbconfig-x86_64-linux-3.0.0 # runtime_platform_name: x86_64-linux # runtime_version: 3.0.0 # # 2. config_name: rbconfig-x86_64-linux-gnu-3.0.0 # runtime_platform_name: x86_64-linux-gnu # runtime_version: 3.0.0 # # With rubygems < 3.3.21, both variations will be present (two entries pointing at the same # installation). # # With rubygems >= 3.3.21, only the second variation will be present. runtime_platform_name = config_name.split("-")[1..-2].join("-") runtime_version = config_name.split("-").last runtime_platform = Gem::Platform.new(runtime_platform_name) if (ruby_version == runtime_version) && (gem_platform =~ runtime_platform) return config_location end end nil end |