Class: SchemaDev::RubySelector::Chruby

Inherits:
ManagerBase show all
Defined in:
lib/schema_dev/ruby_selector.rb

Constant Summary collapse

CORE_COMMAND =
"chruby-exec"

Instance Method Summary collapse

Methods inherited from ManagerBase

installed?

Constructor Details

#initializeChruby

Returns a new instance of Chruby.



23
24
25
# File 'lib/schema_dev/ruby_selector.rb', line 23

def initialize
  @rubies = Pathname.new(ENV['HOME']).join(".rubies").entries().map(&its.basename.to_s)
end

Instance Method Details

#command(ruby) ⇒ Object



26
27
28
29
30
# File 'lib/schema_dev/ruby_selector.rb', line 26

def command(ruby)
  bash = Which.which 'bash' || abort("no bash shell found")
  ruby = @rubies.select(&it =~ /^(ruby-)?#{ruby}(-p.*)?$/).last || ruby
  "SHELL=#{bash} #{CORE_COMMAND} #{ruby} --"
end