lib/rvm/capistrano.rb in rvm-capistrano-1.3.0.rc8 vs lib/rvm/capistrano.rb in rvm-capistrano-1.3.0.rc9

- old
+ new

@@ -8,13 +8,13 @@ unless exists?(name) set(name, *args, &block) end end - set :rvm_shell do + _cset :rvm_shell do shell = File.join(rvm_bin_path, "rvm-shell") - ruby = rvm_ruby_string.to_s.strip + ruby = fetch(:rvm_ruby_string_evaluated).strip case ruby when "release_path" shell = "rvm_path=#{rvm_path} #{shell} --path '#{release_path}'" when "local" ruby = (ENV['GEM_HOME'] || "").gsub(/.*\//, "") @@ -24,11 +24,11 @@ shell = "rvm_path=#{rvm_path} #{shell} '#{ruby}'" unless ruby.empty? end shell end if fetch(:rvm_require_role,nil).nil? - set :default_shell, fetch(:rvm_shell) + _cset :default_shell, fetch(:rvm_shell) else class << self def run(cmd, options={}, &block) if options[:eof].nil? && !cmd.include?(sudo) options = options.merge(:eof => !block_given?) @@ -81,15 +81,23 @@ else rvm_type.to_s.empty? ? "#{rvm_path}/bin" : rvm_type.to_s end end + set :rvm_ruby_string_evaluated, do + value = fetch(:rvm_ruby_string, :default) + if value.to_sym == :local + value = ENV['GEM_HOME'].gsub(/.*\//,"") + end + value.to_s + end + # Let users configure a path to export/import gemsets _cset(:rvm_gemset_path, "#{rvm_path}/gemsets") # Use the default ruby on the server, by default :) - _cset(:rvm_ruby_string, "default") + _cset(:rvm_ruby_string, :default) # Default sudo state _cset(:rvm_install_with_sudo, false) # Let users set the install type and shell of their choice. @@ -187,11 +195,11 @@ By default BASH is used for installer, change with: set :rvm_install_shell, :zsh EOF rvm_task :install_ruby do - ruby, gemset = rvm_ruby_string.to_s.strip.split /@/ + ruby, gemset = fetch(:rvm_ruby_string_evaluated).to_s.strip.split /@/ if %w( release_path default ).include? "#{ruby}" raise "ruby can not be installed when using :rvm_ruby_string => :#{ruby}" else command_install = with_rvm_group("#{File.join(rvm_bin_path, "rvm")} #{rvm_install_ruby} #{ruby} -j #{rvm_install_ruby_threads} #{rvm_install_ruby_params}") if gemset @@ -219,11 +227,11 @@ end end desc "Create gemset" rvm_task :create_gemset do - ruby, gemset = rvm_ruby_string.to_s.strip.split /@/ + ruby, gemset = fetch(:rvm_ruby_string_evaluated).to_s.strip.split /@/ if %w( release_path default ).include? "#{ruby}" raise "gemset can not be created when using :rvm_ruby_string => :#{ruby}" else if gemset run with_rvm_group("#{File.join(rvm_bin_path, "rvm")} #{ruby} do rvm gemset create #{gemset}"), :shell => "#{rvm_install_shell}" @@ -238,16 +246,16 @@ :rvm_gemset_path defaults to :rvm_path/gemsets The gemset can be created with 'cap rvm:gemset_export'. EOF rvm_task :import_gemset do - ruby, gemset = rvm_ruby_string.to_s.strip.split /@/ + ruby, gemset = fetch(:rvm_ruby_string_evaluated).to_s.strip.split /@/ if %w( release_path default ).include? "#{ruby}" raise "gemset can not be imported when using :rvm_ruby_string => :#{ruby}" else if gemset - run "#{File.join(rvm_bin_path, "rvm-shell")} #{rvm_ruby_string} rvm gemset import #{File.join(rvm_gemset_path, "#{rvm_ruby_string}.gems")}", :shell => "#{rvm_install_shell}" + run "#{File.join(rvm_bin_path, "rvm-shell")} #{fetch(:rvm_ruby_string_evaluated)} rvm gemset import #{File.join(rvm_gemset_path, "#{fetch(:rvm_ruby_string_evaluated)}.gems")}", :shell => "#{rvm_install_shell}" end end end desc <<-EOF @@ -257,27 +265,27 @@ :rvm_gemset_path defaults to :rvm_path/gemsets The gemset can be imported with 'cap rvm:gemset_import'. EOF rvm_task :export_gemset do - ruby, gemset = rvm_ruby_string.to_s.strip.split /@/ + ruby, gemset = fetch(:rvm_ruby_string_evaluated).to_s.strip.split /@/ if %w( release_path default ).include? "#{ruby}" raise "gemset can not be imported when using :rvm_ruby_string => :#{ruby}" else if gemset - run "#{File.join(rvm_bin_path, "rvm-shell")} #{rvm_ruby_string} rvm gemset export > #{File.join(rvm_gemset_path, "#{rvm_ruby_string}.gems")}", :shell => "#{rvm_install_shell}" + run "#{File.join(rvm_bin_path, "rvm-shell")} #{fetch(:rvm_ruby_string_evaluated)} rvm gemset export > #{File.join(rvm_gemset_path, "#{fetch(:rvm_ruby_string_evaluated)}.gems")}", :shell => "#{rvm_install_shell}" end end end desc "Install a gem, 'cap rvm:install_gem GEM=my_gem'." rvm_task :install_gem do - run "#{File.join(rvm_bin_path, "rvm")} #{rvm_ruby_string} do gem install #{ENV['GEM']}", :shell => "#{rvm_install_shell}" + run "#{File.join(rvm_bin_path, "rvm")} #{fetch(:rvm_ruby_string_evaluated)} do gem install #{ENV['GEM']}", :shell => "#{rvm_install_shell}" end desc "Uninstall a gem, 'cap rvm:uninstall_gem GEM=my_gem'." rvm_task :uninstall_gem do - run "#{File.join(rvm_bin_path, "rvm")} #{rvm_ruby_string} do gem uninstall --no-executables #{ENV['GEM']}", :shell => "#{rvm_install_shell}" + run "#{File.join(rvm_bin_path, "rvm")} #{fetch(:rvm_ruby_string_evaluated)} do gem uninstall --no-executables #{ENV['GEM']}", :shell => "#{rvm_install_shell}" end end end if Capistrano.const_defined? :Configuration and Capistrano::Configuration.methods.map(&:to_sym).include? :instance end