capistrano-rvm 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,41 +1,112 @@
1
- # Capistrano::Rvm
1
+ # Capistrano::RVM
2
2
 
3
- Capistrano tasks to work with RVM
3
+ RVM support for Capistrano 3.x
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'capistrano-rvm'
9
+ # Gemfile
10
+ gem 'capistrano', github: 'capistrano/capistrano', branch: 'v3'
11
+ gem 'capistrano-rvm', github: "capistrano/rvm"
10
12
 
11
13
  And then execute:
12
14
 
13
- $ bundle
15
+ $ bundle --binstubs
16
+ $ cap install
14
17
 
15
- Or install it yourself as:
18
+ ## Usage
16
19
 
17
- $ gem install capistrano-rvm
20
+ Require in Capfile to use the default task:
18
21
 
19
- ## Usage
22
+ # Capfile
23
+ require 'capistrano/rvm'
24
+
25
+ And you should be good to go!
26
+
27
+ ## Configuration
28
+
29
+ Set those in the stage file dependant on your server configuration:
30
+
31
+ # stage file (staging.rb, production.rb or else)
32
+ set :rvm_type, :user
33
+ set :rvm_ruby_version, '2.0.0-p247'
34
+ set :rvm_custom_path, '~/.myveryownrvm'
35
+
36
+ ### RVM path selection: `:rvm_type`
37
+
38
+ Valid options are:
39
+ * `:auto` (default): just tries to find the correct path.
40
+ `/usr/local/rvm` wins over `~/.rvm`
41
+ * `:system`: defines the RVM path to `/usr/local/rvm`
42
+ * `:user`: defines the RVM path to `~/.rvm`
43
+ * `:mixed`: defines the RVM path to `/usr/local/rvm` for rvm and `~/.rvm` for wrapped commands
44
+
45
+ ### Ruby and gemset selection: `:rvm_ruby_version`
46
+
47
+ By default the Ruby and gemset is used which is returned by `rvm current` on
48
+ the target host.
49
+
50
+ You can omit the ruby patch level from `:rvm_ruby_version` if you want, and
51
+ capistrano will choose the most recent patch level for that version of ruby:
52
+
53
+ set :rvm_ruby_version '2.0.0'
54
+
55
+ If you are using an rvm gemset, just specify it after your ruby_version:
56
+
57
+ set :rvm_ruby_version, '2.0.0-p247@mygemset'
58
+
59
+ or
60
+
61
+ set :rvm_ruby_version, '2.0.0@mygemset'
62
+
63
+
64
+ ### Custom RVM path: `:rvm_custom_path`
65
+
66
+ If you have a custom RVM setup with a different path then expected, you have
67
+ to define a custom RVM path to tell capistrano where it is.
68
+
69
+
70
+ ## Restrictions
71
+
72
+ Capistrano can't (yet) use rvm to install rubies or create gemsets, so on the
73
+ servers you are deploying to, you will have to manually use rvm to install the
74
+ proper ruby and create the gemset.
75
+
76
+
77
+ ## How it works
78
+
79
+ This gem adds a new task `rvm:hook` before `deploy:starting`. It uses the `rvm
80
+ wrapper` command to create wrapper scripts for this application that use the
81
+ desired ruby and gemset. These wrapper scripts are then used by capistrano
82
+ when it wants to run `rake`, `gem`, `bundle`, or `ruby`.
83
+
84
+
85
+ ## Check your configuration
86
+
87
+ If you want to check your configuration you can use the `rvm:check` task to
88
+ get information about the RVM version and ruby which would be used for
89
+ deployment.
90
+
91
+ $ cap production rvm:check
20
92
 
21
- Add this after you define rvm_ruby_string:
22
93
 
23
- require 'capistrano-rvm'
94
+ ## Custom tasks which rely on RVM/Ruby
24
95
 
25
- This gem includes the following tasks:
96
+ When building custom tasks which need a the corrent ruby and gemset, all you
97
+ have to do is run the `rvm:hook` task before your own task. This will create
98
+ the necessary wrappers and handles the execution of the ruby-related commands.
99
+ This is only necessary if your task is *not* *after* the `deploy:starting` task.
26
100
 
27
- cap rvm # Installs rvm, ruby and bundler
28
- cap rvm:create_gemset # Creates the gemset to use
29
- cap rvm:default_ruby # sets as default current ruby version
30
- cap rvm:install # Installs rvm
31
- cap rvm:install_bundler # Install bundler gem
32
- cap rvm:install_ruby # Installs ruby version specified in rvm_ruby_st...
101
+ before :my_custom_task, 'rvm:hook'
33
102
 
