Module: Capistrano::RvmMethods
- Defined in:
- lib/rvm/capistrano/helpers/rvm_methods.rb
Instance Method Summary collapse
- #command_with_shell(cmd, shell = nil) ⇒ Object
-
#path_to_bin_rvm(options = {}) ⇒ Object
helper to find path to rvm binary.
-
#run_rvm(command, options = {}) ⇒ Object
shortcut to binary rvm #command - use :with_rvm_group => true - to wrap it all in ‘with_rvm_group(…)` call - use :with_ruby => ’with_ruby’ - to extend to ‘…/bin/rvm #with_ruby do` - use :subject_class => :gemsets to indicate that the subject of the operation will be a gemset; valid values are any values which can be contained in the rvm_user config variable Array.
-
#run_with_rvm(command) ⇒ Object
allow running tasks with forcing rvm_shell.
-
#run_without_rvm(command) ⇒ Object
allow running tasks without using rvm_shell.
-
#rvm_task(name, &block) ⇒ Object
defined depending on which selector was used.
-
#rvm_user_command(options = {}) ⇒ Object
If we’re operating on something affected by the rvm user mode, we need to make sure that the server has the right rvm user mode.
Instance Method Details
#command_with_shell(cmd, shell = nil) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/rvm/capistrano/helpers/rvm_methods.rb', line 56 def command_with_shell(cmd, shell=nil) if shell == false cmd else "#{shell || "sh"} -c #{quote_and_escape(cmd)}" end end |
#path_to_bin_rvm(options = {}) ⇒ Object
helper to find path to rvm binary
50 51 52 53 54 |
# File 'lib/rvm/capistrano/helpers/rvm_methods.rb', line 50 def path_to_bin_rvm(={}) result = File.join(rvm_bin_path, "rvm") result << " #{options[:with_ruby]} do" if [:with_ruby] result end |
#run_rvm(command, options = {}) ⇒ Object
shortcut to binary rvm #command
-
use :with_rvm_group => true - to wrap it all in ‘with_rvm_group(…)` call
-
use :with_ruby => ‘with_ruby’ - to extend to ‘…/bin/rvm #with_ruby do`
-
use :subject_class => :gemsets to indicate that the subject of the operation
will be a gemset; valid values are any values which can be contained in the rvm_user config variable Array. This allows us to determine whether the subject is persisted system-wide or just per-user, and as a result whether sudo is required.
30 31 32 33 34 35 36 |
# File 'lib/rvm/capistrano/helpers/rvm_methods.rb', line 30 def run_rvm(command, ={}) rvm_bin = path_to_bin_rvm() cmd = "#{rvm_bin} #{command}" cmd = with_rvm_group(cmd, ) if [:with_rvm_group] cmd = rvm_user_command() + cmd run_without_rvm(cmd) end |
#run_with_rvm(command) ⇒ Object
allow running tasks with forcing rvm_shell
18 19 20 |
# File 'lib/rvm/capistrano/helpers/rvm_methods.rb', line 18 def run_with_rvm(command) run command, :shell => "#{rvm_shell}" end |
#run_without_rvm(command) ⇒ Object
allow running tasks without using rvm_shell
13 14 15 |
# File 'lib/rvm/capistrano/helpers/rvm_methods.rb', line 13 def run_without_rvm(command) run command, :shell => "#{rvm_install_shell}" end |
#rvm_task(name, &block) ⇒ Object
defined depending on which selector was used
4 5 6 7 8 9 10 |
# File 'lib/rvm/capistrano/helpers/rvm_methods.rb', line 4 def rvm_task(name,&block) if fetch(:rvm_require_role,nil).nil? task name, &block else task name, :roles => fetch(:rvm_require_role), &block end end |
#rvm_user_command(options = {}) ⇒ Object
If we’re operating on something affected by the rvm user mode, we need to make sure that the server has the right rvm user mode. This returns a shell command to prepend to an existing command in order to achieve this.
42 43 44 45 46 47 |
# File 'lib/rvm/capistrano/helpers/rvm_methods.rb', line 42 def rvm_user_command(={}) return '' unless rvm_type == :mixed && [:subject_class] rvm_user_args = rvm_user.empty? ? 'none' : rvm_user.map(&:to_s).join(' ') rvm_bin = path_to_bin_rvm({ :with_ruby => true }.merge()) "#{rvm_bin} rvm user #{rvm_user_args} ; " end |