Module: BenchmarkDriver::Chruby

Defined in:
lib/benchmark_driver/chruby.rb

Class Method Summary collapse

Class Method Details

.parse_spec(full_spec) ⇒ Object

Parameters:

  • full_spec (String)
    • “2.5.0”, “2.5.0 –jit”, “JIT::2.5.0 –jit”, etc.



17
18
19
20
21
22
23
24
25
# File 'lib/benchmark_driver/chruby.rb', line 17

def self.parse_spec(full_spec)
  name, spec = full_spec.split('::', 2)
  spec ||= name # if `::` is not given, use the whole string as spec
  version, *args = spec.shellsplit
  BenchmarkDriver::Config::Executable.new(
    name: name,
    command: [BenchmarkDriver::Chruby.ruby_path(version), *args],
  )
end

.ruby_path(version) ⇒ Object

Parameters:

  • version (String)


6
7
8
9
10
11
12
13
14
# File 'lib/benchmark_driver/chruby.rb', line 6

def self.ruby_path(version)
  prefix = (Dir.glob('/opt/rubies/*') + Dir.glob("#{ENV['HOME']}/.rubies/*")).find do |dir|
    File.basename(dir) == version
  end
  unless prefix
    abort "Failed to find '#{version}' in /opt/rubies or ~/.rubies"
  end
  "#{prefix}/bin/ruby"
end