Class: SchemaDev::RubySelector::Rbenv

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

Constant Summary collapse

CORE_COMMAND =
"rbenv"

Instance Method Summary collapse

Methods inherited from ManagerBase

installed?

Constructor Details

#initializeRbenv

Returns a new instance of Rbenv.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/schema_dev/ruby_selector.rb', line 44

def initialize
  # because we're running within a ruby program that was launched by
  # rbenv, we already have various environment variables set up.  need
  # strip those out so that the forked shell can run a diifferent ruby
  # version than the one we're in now.
  ENV['PATH'] = ENV['PATH'].split(':').reject{|dir| dir =~ %r{/\.?rbenv/(?!shims)}}.join(':')
  ENV['GEM_PATH'] = ENV['GEM_PATH'].split(':').reject{|dir| dir =~ %r{/\.?rbenv}}.join(':') unless ENV['GEM_PATH'].nil?
  ENV['RBENV_DIR'] = nil
  ENV['RBENV_HOOK_PATH'] = nil
  @versions ||= `rbenv versions --bare`.split
end

Instance Method Details

#command(ruby) ⇒ Object



56
57
58
59
# File 'lib/schema_dev/ruby_selector.rb', line 56

def command(ruby)
  version = @versions.select{|v| v.start_with? ruby}.last || abort("no ruby version '#{ruby}' installed in rbenv")
  "RBENV_VERSION=#{version}"
end