aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordbloete <mail@dennisbloete.de>2010-09-14 22:44:38 +0200
committerdbloete <mail@dennisbloete.de>2010-09-14 22:44:38 +0200
commitf37ca576f49a2724761b57c89e65881d3438c706 (patch)
tree0214394e6b207949b005ff0750fa111280f35c16 /lib
parent236dc92e78c5e34343883376d1bdc15bce099311 (diff)
downloadbundler-f37ca576f49a2724761b57c89e65881d3438c706.tar.gz
Further refactoring of the deployment recipes
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/capistrano.rb23
-rw-r--r--lib/bundler/deployment.rb45
-rw-r--r--lib/bundler/vlad.rb21
3 files changed, 35 insertions, 54 deletions
diff --git a/lib/bundler/capistrano.rb b/lib/bundler/capistrano.rb
index a58716d9..18ea78d9 100644
--- a/lib/bundler/capistrano.rb
+++ b/lib/bundler/capistrano.rb
@@ -6,25 +6,6 @@ require 'bundler/deployment'
Capistrano::Configuration.instance(:must_exist).load do
after "deploy:update_code", "bundle:install"
-
- namespace :bundle do
- desc <<-DESC
- Install the current Bundler environment. By default, gems will be \
- installed to the shared/bundle path. Gems in the development and \
- test group will not be installed. The install command is executed \
- with the --deployment and --quiet flags. You can override any of \
- these defaults by setting the variables shown below. If capistrano \
- can not find the 'bundle' cmd then you can override the bundle_cmd \
- variable to specifiy which one it should use.
-
- set :bundle_gemfile, "Gemfile"
- set :bundle_dir, File.join(fetch(:shared_path), 'bundle')
- set :bundle_flags, "--deployment --quiet"
- set :bundle_without, [:development, :test]
- set :bundle_cmd, "bundle" # e.g. change to "/opt/ruby/bin/bundle"
- DESC
- task :install, :except => { :no_release => true } do
- Bundler::Deployment.install_bundle(self)
- end
- end
+
+ Bundler::Deployment.define_task(self, :task, :except => { :no_release => true })
end
diff --git a/lib/bundler/deployment.rb b/lib/bundler/deployment.rb
index 6896a322..5ccbdc66 100644
--- a/lib/bundler/deployment.rb
+++ b/lib/bundler/deployment.rb
@@ -1,18 +1,37 @@
module Bundler
class Deployment
- def self.install_bundle(context)
- bundle_cmd = context.fetch(:bundle_cmd, "bundle")
- bundle_flags = context.fetch(:bundle_flags, "--deployment --quiet")
- bundle_dir = context.fetch(:bundle_dir, File.join(context.fetch(:shared_path), 'bundle'))
- bundle_gemfile = context.fetch(:bundle_gemfile, "Gemfile")
- bundle_without = [*context.fetch(:bundle_without, [:development, :test])].compact
-
- args = ["--gemfile #{File.join(context.fetch(:current_release), bundle_gemfile)}"]
- args << "--path #{bundle_dir}" unless bundle_dir.to_s.empty?
- args << bundle_flags.to_s
- args << "--without #{bundle_without.join(" ")}" unless bundle_without.empty?
-
- context.run "#{bundle_cmd} install #{args.join(' ')}"
+ def self.define_task(context, task_method = :task, opts = {})
+ context.send :namespace, :bundle do
+ send :desc, <<-DESC
+ Install the current Bundler environment. By default, gems will be \
+ installed to the shared/bundle path. Gems in the development and \
+ test group will not be installed. The install command is executed \
+ with the --deployment and --quiet flags. You can override any of \
+ these defaults by setting the variables shown below. If the bundle \
+ cmd cannot be found then you can override the bundle_cmd variable \
+ to specifiy which one it should use.
+
+ set :bundle_gemfile, "Gemfile"
+ set :bundle_dir, File.join(fetch(:shared_path), 'bundle')
+ set :bundle_flags, "--deployment --quiet"
+ set :bundle_without, [:development, :test]
+ set :bundle_cmd, "bundle" # e.g. change to "/opt/ruby/bin/bundle"
+ DESC
+ send task_method, :install, opts do
+ bundle_cmd = context.fetch(:bundle_cmd, "bundle")
+ bundle_flags = context.fetch(:bundle_flags, "--deployment --quiet")
+ bundle_dir = context.fetch(:bundle_dir, File.join(context.fetch(:shared_path), 'bundle'))
+ bundle_gemfile = context.fetch(:bundle_gemfile, "Gemfile")
+ bundle_without = [*context.fetch(:bundle_without, [:development, :test])].compact
+
+ args = ["--gemfile #{File.join(context.fetch(:current_release), bundle_gemfile)}"]
+ args << "--path #{bundle_dir}" unless bundle_dir.to_s.empty?
+ args << bundle_flags.to_s
+ args << "--without #{bundle_without.join(" ")}" unless bundle_without.empty?
+
+ run "#{bundle_cmd} install #{args.join(' ')}"
+ end
+ end
end
end
end \ No newline at end of file
diff --git a/lib/bundler/vlad.rb b/lib/bundler/vlad.rb
index 40e941e0..36669acd 100644
--- a/lib/bundler/vlad.rb
+++ b/lib/bundler/vlad.rb
@@ -5,24 +5,5 @@
require 'bundler/deployment'
namespace :vlad do
- namespace :bundle do
- desc <<-DESC
- Install the current Bundler environment. By default, gems will be \
- installed to the shared/bundle path. Gems in the development and \
- test group will not be installed. The install command is executed \
- with the --deployment and --quiet flags. You can override any of \
- these defaults by setting the variables shown below. If Vlad \
- can not find the 'bundle' cmd then you can override the bundle_cmd \
- variable to specifiy which one it should use.
-
- set :bundle_gemfile, "Gemfile"
- set :bundle_dir, File.join(fetch(:shared_path), 'bundle')
- set :bundle_flags, "--deployment --quiet"
- set :bundle_without, [:development, :test]
- set :bundle_cmd, "bundle" # e.g. change to "/opt/ruby/bin/bundle"
- DESC
- remote_task :install, :roles => :app do
- Bundler::Deployment.install_bundle(Rake::RemoteTask)
- end
- end
+ Bundler::Deployment.define_task(Rake::RemoteTask, :remote_task, :roles => :app)
end \ No newline at end of file