class SchemaDev::RubySelector::Chruby

Constants

CORE_COMMAND

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/schema_dev/ruby_selector.rb, line 30
def initialize
  super

  @rubies = Pathname.new(ENV['HOME'])
                    .join('.rubies')
                    .entries
                    .map { |e| e.basename.to_s }
end

Public Instance Methods

command(ruby) click to toggle source
# File lib/schema_dev/ruby_selector.rb, line 39
def command(ruby)
  bash = Which.which 'bash' || abort('no bash shell found')
  ruby = @rubies.select { |e| e =~ /^(ruby-)?#{ruby}(-p.*)?$/ }
                .last || ruby
  "SHELL=#{bash} #{CORE_COMMAND} #{ruby} --"
end