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

Feature/require without hooks #85

Open
wants to merge 2 commits 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
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ To set the Ruby version explicitly, add `:rbenv_ruby` to your Capistrano configu

Alternatively, allow the remote host's `rbenv` to [determine the appropriate Ruby version](https://github.com/rbenv/rbenv#choosing-the-ruby-version) by omitting `:rbenv_ruby`. This approach is useful if you have a `.ruby-version` file in your project.

### Explicitely require hooks

Alternatively, if you want to have control on the execution of nvm tasks

```ruby
# Capfile
require capistrano/rbenv/without_hooks
```

You can then add the hooks on a per deploy script basis

```ruby
# config/deploy/my_stage_with_rbenv.rb
Capistrano::DSL.stages.each do |stage|
after stage, 'rbenv:validate'
after stage, 'rbenv:map_bins'
end
```

## Contributing

1. Fork it
Expand Down
4 changes: 4 additions & 0 deletions lib/capistrano/hooks/rbenv.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Capistrano::DSL.stages.each do |stage|
after stage, 'rbenv:validate'
after stage, 'rbenv:map_bins'
end
2 changes: 1 addition & 1 deletion lib/capistrano/rbenv.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
load File.expand_path("../tasks/rbenv.rake", __FILE__)
load File.expand_path('../tasks/deploy_rbenv.rake', __FILE__)
1 change: 1 addition & 0 deletions lib/capistrano/rbenv/without_hooks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
load File.expand_path('../../tasks/rbenv.rake', __FILE__)
2 changes: 2 additions & 0 deletions lib/capistrano/tasks/deploy_rbenv.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
load File.expand_path('../rbenv.rake', __FILE__)
load File.expand_path('../../hooks/rbenv.rb', __FILE__)
5 changes: 0 additions & 5 deletions lib/capistrano/tasks/rbenv.rake
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ namespace :rbenv do
end
end

Capistrano::DSL.stages.each do |stage|
after stage, 'rbenv:validate'
after stage, 'rbenv:map_bins'
end

namespace :load do
task :defaults do
set :rbenv_path, -> {
Expand Down