diff options
author | dbloete <mail@dennisbloete.de> | 2010-09-14 22:44:38 +0200 |
---|---|---|
committer | dbloete <mail@dennisbloete.de> | 2010-09-14 22:44:38 +0200 |
commit | f37ca576f49a2724761b57c89e65881d3438c706 (patch) | |
tree | 0214394e6b207949b005ff0750fa111280f35c16 /lib/bundler/deployment.rb | |
parent | 236dc92e78c5e34343883376d1bdc15bce099311 (diff) | |
download | bundler-f37ca576f49a2724761b57c89e65881d3438c706.tar.gz |
Further refactoring of the deployment recipes
Diffstat (limited to 'lib/bundler/deployment.rb')
-rw-r--r-- | lib/bundler/deployment.rb | 45 |
1 files changed, 32 insertions, 13 deletions
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 |