103
+ The hook can be called multiple times per `cap` run - it only creates the
104
+ wrappers once.
34
105
 
35
106
  ## Contributing
36
107
 
37
108
  1. Fork it
38
109
  2. Create your feature branch (`git checkout -b my-new-feature`)
39
- 3. Commit your changes (`git commit -am 'Added some feature'`)
110
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
111
  4. Push to the branch (`git push origin my-new-feature`)
41
112
  5. Create new Pull Request
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
- #!/usr/bin/env rake
2
1
  require "bundler/gem_tasks"
@@ -1,19 +1,20 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/capistrano-rvm/version', __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
4
 
4
5
  Gem::Specification.new do |gem|
5
- gem.authors = ["Edwin Cruz"]
6
- gem.email = ["softr8@gmail.com"]
7
- gem.description = %q{Capistrano tasks to manage rvm commands}
8
- gem.summary = %q{Some tasks to install rvm, ruby and bundler without pain}
9
- gem.homepage = ""
10
-
11
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
- gem.files = `git ls-files`.split("\n")
13
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
6
  gem.name = "capistrano-rvm"
7
+ gem.version = '0.0.2'
8
+ gem.authors = ["Kir Shatrov"]
9
+ gem.email = ["shatrov@me.com"]
10
+ gem.description = %q{RVM integration for Capistrano}
11
+ gem.summary = %q{RVM integration for Capistrano}
12
+ gem.homepage = "https://github.com/capistrano/rvm"
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
16
  gem.require_paths = ["lib"]
16
- gem.version = Capistrano::Rvm::VERSION
17
17
 
18
- gem.add_runtime_dependency "capistrano"
18
+ gem.add_dependency 'capistrano'
19
+
19
20
  end
@@ -1,2 +0,0 @@
1
- require "capistrano-rvm/capistrano_integration"
2
- require "capistrano-rvm/version"
@@ -0,0 +1 @@
1
+ load File.expand_path("../tasks/rvm.rake", __FILE__)
@@ -0,0 +1,78 @@
1
+ RVM_SYSTEM_PATH = "/usr/local/rvm"
2
+ RVM_USER_PATH = "~/.rvm"
3
+
4
+ def bundler_loaded?
5
+ Gem::Specification::find_all_by_name('capistrano-bundler').any?
6
+ end
7
+
8
+ SSHKit.config.command_map = Hash.new do |hash, key|
9
+ if fetch(:rvm_map_bins).include?(key.to_s)
10
+ hash[key] = "#{fetch(:rvm_bins_path)}/bin/#{fetch(:application)}_#{key}"
11
+ elsif key.to_s == "rvm"
12
+ hash[key] = "#{fetch(:rvm_path)}/bin/rvm"
13
+ else
14
+ hash[key] = key
15
+ end
16
+ end
17
+
18
+ namespace :deploy do
19
+ after :starting, 'rvm:hook'
20
+ end
21
+
22
+ namespace :rvm do
23
+ desc "Runs the RVM hook - use it before any custom tasks if necessary"
24
+ task :hook do
25
+ unless fetch(:rvm_hooked)
26
+ invoke :'rvm:init'
27
+ invoke :'rvm:create_wrappers'
28
+ set :rvm_hooked, true
29
+ end
30
+ end
31
+
32
+ desc "Prints the RVM and Ruby version on the target host"
33
+ task :check do
34
+ on roles(:all) do
35
+ puts capture(:rvm, "version")
36
+ puts capture(:rvm, "current")
37
+ puts capture(:ruby, "--version")
38
+ end
39
+ end
40
+ before :check, 'rvm:hook'
41
+
42
+ task :init do
43
+ on roles(:all) do
44
+ rvm_path = fetch(:rvm_custom_path)
45
+ rvm_path ||= case fetch(:rvm_type)
46
+ when :auto
47
+ if test("[ -d #{RVM_SYSTEM_PATH} ]")
48
+ RVM_SYSTEM_PATH
49
+ else
50
+ RVM_USER_PATH
51
+ end
52
+ when :system, :mixed
53
+ RVM_SYSTEM_PATH
54
+ else # :user
55
+ RVM_USER_PATH
56
+ end
57
+ set :rvm_path, rvm_path
58
+ set :rvm_bins_path, fetch(:rvm_type) == :mixed ? RVM_USER_PATH : rvm_path
59
+
60
+ rvm_ruby_version = fetch(:rvm_ruby_version)
61
+ rvm_ruby_version ||= capture(:rvm, "current")
62
+ set :rvm_ruby_version, rvm_ruby_version
63
+ end
64
+ end
65
+
66
+ task :create_wrappers do
67
+ on roles(:all) do
68
+ execute :rvm, "wrapper #{fetch(:rvm_ruby_version)} #{fetch(:application)} #{fetch(:rvm_map_bins).join(" ")}"
69
+ end
70
+ end
71
+ end
72
+
73
+ namespace :load do
74
+ task :defaults do
75
+ set :rvm_map_bins, bundler_loaded? ? %w{bundle gem rake ruby} : %w{gem rake ruby}
76
+ set :rvm_type, :auto
77
+ end
78
+ end
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-rvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - Edwin Cruz
8
+ - Kir Shatrov
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-10 00:00:00.000000000 Z
12
+ date: 2013-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
16
- requirement: &2172920960 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,24 +21,27 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2172920960
25
- description: Capistrano tasks to manage rvm commands
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: RVM integration for Capistrano
26
31
  email:
