aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler/capistrano.rb
diff options
context:
space:
mode:
authorChris Griego <cgriego@gmail.com>2010-08-12 19:04:49 -0500
committerAndre Arko <andre@arko.net>2010-08-13 10:37:45 -0700
commitff4376a3cec53c26888ccbdd75c3c82f298822ca (patch)
tree3773905d1c7572b73b2567c5bf4bdbf813fdcbef /lib/bundler/capistrano.rb
parentff57a02cb11baf57c4ecd671719fefcee77a535b (diff)
downloadbundler-ff4376a3cec53c26888ccbdd75c3c82f298822ca.tar.gz
Harden the capistrano task
* Add a task description compatible with capistrano's brief description support * Exclude the bundle:install task from running on servers that don't have a copy of the release * Make Gemfile configurable * Make bundle_dir allow nil * Make group exclusion configurable, allow nil * Make bundle install arguments configurable similar to deploy:migrate * Prefer the fetch method over dynamic methods to help avoid ambiguous conflicts
Diffstat (limited to 'lib/bundler/capistrano.rb')
-rw-r--r--lib/bundler/capistrano.rb34
1 files changed, 28 insertions, 6 deletions
diff --git a/lib/bundler/capistrano.rb b/lib/bundler/capistrano.rb
index 4fcb8339..b679c697 100644
--- a/lib/bundler/capistrano.rb
+++ b/lib/bundler/capistrano.rb
@@ -1,16 +1,38 @@
# Capistrano task for Bundler.
#
-# Just add "require 'bundler/capistrano'" in your Capistrano deploy.rb, and Bundler
-# will be activated after each new deployment. To configure the directory that
-# Bundler will install to, set :bundle_dir before deploy:update_code runs.
+# Just add "require 'bundler/capistrano'" in your Capistrano deploy.rb, and
+# Bundler will be activated after each new deployment.
Capistrano::Configuration.instance(:must_exist).load do
after "deploy:update_code", "bundle:install"
namespace :bundle do
- task :install do
- bundle_dir = fetch(:bundle_dir, "#{shared_path}/bundle")
- run "bundle install --gemfile #{release_path}/Gemfile --path #{bundle_dir} --deployment --without development test"
+ desc <<-DESC
+ Install the current Bundler environment. By default, gems will be \
+ installed to the shared/bundle path. However, you can specify a \
+ different directory via the bundle_dir variable. You can also specify \
+ the file name and path to the Gemfile using the bundle_gemfile \
+ variable. By default, gems in the development and test group will not \
+ be installed. If you want these gems to be installed or want \
+ additional named groups to be excluded, you can specify the \
+ bundle_without variable
+
+ set :bundle_gemfile, "Gemfile"
+ set :bundle_dir, "vendor/bundle"
+ set :bundle_without, [:development, :test]
+ DESC
+ task :install, :except => { :no_release => true } do
+ bundle_dir = fetch(:bundle_dir, "#{fetch(:shared_path)}/bundle")
+ bundle_without = [*fetch(:bundle_without, [:development, :test])].compact
+ bundle_install_env = fetch(:bundle_install_env, "--deployment")
+ bundle_gemfile = fetch(:bundle_gemfile, "Gemfile")
+ args = [
+ "--gemfile #{fetch(:latest_release)}/#{bundle_gemfile}",
+ ("--path #{bundle_dir}" unless bundle_dir.to_s.empty?),
+ "#{bundle_install_env}",
+ ("--without #{bundle_without.join(" ")}" unless bundle_without.empty?)
+ ].compact
+ run "bundle install #{args.join(' ')}"
end
end
end