Class: MultiRubyRunner::VersionManager::Rvm
- Inherits:
-
MultiRubyRunner::VersionManager
- Object
- MultiRubyRunner::VersionManager
- MultiRubyRunner::VersionManager::Rvm
- Defined in:
- lib/multi_ruby_runner/version_manager/rvm.rb
Overview
Represents the [rvm](rvm.io/) ruby version manager.
Instance Method Summary collapse
-
#activation_string ⇒ String
Returns the string to be executed in shell to activate rvm in a shell.
-
#compute_process_args(command_string, directory, options) ⇒ Hash
See MultiRubyRunner#execute_command_in_directory.
-
#shell_command_string(command_string, directory) ⇒ Object
Returns the command string to be passed to the shell.
Methods inherited from MultiRubyRunner::VersionManager
Constructor Details
This class inherits a constructor from MultiRubyRunner::VersionManager
Instance Method Details
#activation_string ⇒ String
Returns the string to be executed in shell to activate rvm in a shell.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/multi_ruby_runner/version_manager/rvm.rb', line 37 def activation_string # Given the @ruby_executable_path, we can compute the rvm script path # that needs to be sourced: # /Users/username/.rvm/rubies/ruby-2.2.3/bin/ruby # ~/.rvm/scripts/rvm script_path = @ruby_executable_path.match( /^.+(#{ Regexp.escape("/.rvm/") })(?=rubies)/ )[0] if script_path.nil? raise RuntimeError.new("Could not detect rvm script path! (#{ @ruby_executable_path.inspect }") end script_path << 'scripts/rvm' # Rvm requires sourcing of script_path: "source #{ script_path }" end |
#compute_process_args(command_string, directory, options) ⇒ Hash
See MultiRubyRunner#execute_command_in_directory
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/multi_ruby_runner/version_manager/rvm.rb', line 15 def compute_process_args(command_string, directory, ) { entire_command: [ [:shell_invocation], %('#{ shell_command_string(command_string, directory) }') ].join(' '), blocking: [:blocking], environment_overrides: {}, } end |
#shell_command_string(command_string, directory) ⇒ Object
Returns the command string to be passed to the shell
27 28 29 30 31 32 33 |
# File 'lib/multi_ruby_runner/version_manager/rvm.rb', line 27 def shell_command_string(command_string, directory) [ activation_string, # activate rvm "cd #{ directory }", # cd into the directory containing .ruby-version file command_string, # execute command ].join('; ') end |