Sha256: f71450b5e55f74c3d3b1764065270b1e3d02b0a7cc2f80ace0ed4d20356edf84

Contents?: true

Size: 842 Bytes

Versions: 4

Compression:

Stored size: 842 Bytes

Contents

require 'shellwords'

module BenchmarkDriver
  module Chruby
    # @param [String] version
    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

    # @param [String] full_spec - "2.5.0", "2.5.0 --jit", "JIT::2.5.0 --jit", etc.
    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
benchmark_driver-0.16.5 lib/benchmark_driver/chruby.rb
benchmark_driver-0.16.4 lib/benchmark_driver/chruby.rb
benchmark_driver-0.16.3 lib/benchmark_driver/chruby.rb
benchmark_driver-0.16.2 lib/benchmark_driver/chruby.rb