module BenchmarkDriver::Rvm
Public Class Methods
parse_spec(full_spec)
click to toggle source
@param [String] full_spec - “2.5.0”, “2.5.0 –jit”, “JIT::2.5.0 –jit”, etc.
# File lib/benchmark_driver/rvm.rb, line 39 def self.parse_spec(full_spec) name, spec = full_spec.split('::', 2) spec ||= name # if `::` is not given, regard whole string as spec version, *args = spec.shellsplit BenchmarkDriver::Config::Executable.new( name: name, command: [BenchmarkDriver::Rvm.ruby_path(version), *args], ) end
ruby_path(version)
click to toggle source
@param [String] version
# File lib/benchmark_driver/rvm.rb, line 20 def self.ruby_path(version) path = if version == 'system' system_ruby_path else rubies = Pathname.new("#{ENV['rvm_path']}/rubies") abort "Rubies path '#{rubies}' not found" unless rubies.exist? ruby_list = rubies.children.select { |path| path.directory? && path.basename.to_s.match(version) } ruby_root = ruby_list.detect { |path| path.basename.to_s == version } || ruby_list[0] abort "Version '#{version}' not found" unless ruby_root "#{ruby_root}/bin/ruby" end unless File.exist?(path) abort "Binary '#{path}' not found" end path end
system_ruby_path()
click to toggle source
Execute “which -a ruby” command to get a list of Ruby versions from $PATH.
# File lib/benchmark_driver/rvm.rb, line 7 def self.system_ruby_path env_rubies = `which -a ruby` abort "Failed to execute 'which -a ruby'" unless $?.success? env_rubies.each_line do |line| if !line.match(ENV['rvm_path']) return line.rstrip end end abort "System ruby not found" end