27
- - softr8@gmail.com
32
+ - shatrov@me.com
28
33
  executables: []
29
34
  extensions: []
30
35
  extra_rdoc_files: []
31
36
  files:
32
- - .gitignore
33
37
  - Gemfile
34
- - LICENSE
35
38
  - README.md
36
39
  - Rakefile
37
40
  - capistrano-rvm.gemspec
38
41
  - lib/capistrano-rvm.rb
39
- - lib/capistrano-rvm/capistrano_integration.rb
40
- - lib/capistrano-rvm/version.rb
41
- homepage: ''
42
+ - lib/capistrano/rvm.rb
43
+ - lib/capistrano/tasks/rvm.rake
44
+ homepage: https://github.com/capistrano/rvm
42
45
  licenses: []
43
46
  post_install_message:
44
47
  rdoc_options: []
@@ -58,8 +61,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
61
  version: '0'
59
62
  requirements: []
60
63
  rubyforge_project:
61
- rubygems_version: 1.8.10
64
+ rubygems_version: 1.8.23
62
65
  signing_key:
63
66
  specification_version: 3
64
- summary: Some tasks to install rvm, ruby and bundler without pain
67
+ summary: RVM integration for Capistrano
65
68
  test_files: []
69
+ has_rdoc:
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- .idea
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2012 Edwin Cruz
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,60 +0,0 @@
1
- require "capistrano"
2
- require "capistrano/version"
3
-
4
- module CapistranoResque
5
- class CapistranoIntegration
6
- def self.load_into(capistrano_config)
7
- capistrano_config.load do
8
-
9
- namespace :rvm do
10
-
11
- set :ruby_version, rvm_ruby_string.split('@').first
12
- set :gemset_name, rvm_ruby_string.split('@')[1] || application
13
- set :tmp_ruby_string, rvm_ruby_string
14
-
15
- desc "Installs rvm, ruby and bundler"
16
- task :default do
17
- install
18
- install_ruby
19
- install_bundler
20
- create_gemset
21
- end
22
-
23
- desc "Installs rvm"
24
- task :install, :except => {:no_release => true} do
25
- set :rvm_ruby_string, ''
26
- run "RVM=`rvm | grep 'RVM'` ; if [ -z \"$RVM\" ] ; then bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) ; fi", shell: 'bash -l'
27
- set :rvm_ruby_string, tmp_ruby_string
28
- end
29
-
30
- desc "installs ruby version specified in rvm_ruby_string"
31
- task :install_ruby, :except => {:no_release => true} do
32
- set :rvm_ruby_string, ''
33
- run "RUBY_INSTALLED=`rvm list | grep '#{ruby_version}'` ; if [ -z \"$RUBY_INSTALLED\" ]; then rvm install #{ruby_version} ; fi"
34
- set :rvm_ruby_string, tmp_ruby_string
35
- end
36
-
37
- desc "sets as default current ruby version"
38
- task :default_ruby, :except => {:no_release => true} do
39
- run "rvm --default #{ruby_version}"
40
- end
41
-
42
- desc "install bundler gem"
43
- task :install_bundler, :except => {:no_release => true} do
44
- run "if [ -z \"`gem list | grep bundler`\" ] ; then gem install bundler --no-rdoc --no-ri ; fi "
45
- end
46
-
47
- task :create_gemset, :except => {:no_release => true} do
48
- set :rvm_ruby_string, ruby_version
49
- run "rvm gemset create #{gemset_name}"
50
- set :rvm_ruby_string, tmp_ruby_string
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end
57
-
58
- if Capistrano::Configuration.instance
59
- CapistranoResque::CapistranoIntegration.load_into(Capistrano::Configuration.instance)
60
- end
@@ -1,5 +0,0 @@
1
- module Capistrano
2
- module Rvm
3
- VERSION = "0.0.1"
4
- end
5
- end