rvm-capistrano 1.4.0.rc1 → 1.4.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Manifest.yml CHANGED
@@ -4,5 +4,21 @@
4
4
  - Rakefile
5
5
  - LICENSE
6
6
  - lib/rvm/capistrano.rb
7
- - lib/rvm/capistrano/version.rb
7
+ - lib/rvm/capistrano/base.rb
8
+ - lib/rvm/capistrano/create_gemset.rb
9
+ - lib/rvm/capistrano/empty_gemset.rb
10
+ - lib/rvm/capistrano/gem_install_uninstall.rb
11
+ - lib/rvm/capistrano/gemset_import_export.rb
12
+ - lib/rvm/capistrano/install_pkgs.rb
13
+ - lib/rvm/capistrano/install_ruby.rb
14
+ - lib/rvm/capistrano/install_rvm.rb
8
15
  - lib/rvm/capistrano/selector.rb
16
+ - lib/rvm/capistrano/selector_mixed.rb
17
+ - lib/rvm/capistrano/version.rb
18
+ - lib/rvm/capistrano/helpers/_cset.rb
19
+ - lib/rvm/capistrano/helpers/base.rb
20
+ - lib/rvm/capistrano/helpers/quote_and_escape.rb
21
+ - lib/rvm/capistrano/helpers/run_silent_curl.rb
22
+ - lib/rvm/capistrano/helpers/rvm_if_sudo.rb
23
+ - lib/rvm/capistrano/helpers/rvm_methods.rb
24
+ - lib/rvm/capistrano/helpers/with_rvm_group.rb
@@ -0,0 +1,80 @@
1
+ require 'rvm/capistrano/helpers/_cset'
2
+ require 'rvm/capistrano/helpers/rvm_methods'
3
+
4
+ rvm_with_capistrano do
5
+
6
+ on :load do
7
+ _cset :rvm_shell do
8
+ shell = File.join(rvm_bin_path, "rvm-shell")
9
+ ruby = fetch(:rvm_ruby_string_evaluated).strip
10
+ case ruby
11
+ when "release_path"
12
+ shell = "rvm_path=#{rvm_path} #{shell} --path '#{release_path}'"
13
+ when "local"
14
+ ruby = (ENV['GEM_HOME'] || "").gsub(/.*\//, "")
15
+ raise "Failed to get ruby version from GEM_HOME. Please make sure rvm is loaded!" if ruby.empty?
16
+ shell = "rvm_path=#{rvm_path} #{shell} '#{ruby}'"
17
+ else
18
+ shell = "rvm_path=#{rvm_path} #{shell} '#{ruby}'" unless ruby.empty?
19
+ end
20
+ shell
21
+ end
22
+
23
+ # Let users set the type of their rvm install.
24
+ _cset(:rvm_type, :user)
25
+
26
+ # Define rvm_path
27
+ # This is used in the default_shell command to pass the required variable to rvm-shell, allowing
28
+ # rvm to boostrap using the proper path. This is being lost in Capistrano due to the lack of a
29
+ # full environment.
30
+ _cset(:rvm_path) do
31
+ case rvm_type
32
+ when :root, :system
33
+ "/usr/local/rvm"
34
+ when :local, :user, :default
35
+ "$HOME/.rvm/"
36
+ else
37
+ rvm_type.to_s.empty? ? "$HOME/.rvm" : rvm_type.to_s
38
+ end
39
+ end
40
+
41
+ # Let users override the rvm_bin_path
42
+ _cset(:rvm_bin_path) do
43
+ case rvm_type
44
+ when :root, :system
45
+ "/usr/local/rvm/bin"
46
+ when :local, :user, :default
47
+ "$HOME/.rvm/bin"
48
+ else
49
+ rvm_type.to_s.empty? ? "#{rvm_path}/bin" : rvm_type.to_s
50
+ end
51
+ end
52
+
53
+ # evaluate :rvm_ruby_string => :local
54
+ set :rvm_ruby_string_evaluated do
55
+ value = fetch(:rvm_ruby_string, :default)
56
+ if value.to_sym == :local
57
+ value = ENV['GEM_HOME'].gsub(/.*\//,"")
58
+ end
59
+ value.to_s
60
+ end
61
+
62
+ # Use the default ruby on the server, by default :)
63
+ _cset(:rvm_ruby_string, :default)
64
+
65
+ end
66
+
67
+ ## not needed in base but are used in many extensions
68
+
69
+ on :load do
70
+ # Let users set the install shell of their choice
71
+ _cset(:rvm_install_shell, :bash)
72
+ end
73
+
74
+ extend Capistrano::RvmMethods
75
+
76
+ namespace :rvm do
77
+ extend Capistrano::RvmMethods
78
+ end
79
+
80
+ end
@@ -0,0 +1,24 @@
1
+ require 'rvm/capistrano/base'
2
+ require 'rvm/capistrano/helpers/with_rvm_group'
3
+
4
+ rvm_with_capistrano do
5
+ namespace :rvm do
6
+
7
+ desc "Create gemset"
8
+ rvm_task :create_gemset do
9
+ ruby, gemset = fetch(:rvm_ruby_string_evaluated).to_s.strip.split(/@/)
10
+ if %w( release_path default ).include? "#{ruby}"
11
+ raise "
12
+
13
+ gemset can not be created when using :rvm_ruby_string => :#{ruby}
14
+
15
+ "
16
+ else
17
+ if gemset
18
+ run_rvm("rvm gemset create #{gemset}", :with_rvm_group => true, :with_ruby => ruby)
19
+ end
20
+ end
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ # Extension to empty gemset.
2
+
3
+ require 'rvm/capistrano/base'
4
+
5
+ rvm_with_capistrano do
6
+ namespace :rvm do
7
+
8
+ desc "Empty gemset"
9
+ task :empty_gemset do
10
+ ruby, gemset = rvm_ruby_string_evaluated.to_s.strip.split /@/
11
+ if %w( release_path default ).include? "#{ruby}"
12
+ raise "gemset can not be emptied when using :rvm_ruby_string => :#{ruby}"
13
+ else
14
+ if gemset
15
+ run_rvm("rvm --force gemset empty #{gemset}", :with_ruby => ruby)
16
+ end
17
+ end
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ require 'rvm/capistrano/base'
2
+
3
+ rvm_with_capistrano do
4
+ namespace :rvm do
5
+
6
+ desc "Install a gem, 'cap rvm:install_gem GEM=my_gem'."
7
+ rvm_task :install_gem do
8
+ run_rvm("gem install #{ENV['GEM']}", :with_ruby => rvm_ruby_string_evaluated)
9
+ end
10
+
11
+ desc "Uninstall a gem, 'cap rvm:uninstall_gem GEM=my_gem'."
12
+ rvm_task :uninstall_gem do
13
+ run_rvm("gem uninstall --no-executables #{ENV['GEM']}", :with_ruby => rvm_ruby_string_evaluated)
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,56 @@
1
+ require 'rvm/capistrano/base'
2
+
3
+ rvm_with_capistrano do
4
+
5
+ on :load do
6
+
7
+ # Let users configure a path to export/import gemsets
8
+ _cset(:rvm_gemset_path, "#{rvm_path}/gemsets")
9
+
10
+ end
11
+
12
+ namespace :rvm do
13
+
14
+ desc <<-EOF
15
+ Import file contents to the current RVM ruby gemset.
16
+
17
+ The gemset filename must match :rvm_ruby_string.gems and be located in :rvm_gemset_path.
18
+ :rvm_gemset_path defaults to :rvm_path/gemsets
19
+
20
+ The gemset can be created with 'cap rvm:gemset_export'.
21
+ EOF
22
+ rvm_task :import_gemset do
23
+ ruby, gemset = fetch(:rvm_ruby_string_evaluated).to_s.strip.split(/@/)
24
+ if %w( release_path default ).include? "#{ruby}"
25
+ raise "gemset can not be imported when using :rvm_ruby_string => :#{ruby}"
26
+ else
27
+ if gemset
28
+ ruby = fetch(:rvm_ruby_string_evaluated)
29
+ run_rvm("rvm gemset import #{File.join(rvm_gemset_path, "#{ruby}.gems")}", :with_ruby => ruby)
30
+ end
31
+ end
32
+ end
33
+
34
+ desc <<-EOF
35
+ Export the current RVM ruby gemset contents to a file.
36
+
37
+ The gemset filename will match :rvm_ruby_string.gems and be located in :rvm_gemset_path.
38
+ :rvm_gemset_path defaults to :rvm_path/gemsets
39
+
40
+ The gemset can be imported with 'cap rvm:gemset_import'.
41
+ EOF
42
+ rvm_task :export_gemset do
43
+ ruby, gemset = fetch(:rvm_ruby_string_evaluated).to_s.strip.split(/@/)
44
+ if %w( release_path default ).include? "#{ruby}"
45
+ raise "gemset can not be exported when using :rvm_ruby_string => :#{ruby}"
46
+ else
47
+ if gemset
48
+ ruby = fetch(:rvm_ruby_string_evaluated)
49
+ run_rvm("rvm gemset export > #{File.join(rvm_gemset_path, "#{ruby}.gems")}", :with_ruby => ruby)
50
+ end
51
+ end
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,14 @@
1
+ require 'rvm/capistrano/helpers/base'
2
+
3
+ rvm_with_capistrano do
4
+
5
+ unless methods.map(&:to_sym).include?(:_cset)
6
+ # Taken from the capistrano code.
7
+ def _cset(name, *args, &block)
8
+ unless exists?(name)
9
+ set(name, *args, &block)
10
+ end
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,8 @@
1
+ module Capistrano
2
+ end
3
+
4
+ def rvm_with_capistrano(&block)
5
+ if Capistrano.const_defined? :Configuration and Capistrano::Configuration.methods.map(&:to_sym).include? :instance
6
+ Capistrano::Configuration.instance(true).load(&block)
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ require 'rvm/capistrano/helpers/base'
2
+
3
+ rvm_with_capistrano do
4
+ def quote_and_escape(text, quote = "'")
5
+ "#{quote}#{text.gsub(/#{quote}/) { |m| "#{quote}\\#{quote}#{quote}" }}#{quote}"
6
+ end
7
+ end
@@ -0,0 +1,19 @@
1
+ require 'rvm/capistrano/base'
2
+
3
+ rvm_with_capistrano do
4
+ def run_silent_curl(command)
5
+ run_without_rvm(<<-EOF.gsub(/[\s]+/, ' '))
6
+ __LAST_STATUS=0;
7
+ export CURL_HOME="${TMPDIR:-${HOME}}/.rvm-curl-config.$$";
8
+ mkdir ${CURL_HOME}/;
9
+ {
10
+ [[ -r ${HOME}/.curlrc ]] && cat ${HOME}/.curlrc;
11
+ echo "silent";
12
+ echo "show-error";
13
+ } > $CURL_HOME/.curlrc;
14
+ #{command} || __LAST_STATUS=$?;
15
+ rm -rf $CURL_HOME;
16
+ exit ${__LAST_STATUS}
17
+ EOF
18
+ end
19
+ end
@@ -0,0 +1,43 @@
1
+ require 'rvm/capistrano/base'
2
+
3
+ rvm_with_capistrano do
4
+
5
+ on :load do
6
+ # Default sudo state
7
+ _cset(:rvm_install_with_sudo, false)
8
+ end
9
+
10
+ def rvm_if_sudo(options = {})
11
+ case rvm_type
12
+ when :root, :system
13
+ if fetch(:use_sudo, true) == false && rvm_install_with_sudo == false
14
+ explanation = <<-EXPLANATION
15
+ You can enable use_sudo within rvm for use only by this install operation by adding to deploy.rb:
16
+
17
+ set :rvm_install_with_sudo, true
18
+
19
+ EXPLANATION
20
+ if options[:deferred]
21
+ <<-DEFERRED_ERROR.gsub(/\n/, " ; ")
22
+ echo "
23
+ Neither :use_sudo or :rvm_install_with_sudo was set and installation would ended up in using 'sudo'
24
+ #{explanation}
25
+ " >&2
26
+ exit 1
27
+ DEFERRED_ERROR
28
+ else
29
+ raise "
30
+
31
+ :use_sudo is set to 'false' but sudo is needed to install rvm_type: #{rvm_type}.
32
+ #{explanation}
33
+ "
34
+ end
35
+ else
36
+ "#{sudo} "
37
+ end
38
+ else
39
+ ''
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,40 @@
1
+ module Capistrano
2
+ module RvmMethods
3
+ # defined depending on which selector was used
4
+ def rvm_task(name,&block)
5
+ if fetch(:rvm_require_role,nil).nil?
6
+ task name, &block
7
+ else
8
+ task name, :roles => fetch(:rvm_require_role), &block
9
+ end
10
+ end
11
+
12
+ # allow running tasks without using rvm_shell
13
+ def run_without_rvm(command)
14
+ run command, :shell => "#{rvm_install_shell}"
15
+ end
16
+
17
+ # allow running tasks with forcing rvm_shell
18
+ def run_with_rvm(command)
19
+ run command, :shell => "#{rvm_shell}"
20
+ end
21
+
22
+ # shortcut to binary rvm #{command}
23
+ # - use :with_rvm_group => true - to wrap it all in `with_rvm_group(...)` call
24
+ # - use :with_ruby => 'with_ruby' - to extend to `.../bin/rvm #{with_ruby} do`
25
+ def run_rvm(command, options={})
26
+ if options[:with_rvm_group]
27
+ run_without_rvm("#{path_to_bin_rvm(options)} #{command}")
28
+ else
29
+ run_without_rvm(with_rvm_group("#{path_to_bin_rvm(options)} #{command}"))
30
+ end
31
+ end
32
+
33
+ # helper to find path to rvm binary
34
+ def path_to_bin_rvm(options={})
35
+ result = File.join(rvm_bin_path, "rvm")
36
+ result << " #{options[:with_ruby]} do" if options[:with_ruby]
37
+ result
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,21 @@
1
+ require 'rvm/capistrano/helpers/base'
2
+ require 'rvm/capistrano/helpers/rvm_if_sudo'
3
+ require 'rvm/capistrano/helpers/quote_and_escape'
4
+
5
+ rvm_with_capistrano do
6
+
7
+ def with_rvm_group(command)
8
+ case rvm_type
9
+ when :root, :system
10
+ <<-CODE
11
+ if id | grep ' groups=.*(rvm)' >/dev/null ;
12
+ then #{command} ;
13
+ else #{rvm_if_sudo(:deferred=>true)} sg rvm -c #{quote_and_escape(command)} ;
14
+ fi
15
+ CODE
16
+ else
17
+ command
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,38 @@
1
+ require 'rvm/capistrano/base'
2
+
3
+ rvm_with_capistrano do
4
+
5
+ warn "task 'rvm:install_pkgs' is deprecated, please read about autolibs => http://rvm.io/rvm/autolibs especially check the autolibs mode 'rvm_pkg'."
6
+
7
+ on :load do
8
+
9
+ # Additional rvm packages to install.
10
+ _cset(:rvm_install_pkgs, [])
11
+
12
+ end
13
+
14
+ namespace :rvm do
15
+
16
+ desc <<-EOF
17
+ WARNING: Deprecated, please read about autolibs => http://rvm.io/rvm/autolibs especially check the autolibs mode 'rvm_pkg'.
18
+
19
+ Install RVM packages to the server.
20
+
21
+ This must come before the 'rvm:install_ruby' task is called.
22
+
23
+ The package list is empty by default. Specifiy the packages to install with:
24
+
25
+ set :rvm_install_pkgs, %w[libyaml curl]
26
+
27
+ Full list of packages available at https://rvm.io/packages/ or by running 'rvm pkg'.
28
+ EOF
29
+
30
+ rvm_task :install_pkgs do
31
+ rvm_install_pkgs.each do |pkg|
32
+ run_rvm("pkg install #{pkg}")
33
+ end
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,73 @@
1
+ require 'rvm/capistrano/base'
2
+ require 'rvm/capistrano/helpers/run_silent_curl'
3
+ require 'rvm/capistrano/helpers/rvm_if_sudo'
4
+ require 'rvm/capistrano/helpers/with_rvm_group'
5
+
6
+ rvm_with_capistrano do
7
+
8
+ on :load do
9
+
10
+ # Let users set the (re)install for ruby.
11
+ _cset(:rvm_install_ruby, :install)
12
+
13
+ # Pass no special params to the ruby build by default
14
+ _cset(:rvm_install_ruby_params, '')
15
+
16
+ end
17
+
18
+ namespace :rvm do
19
+
20
+ desc <<-EOF
21
+ Install RVM ruby to the server, create gemset if needed.
22
+ By default ruby is installed, you can reinstall with:
23
+
24
+ set :rvm_install_ruby, :reinstall
25
+
26
+ By default ruby is compiled using all CPU cores, change with:
27
+
28
+ set :rvm_install_ruby_threads, 5
29
+
30
+ By default BASH is used for installer, change with:
31
+
32
+ set :rvm_install_shell, :zsh
33
+ EOF
34
+ rvm_task :install_ruby do
35
+ ruby, gemset = fetch(:rvm_ruby_string_evaluated).to_s.strip.split(/@/)
36
+ if %w( release_path default ).include? "#{ruby}"
37
+ raise "
38
+
39
+ ruby can not be installed when using :rvm_ruby_string => :#{ruby}
40
+
41
+ "
42
+ else
43
+ command_install = ""
44
+
45
+ autolibs_flag = fetch(:rvm_autolibs_flag, 2).to_s
46
+ autolibs_flag_no_requirements = %w(
47
+ 0 disable disabled
48
+ 1 read read-only
49
+ 2 fail read-fail
50
+ ).include?( autolibs_flag )
51
+
52
+ install_ruby_threads = fetch(:rvm_install_ruby_threads,nil).nil? ? '' : "-j #{rvm_install_ruby_threads}"
53
+
54
+ if autolibs_flag_no_requirements
55
+ command_install << with_rvm_group("#{path_to_bin_rvm} --autolibs=#{autolibs_flag} #{rvm_install_ruby} #{ruby} #{install_ruby_threads} #{rvm_install_ruby_params}")
56
+ else
57
+ command_install << "#{rvm_if_sudo} #{path_to_bin_rvm} --autolibs=#{autolibs_flag} requirements #{ruby}"
58
+ command_install << "; "
59
+ command_install << with_rvm_group("#{path_to_bin_rvm} --autolibs=1 #{rvm_install_ruby} #{ruby} #{install_ruby_threads} #{rvm_install_ruby_params}")
60
+ end
61
+
62
+ if gemset
63
+ command_install << "; "
64
+ command_install << with_rvm_group("#{path_to_bin_rvm(:with_ruby=>ruby)} rvm gemset create #{gemset}")
65
+ end
66
+
67
+ run_silent_curl command_install
68
+ end
69
+ end
70
+
71
+ end
72
+
73
+ end
@@ -0,0 +1,42 @@
1
+ require 'rvm/capistrano/base'
2
+ require 'rvm/capistrano/helpers/run_silent_curl'
3
+ require 'rvm/capistrano/helpers/rvm_if_sudo'
4
+
5
+ rvm_with_capistrano do
6
+
7
+ on :load do
8
+
9
+ # Let users set the install type of their choice.
10
+ _cset(:rvm_install_type, :stable)
11
+
12
+ # By default system installations add deploying user to rvm group. also try :all
13
+ _cset(:rvm_add_to_group, fetch(:user,"$USER"))
14
+
15
+ end
16
+
17
+ namespace :rvm do
18
+
19
+ desc <<-EOF
20
+ Install RVM of the given choice to the server.
21
+ By default RVM "stable" is installed, change with:
22
+
23
+ set :rvm_install_type, :head
24
+
25
+ By default BASH is used for installer, change with:
26
+
27
+ set :rvm_install_shell, :zsh
28
+ EOF
29
+ rvm_task :install_rvm do
30
+ command_fetch = "curl -L get.rvm.io"
31
+ command_install = rvm_if_sudo
32
+ command_install << "#{rvm_install_shell} -s #{rvm_install_type} --path #{rvm_path}"
33
+ case rvm_type
34
+ when :root, :system
35
+ command_install << " --add-to-rvm-group #{[rvm_add_to_group].flatten.map(&:to_s).join(",")}"
36
+ end
37
+ run_silent_curl "#{command_fetch} | #{command_install}"
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -1,71 +1,22 @@
1
- module Capistrano
2
- Configuration.instance(true).load do
3
- on :load do
4
- _cset :rvm_shell do
5
- shell = File.join(rvm_bin_path, "rvm-shell")
6
- ruby = fetch(:rvm_ruby_string_evaluated).strip
7
- case ruby
8
- when "release_path"
9
- shell = "rvm_path=#{rvm_path} #{shell} --path '#{release_path}'"
10
- when "local"
11
- ruby = (ENV['GEM_HOME'] || "").gsub(/.*\//, "")
12
- raise "Failed to get ruby version from GEM_HOME. Please make sure rvm is loaded!" if ruby.empty?
13
- shell = "rvm_path=#{rvm_path} #{shell} '#{ruby}'"
14
- else
15
- shell = "rvm_path=#{rvm_path} #{shell} '#{ruby}'" unless ruby.empty?
16
- end
17
- shell
18
- end
1
+ require 'rvm/capistrano/base'
19
2
 
20
- # this is part of check, search for :rvm_require_role
21
- if fetch(:rvm_require_role,nil).nil?
22
- set :default_shell do
23
- fetch(:rvm_shell)
24
- end
25
- end
3
+ rvm_with_capistrano do
4
+ on :load do
26
5
 
27
- # Let users set the type of their rvm install.
28
- _cset(:rvm_type, :user)
6
+ # conflicts with rvm/capistrano/selector_mixed
7
+ unless fetch(:rvm_require_role,nil).nil?
8
+ raise "
29
9
 
30
- # Define rvm_path
31
- # This is used in the default_shell command to pass the required variable to rvm-shell, allowing
32
- # rvm to boostrap using the proper path. This is being lost in Capistrano due to the lack of a
33
- # full environment.
34
- _cset(:rvm_path) do
35
- case rvm_type
36
- when :root, :system
37
- "/usr/local/rvm"
38
- when :local, :user, :default
39
- "$HOME/.rvm/"
40
- else
41
- rvm_type.to_s.empty? ? "$HOME/.rvm" : rvm_type.to_s
42
- end
43
- end
10
+ ERROR: found: 'set :rvm_require_role, \"#{fetch(:rvm_require_role,nil)}\"',
11
+ it conflicts with 'require \"rvm/capistrano/selector\"',
12
+ please remove it.
44
13
 
45
- # Let users override the rvm_bin_path
46
- _cset(:rvm_bin_path) do
47
- case rvm_type
48
- when :root, :system
49
- "/usr/local/rvm/bin"
50
- when :local, :user, :default
51
- "$HOME/.rvm/bin"
52
- else
53
- rvm_type.to_s.empty? ? "#{rvm_path}/bin" : rvm_type.to_s
54
- end
55
- end
56
-
57
- # evaluate :rvm_ruby_string => :local
58
- set :rvm_ruby_string_evaluated do
59
- value = fetch(:rvm_ruby_string, :default)
60
- if value.to_sym == :local
61
- value = ENV['GEM_HOME'].gsub(/.*\//,"")
62
- end
63
- value.to_s
64
- end
65
-
66
- # Use the default ruby on the server, by default :)
67
- _cset(:rvm_ruby_string, :default)
14
+ "
15
+ end
68
16
 
17
+ set :default_shell do
18
+ fetch(:rvm_shell)
69
19
  end
20
+
70
21
  end
71
22
  end
@@ -0,0 +1,41 @@
1
+ require 'rvm/capistrano/base'
2
+ require 'rvm/capistrano/helpers/quote_and_escape'
3
+
4
+ rvm_with_capistrano do
5
+
6
+ if fetch(:rvm_require_role,nil).nil?
7
+ raise "
8
+
9
+ ERROR: no 'set :rvm_require_role, \"...\"' declared before 'rvm/capistrano/selector_mixed',
10
+ it is required for proper functioning, please add it and try again.
11
+
12
+ "
13
+ end
14
+
15
+ # conflicts with rvm/capistrano/selector
16
+ class << self
17
+ def run(cmd, options={}, &block)
18
+ if options[:eof].nil? && !cmd.include?(sudo)
19
+ options = options.merge(:eof => !block_given?)
20
+ end
21
+ shell = options[:shell]
22
+ options[:shell] = false
23
+
24
+ parallel(options) do |session|
25
+ if shell.nil?
26
+ session.when "in?(:#{fetch(:rvm_require_role,nil)})", command_with_shell(cmd, fetch(:rvm_shell)), &block
27
+ end
28
+ session.else command_with_shell(cmd, shell), &block
29
+ end
30
+ end
31
+
32
+ def command_with_shell(cmd, shell=nil)
33
+ if shell == false
34
+ cmd
35
+ else
36
+ "#{shell || "sh"} -c #{quote_and_escape(cmd)}"
37
+ end
38
+ end
39
+
40
+ end
41
+ end
@@ -1,5 +1,5 @@
1
1
  module RVM
2
2
  class Capistrano
3
- VERSION="1.4.0.rc1"
3
+ VERSION="1.4.0.rc2"
4
4
  end
5
5
  end
@@ -1,320 +1,11 @@
1
1
  # Recipes for using RVM on a server with capistrano.
2
2
 
3
3
  require 'rvm/capistrano/selector'
4
-
5
- module Capistrano
6
- Configuration.instance(true).load do
7
-
8
- unless methods.map(&:to_sym).include?(:_cset)
9
- # Taken from the capistrano code.
10
- def _cset(name, *args, &block)
11
- unless exists?(name)
12
- set(name, *args, &block)
13
- end
14
- end
15
- end
16
-
17
- class << self
18
- def quote_and_escape(text, quote = "'")
19
- "#{quote}#{text.gsub(/#{quote}/) { |m| "#{quote}\\#{quote}#{quote}" }}#{quote}"
20
- end
21
- end
22
-
23
- # this is part of check, search for :rvm_require_role
24
- unless fetch(:rvm_require_role,nil).nil?
25
- set :rvm_require_role_was_set_before_require, true
26
- class << self
27
- def run(cmd, options={}, &block)
28
- if options[:eof].nil? && !cmd.include?(sudo)
29
- options = options.merge(:eof => !block_given?)
30
- end
31
- shell = options[:shell]
32
- options[:shell] = false
33
-
34
- parallel(options) do |session|
35
- if shell.nil?
36
- session.when "in?(:#{fetch(:rvm_require_role,nil)})", command_with_shell(cmd, fetch(:rvm_shell)), &block
37
- end
38
- session.else command_with_shell(cmd, shell), &block
39
- end
40
- end
41
- def command_with_shell(cmd, shell=nil)
42
- if shell == false
43
- cmd
44
- else
45
- "#{shell || "sh"} -c #{quote_and_escape(cmd)}"
46
- end
47
- end
48
- end
49
- end
50
-
51
- on :load do
52
-
53
- # this is part of check, search for :rvm_require_role
54
- if ! fetch(:rvm_require_role,nil).nil? and fetch(:rvm_require_role_was_set_before_require, nil).nil?
55
- raise "
56
-
57
- ERROR: detected 'set :rvm_require_role, \"#{fetch(:rvm_require_role,nil)}\"' after 'require \"rvm/capistrano\"', please move it above for proper functioning.
58
-
59
- "
60
- end
61
-
62
- # Let users configure a path to export/import gemsets
63
- _cset(:rvm_gemset_path, "#{rvm_path}/gemsets")
64
-
65
- # Default sudo state
66
- _cset(:rvm_install_with_sudo, false)
67
-
68
- # Let users set the install type and shell of their choice.
69
- _cset(:rvm_install_type, :stable)
70
- _cset(:rvm_install_shell, :bash)
71
-
72
- # Let users set the (re)install for ruby.
73
- _cset(:rvm_install_ruby, :install)
74
-
75
- # Pass no special params to the ruby build by default
76
- _cset(:rvm_install_ruby_params, '')
77
-
78
- # Additional rvm packages to install.
79
- _cset(:rvm_install_pkgs, [])
80
-
81
- # By default system installations add deploying user to rvm group. also try :all
82
- _cset(:rvm_add_to_group, fetch(:user,"$USER"))
83
-
84
- end
85
-
86
- namespace :rvm do
87
-
88
- def run_silent_curl(command)
89
- run(<<-EOF.gsub(/[\s]+/, ' '), :shell => "#{rvm_install_shell}")
90
- __LAST_STATUS=0;
91
- export CURL_HOME="${TMPDIR:-${HOME}}/.rvm-curl-config.$$";
92
- mkdir ${CURL_HOME}/;
93
- {
94
- [[ -r ${HOME}/.curlrc ]] && cat ${HOME}/.curlrc;
95
- echo "silent";
96
- echo "show-error";
97
- } > $CURL_HOME/.curlrc;
98
- #{command} || __LAST_STATUS=$?;
99
- rm -rf $CURL_HOME;
100
- exit ${__LAST_STATUS}
101
- EOF
102
- end
103
-
104
- def rvm_if_sudo(options = {})
105
- case rvm_type
106
- when :root, :system
107
- if fetch(:use_sudo, true) == false && rvm_install_with_sudo == false
108
- explanation = <<-EXPLANATION
109
- You can enable use_sudo within rvm for use only by this install operation by adding to deploy.rb:
110
-
111
- set :rvm_install_with_sudo, true
112
-
113
- EXPLANATION
114
- if options[:deferred]
115
- <<-DEFERRED_ERROR.gsub(/\n/, " ; ")
116
- echo "
117
- Neither :use_sudo or :rvm_install_with_sudo was set and installation would ended up in using 'sudo'
118
- #{explanation}
119
- " >&2
120
- exit 1
121
- DEFERRED_ERROR
122
- else
123
- raise "
124
-
125
- :use_sudo is set to 'false' but sudo is needed to install rvm_type: #{rvm_type}.
126
- #{explanation}
127
- "
128
- end
129
- else
130
- "#{sudo} "
131
- end
132
- else
133
- ''
134
- end
135
- end
136
-
137
- def with_rvm_group(command)
138
- case rvm_type
139
- when :root, :system
140
- <<-CODE
141
- if id | grep ' groups=.*(rvm)' >/dev/null ;
142
- then #{command} ;
143
- else #{rvm_if_sudo(:deferred=>true)} sg rvm -c #{quote_and_escape(command)} ;
144
- fi
145
- CODE
146
- else
147
- command
148
- end
149
- end
150
-
151
- def rvm_task(name,&block)
152
- if fetch(:rvm_require_role,nil).nil?
153
- task name, &block
154
- else
155
- task name, :roles => fetch(:rvm_require_role), &block
156
- end
157
- end
158
-
159
- desc <<-EOF
160
- Install RVM of the given choice to the server.
161
- By default RVM "stable" is installed, change with:
162
-
163
- set :rvm_install_type, :head
164
-
165
- By default BASH is used for installer, change with:
166
-
167
- set :rvm_install_shell, :zsh
168
- EOF
169
- rvm_task :install_rvm do
170
- command_fetch = "curl -L get.rvm.io"
171
- command_install = rvm_if_sudo
172
- command_install << "#{rvm_install_shell} -s #{rvm_install_type} --path #{rvm_path}"
173
- case rvm_type
174
- when :root, :system
175
- command_install << " --add-to-rvm-group #{[rvm_add_to_group].flatten.map(&:to_s).join(",")}"
176
- end
177
- run_silent_curl "#{command_fetch} | #{command_install}"
178
- end
179
-
180
- desc <<-EOF
181
- Install RVM ruby to the server, create gemset if needed.
182
- By default ruby is installed, you can reinstall with:
183
-
184
- set :rvm_install_ruby, :reinstall
185
-
186
- By default ruby is compiled using all CPU cores, change with:
187
-
188
- set :rvm_install_ruby_threads, 5
189
-
190
- By default BASH is used for installer, change with:
191
-
192
- set :rvm_install_shell, :zsh
193
- EOF
194
- rvm_task :install_ruby do
195
- ruby, gemset = fetch(:rvm_ruby_string_evaluated).to_s.strip.split(/@/)
196
- if %w( release_path default ).include? "#{ruby}"
197
- raise "
198
-
199
- ruby can not be installed when using :rvm_ruby_string => :#{ruby}
200
-
201
- "
202
- else
203
- command_install = ""
204
-
205
- autolibs_flag = fetch(:rvm_autolibs_flag, 2).to_s
206
- autolibs_flag_no_requirements = %w(
207
- 0 disable disabled
208
- 1 read read-only
209
- 2 fail read-fail
210
- ).include?( autolibs_flag )
211
-
212
- install_ruby_threads = fetch(:rvm_install_ruby_threads,nil).nil? ? '' : "-j #{rvm_install_ruby_threads}"
213
-
214
- if autolibs_flag_no_requirements
215
- command_install << with_rvm_group("#{File.join(rvm_bin_path, "rvm")} --autolibs=#{autolibs_flag} #{rvm_install_ruby} #{ruby} #{install_ruby_threads} #{rvm_install_ruby_params}")
216
- else
217
- command_install << "#{rvm_if_sudo} #{File.join(rvm_bin_path, "rvm")} --autolibs=#{autolibs_flag} requirements #{ruby}"
218
- command_install << "; "
219
- command_install << with_rvm_group("#{File.join(rvm_bin_path, "rvm")} --autolibs=1 #{rvm_install_ruby} #{ruby} #{install_ruby_threads} #{rvm_install_ruby_params}")
220
- end
221
-
222
- if gemset
223
- command_install << "; "
224
- command_install << with_rvm_group("#{File.join(rvm_bin_path, "rvm")} #{ruby} do rvm gemset create #{gemset}")
225
- end
226
-
227
- run_silent_curl command_install
228
- end
229
- end
230
-
231
- desc <<-EOF
232
- Install RVM packages to the server.
233
-
234
- This must come before the 'rvm:install_ruby' task is called.
235
-
236
- The package list is empty by default. Specifiy the packages to install with:
237
-
238
- set :rvm_install_pkgs, %w[libyaml curl]
239
-
240
- Full list of packages available at https://rvm.io/packages/ or by running 'rvm pkg'.
241
- EOF
242
- rvm_task :install_pkgs do
243
- rvm_install_pkgs.each do |pkg|
244
- run "#{File.join(rvm_bin_path, "rvm")} pkg install #{pkg}", :shell => "#{rvm_install_shell}"
245
- end
246
- end
247
-
248
- desc "Create gemset"
249
- rvm_task :create_gemset do
250
- ruby, gemset = fetch(:rvm_ruby_string_evaluated).to_s.strip.split(/@/)
251
- if %w( release_path default ).include? "#{ruby}"
252
- raise "
253
-
254
- gemset can not be created when using :rvm_ruby_string => :#{ruby}
255
-
256
- "
257
- else
258
- if gemset
259
- run with_rvm_group("#{File.join(rvm_bin_path, "rvm")} #{ruby} do rvm gemset create #{gemset}"), :shell => "#{rvm_install_shell}"
260
- end
261
- end
262
- end
263
-
264
- desc <<-EOF
265
- Import file contents to the current RVM ruby gemset.
266
-
267
- The gemset filename must match :rvm_ruby_string.gems and be located in :rvm_gemset_path.
268
- :rvm_gemset_path defaults to :rvm_path/gemsets
269
-
270
- The gemset can be created with 'cap rvm:gemset_export'.
271
- EOF
272
- rvm_task :import_gemset do
273
- ruby, gemset = fetch(:rvm_ruby_string_evaluated).to_s.strip.split(/@/)
274
- if %w( release_path default ).include? "#{ruby}"
275
- raise "gemset can not be imported when using :rvm_ruby_string => :#{ruby}"
276
- else
277
- if gemset
278
- 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}"
279
- end
280
- end
281
- end
282
-
283
- desc <<-EOF
284
- Export the current RVM ruby gemset contents to a file.
285
-
286
- The gemset filename will match :rvm_ruby_string.gems and be located in :rvm_gemset_path.
287
- :rvm_gemset_path defaults to :rvm_path/gemsets
288
-
289
- The gemset can be imported with 'cap rvm:gemset_import'.
290
- EOF
291
- rvm_task :export_gemset do
292
- ruby, gemset = fetch(:rvm_ruby_string_evaluated).to_s.strip.split(/@/)
293
- if %w( release_path default ).include? "#{ruby}"
294
- raise "gemset can not be imported when using :rvm_ruby_string => :#{ruby}"
295
- else
296
- if gemset
297
- 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}"
298
- end
299
- end
300
- end
301
-
302
- desc "Install a gem, 'cap rvm:install_gem GEM=my_gem'."
303
- rvm_task :install_gem do
304
- run "#{File.join(rvm_bin_path, "rvm")} #{fetch(:rvm_ruby_string_evaluated)} do gem install #{ENV['GEM']}", :shell => "#{rvm_install_shell}"
305
- end
306
-
307
- desc "Uninstall a gem, 'cap rvm:uninstall_gem GEM=my_gem'."
308
- rvm_task :uninstall_gem do
309
- run "#{File.join(rvm_bin_path, "rvm")} #{fetch(:rvm_ruby_string_evaluated)} do gem uninstall --no-executables #{ENV['GEM']}", :shell => "#{rvm_install_shell}"
310
- end
311
-
312
- end
313
- end if Capistrano.const_defined? :Configuration and Capistrano::Configuration.methods.map(&:to_sym).include? :instance
314
- end
4
+ require 'rvm/capistrano/install_rvm'
5
+ require 'rvm/capistrano/install_ruby'
6
+ require 'rvm/capistrano/create_gemset'
315
7
 
316
8
  # E.g, to use ree and rails 3:
317
9
  #
318
10
  # require 'rvm/capistrano'
319
11
  # set :rvm_ruby_string, "ree@rails3"
320
- #
metadata CHANGED
@@ -1,99 +1,139 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rvm-capistrano
3
- version: !ruby/object:Gem::Version
4
- version: 1.4.0.rc1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 2304346973
5
+ prerelease: 6
6
+ segments:
7
+ - 1
8
+ - 4
9
+ - 0
10
+ - rc
11
+ - 2
12
+ version: 1.4.0.rc2
5
13
  platform: ruby
6
- authors:
14
+ authors:
7
15
  - Wayne E. Seguin
8
16
  - Michal Papis
9
17
  autorequire:
10
18
  bindir: bin
11
19
  cert_chain: []
12
- date: 2013-06-29 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
20
+
21
+ date: 2013-07-01 00:00:00 Z
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
15
24
  name: capistrano
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - '>='
19
- - !ruby/object:Gem::Version
20
- version: 2.0.0
21
- type: :runtime
22
25
  prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - '>='
26
- - !ruby/object:Gem::Version
26
+ requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ hash: 15
32
+ segments:
33
+ - 2
34
+ - 0
35
+ - 0
27
36
  version: 2.0.0
28
- - !ruby/object:Gem::Dependency
37
+ type: :runtime
38
+ version_requirements: *id001
39
+ - !ruby/object:Gem::Dependency
29
40
  name: rake
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - '>='
33
- - !ruby/object:Gem::Version
34
- version: '0'
35
- type: :development
36
41
  prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - '>='
40
- - !ruby/object:Gem::Version
41
- version: '0'
42
- - !ruby/object:Gem::Dependency
43
- name: minitest
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - '>='
47
- - !ruby/object:Gem::Version
48
- version: '0'
42
+ requirement: &id002 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ hash: 3
48
+ segments:
49
+ - 0
50
+ version: "0"
49
51
  type: :development
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: minitest
50
55
  prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - '>='
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ type: :development
66
+ version_requirements: *id003
56
67
  description: RVM / Capistrano Integration Gem
57
- email:
68
+ email:
58
69
  - wayneeseguin@gmail.com
59
70
  - mpapis@gmail.com
60
71
  executables: []
72
+
61
73
  extensions: []
74
+
62
75
  extra_rdoc_files: []
63
- files:
76
+
77
+ files:
64
78
  - History.md
65
79
  - Manifest.yml
66
80
  - README.md
67
81
  - Rakefile
68
82
  - LICENSE
69
83
  - lib/rvm/capistrano.rb
70
- - lib/rvm/capistrano/version.rb
84
+ - lib/rvm/capistrano/base.rb
85
+ - lib/rvm/capistrano/create_gemset.rb
86
+ - lib/rvm/capistrano/empty_gemset.rb
87
+ - lib/rvm/capistrano/gem_install_uninstall.rb
88
+ - lib/rvm/capistrano/gemset_import_export.rb
89
+ - lib/rvm/capistrano/install_pkgs.rb
90
+ - lib/rvm/capistrano/install_ruby.rb
91
+ - lib/rvm/capistrano/install_rvm.rb
71
92
  - lib/rvm/capistrano/selector.rb
93
+ - lib/rvm/capistrano/selector_mixed.rb
94
+ - lib/rvm/capistrano/version.rb
95
+ - lib/rvm/capistrano/helpers/_cset.rb
96
+ - lib/rvm/capistrano/helpers/base.rb
97
+ - lib/rvm/capistrano/helpers/quote_and_escape.rb
98
+ - lib/rvm/capistrano/helpers/run_silent_curl.rb
99
+ - lib/rvm/capistrano/helpers/rvm_if_sudo.rb
100
+ - lib/rvm/capistrano/helpers/rvm_methods.rb
101
+ - lib/rvm/capistrano/helpers/with_rvm_group.rb
72
102
  - spec/spec_helper.rb
73
103
  homepage: https://github.com/wayneeseguin/rvm-capistrano
74
- licenses:
104
+ licenses:
75
105
  - MIT
76
- metadata: {}
77
106
  post_install_message:
78
107
  rdoc_options: []
79
- require_paths:
108
+
109
+ require_paths:
80
110
  - lib
81
- required_ruby_version: !ruby/object:Gem::Requirement
82
- requirements:
83
- - - '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- required_rubygems_version: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - '>'
89
- - !ruby/object:Gem::Version
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
119
+ version: "0"
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ">"
124
+ - !ruby/object:Gem::Version
125
+ hash: 25
126
+ segments:
127
+ - 1
128
+ - 3
129
+ - 1
90
130
  version: 1.3.1
91
131
  requirements: []
132
+
92
133
  rubyforge_project:
93
- rubygems_version: 2.0.3
134
+ rubygems_version: 1.8.24
94
135
  signing_key:
95
- specification_version: 4
136
+ specification_version: 3
96
137
  summary: RVM / Capistrano Integration Gem
97
- test_files:
138
+ test_files:
98
139
  - spec/spec_helper.rb
99
- has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 67171efbb1be95f398a8e0d60b0f75b64e53d983
4
- data.tar.gz: f86de38a275c25f83ca86b1b701545d53d5da392
5
- SHA512:
6
- metadata.gz: 6abd4c7ac08bdf41280248502dce2d406cc55a57c6b70062a3cd5a1ab97371d787b42895856d65a08dab8684b3bb741f08305a20648d3fcc8151eedb4db93df5
7
- data.tar.gz: c1b5f9c83a83949c98d1a4bb0348307ec7f63bb5600f5731e93e713b97a7f8789d1c9c3cdafb8236c2448c978bc318fc6dea441a4f60dcfd0697eae2b9fe5524