Module: BenchmarkDriver::RidkUse
- Defined in:
- lib/benchmark_driver/ridkuse.rb
Class Method Summary collapse
- .parse_spec(full_spec) ⇒ Object
-
.ridk_use_list ⇒ Object
Execute “ridk use list” command to get a list of Ruby versions.
- .ruby_path(version) ⇒ Object
Class Method Details
.parse_spec(full_spec) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/benchmark_driver/ridkuse.rb', line 47 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::RidkUse.ruby_path(version), *args], ) end |
.ridk_use_list ⇒ Object
Execute “ridk use list” command to get a list of Ruby versions.
-
“ridk use list” is a sub-command of ridk. It returns a list of installed ruby versions.
-
“ridk” is a helper command tool of RubyInstaller2 for Windows, that to manage the runtime environment of RubyInstaller-2.4 and up.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/benchmark_driver/ridkuse.rb', line 14 def self.ridk_use_list ruby_list = [] regex = /(\d+)\s-\s([^\s]+)\s\truby\s([^\s]+)\s/ cmd = "ridk use list" stdout, _status = Open3.capture2e(cmd) stdout.each_line do |line| if matched = regex.match(line) idx, rubypath, rubyver = matched[1..3] ruby_list << rubyver << [idx, "#{rubypath}/bin/ruby.exe"] else abort "Failed to execute 'ridk use list'" end end Hash[*ruby_list] end |
.ruby_path(version) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/benchmark_driver/ridkuse.rb', line 32 def self.ruby_path(version) ruby_list = BenchmarkDriver::RidkUse.ridk_use_list regex = Regexp.new(version) matched = ruby_list.keys.find {|k| k =~ regex} if ruby_list.has_key?(version) ruby_list[version][1] elsif matched ruby_list[matched][1] else abort "version #{version} not found" end end |