Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add optional manual task-level management of rvm integration #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,30 @@ And then execute:

## Usage

Require in Capfile to use the default task:
Require in Capfile to always use `rvm:hook` task:

# Capfile
require 'capistrano/rvm'

And you should be good to go!
And you should be good to go! All tasks will be rvm-aware.

Or, If you prefer to manually manage RVM integration at the task level:

# Capfile
require 'capistrano/rvm/no_hook'

With this approach, you must explicitly set `rvm:hook` as a prequisite for tasks
requiring RVM support:

before TASKNAME, 'rvm:hook'

You may aletnatively use the convenience method `with_rvm`:

with_rvm TASKNAME

Multiple tasks may be supported in one line:

with_rvm TASKNAME1, TASKNAME2, TASKNAME3

## Configuration

Expand Down Expand Up @@ -86,10 +104,18 @@ proper ruby and create the gemset.

## How it works

This gem adds a new task `rvm:hook` before `deploy` task.
It sets the `rvm ... do ...` for capistrano when it wants to run
`rake`, `gem`, `bundle`, or `ruby`.
With the default configuration, this gem adds a new tasks `rvm:hook` and
`rvm:check` after each stage-setting task (ex. 'staging', 'production', etc.).

`rvm:hook` sets the `rvm ... do ...` for capistrano when it wants to run `rake`,
`gem`, `bundle`, or `ruby`.

`rvm:check` outputs the current version info for rvm plus the active rvm and
gemset. It only runs when :log_level is set to :debug (including when the
`--trace` argument is passed to `cap`.)

When the `no_hook` configuration is used, `rvm:hook` must be manually set as a
prerequisite for tasks requiring RVM support (with the exception of `rvm:check`.)

## Check your configuration

Expand Down
6 changes: 6 additions & 0 deletions lib/capistrano/rvm.rb
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
load File.expand_path("../tasks/rvm.rake", __FILE__)

# all stage-based tasks are supported by default
Capistrano::DSL.stages.each do |stage|
after stage, 'rvm:hook'
after stage, 'rvm:check'
end
4 changes: 4 additions & 0 deletions lib/capistrano/rvm/no_hook.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
load File.expand_path("../../tasks/rvm.rake", __FILE__)

# ONLY rvm:check is rvm supported by default
with_rvm 'rvm:check'
7 changes: 4 additions & 3 deletions lib/capistrano/tasks/rvm.rake
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ namespace :rvm do
end
end

Capistrano::DSL.stages.each do |stage|
after stage, 'rvm:hook'
after stage, 'rvm:check'
def with_rvm(*tasks)
tasks.each do |t|
before t, 'rvm:hook'
end
end

namespace :load do
Expand Down