Class: SchemaDev::RubySelector::Rbenv
- Inherits:
-
Object
- Object
- SchemaDev::RubySelector::Rbenv
- Defined in:
- lib/schema_dev/ruby_selector.rb
Instance Method Summary collapse
- #command(ruby) ⇒ Object
-
#initialize ⇒ Rbenv
constructor
A new instance of Rbenv.
Constructor Details
#initialize ⇒ Rbenv
Returns a new instance of Rbenv.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/schema_dev/ruby_selector.rb', line 32 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
44 45 46 47 |
# File 'lib/schema_dev/ruby_selector.rb', line 44 def command(ruby) version = @versions.select{|v| v.start_with? ruby}.last || abort("no ruby version '#{ruby}' installed in rbenv") "RBENV_VERSION=#{version}" end |