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.



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/schema_dev/ruby_selector.rb', line 58

def initialize
  super

  # 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



72
73
74
75
# File 'lib/schema_dev/ruby_selector.rb', line 72

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