diff --git a/lib/inploy/deploy.rb b/lib/inploy/deploy.rb index 8ea85eb..4763e7a 100644 --- a/lib/inploy/deploy.rb +++ b/lib/inploy/deploy.rb @@ -40,7 +40,7 @@ def remote_install(opts) end def remote_setup - remote_run "cd #{path} && #{sudo_if_should}git clone --depth 1 #{repository} #{application} && cd #{application_folder} #{checkout}#{bundle} && #{sudo_if_should}rake inploy:local:setup RAILS_ENV=#{environment} environment=#{environment}#{skip_steps_cmd}" + remote_run "cd #{path} && #{sudo_if_should}git clone --depth 1 #{repository} #{application} && cd #{application_folder} #{checkout}#{bundle} && #{sudo_if_should}#{rake_cmd} inploy:local:setup RAILS_ENV=#{environment} environment=#{environment}#{skip_steps_cmd}" end def local_setup @@ -54,11 +54,11 @@ def local_setup end def remote_update - remote_run "cd #{application_path} && #{sudo_if_should}rake inploy:local:update RAILS_ENV=#{environment} environment=#{environment}#{skip_steps_cmd}" + remote_run "cd #{application_path} && #{sudo_if_should}#{rake_cmd} inploy:local:update RAILS_ENV=#{environment} environment=#{environment}#{skip_steps_cmd}" end def remote_rake(task) - remote_run "cd #{application_path} && rake #{task} RAILS_ENV=#{environment}" + remote_run "cd #{application_path} && #{rake_cmd} #{task} RAILS_ENV=#{environment}" end def remote_reset(params) diff --git a/lib/inploy/dsl.rb b/lib/inploy/dsl.rb index 063e996..8d990e0 100644 --- a/lib/inploy/dsl.rb +++ b/lib/inploy/dsl.rb @@ -1,5 +1,6 @@ module Inploy module DSL + include Helper module ClassMethods def define_callbacks(*callbacks) callbacks.each do |callback| @@ -37,11 +38,11 @@ def log(command) end def rake(command) - run "rake #{command}" + run "#{rake_cmd} #{command}" end def rake_if_included(command) - rake command if tasks.include?("rake #{command.split[0]}") + rake command if tasks.include?("#{rake_cmd} #{command.split[0]}") end def ruby_if_exists(file, opts) diff --git a/lib/inploy/helper.rb b/lib/inploy/helper.rb index 43ac85f..b568305 100644 --- a/lib/inploy/helper.rb +++ b/lib/inploy/helper.rb @@ -55,12 +55,16 @@ def migrate_database end def tasks - `rake -T` + `#{rake_cmd} -T` end def bundle_cmd "bundle install #{bundler_opts || '--deployment --without development test cucumber'}" end + + def rake_cmd + using_bundler? ? "bundle exec rake" : "rake" + end def bundle_install run bundle_cmd unless skip_step?('bundle_install') diff --git a/lib/inploy/templates/rails3_push.rb b/lib/inploy/templates/rails3_push.rb index 6414dfe..b22d596 100644 --- a/lib/inploy/templates/rails3_push.rb +++ b/lib/inploy/templates/rails3_push.rb @@ -16,7 +16,7 @@ def remote_setup command = [] command << "cd #{application_path}" - command << "rake inploy:local:setup RAILS_ENV=#{environment} environment=#{environment}#{skip_steps_cmd}" + command << "#{rake_cmd} inploy:local:setup RAILS_ENV=#{environment} environment=#{environment}#{skip_steps_cmd}" remote_run command.join(' && ') end @@ -25,7 +25,7 @@ def remote_update command = [] command << "cd #{application_path}" - command << "rake inploy:local:update RAILS_ENV=#{environment} environment=#{environment}#{skip_steps_cmd}" + command << "#{rake_cmd} inploy:local:update RAILS_ENV=#{environment} environment=#{environment}#{skip_steps_cmd}" remote_run command.join(' && ') end diff --git a/spec/deploy_spec.rb b/spec/deploy_spec.rb index 0adcb31..8adcbd1 100644 --- a/spec/deploy_spec.rb +++ b/spec/deploy_spec.rb @@ -12,8 +12,9 @@ def expect_setup_with(branch, environment = 'production', skip_steps = nil, bund end skip_steps_cmd = " skip_steps=#{skip_steps.join(',')}" unless skip_steps.nil? bundler_cmd = " && bundle install #{bundler_opts}" if bundler + rake_cmd = bundler ? "bundle exec rake" : "rake" directory = app_folder.nil? ? @application : "#{@application}/#{app_folder}" - expect_command "ssh #{@ssh_opts} #{@user}@#{@host} 'cd #{@path} && git clone --depth 1 #{@repository} #{@application} && cd #{directory} #{checkout}#{bundler_cmd} && rake inploy:local:setup RAILS_ENV=#{environment} environment=#{environment}#{skip_steps_cmd}'" + expect_command "ssh #{@ssh_opts} #{@user}@#{@host} 'cd #{@path} && git clone --depth 1 #{@repository} #{@application} && cd #{directory} #{checkout}#{bundler_cmd} && #{rake_cmd} inploy:local:setup RAILS_ENV=#{environment} environment=#{environment}#{skip_steps_cmd}'" end def setup(subject) diff --git a/spec/rails3_spec.rb b/spec/rails3_spec.rb index 77cfd7c..ad7d7b8 100644 --- a/spec/rails3_spec.rb +++ b/spec/rails3_spec.rb @@ -10,7 +10,7 @@ def expect_setup_with(branch, environment = 'production') else checkout = "&& git checkout -f -b #{branch} origin/#{branch}" end - expect_command "ssh #{@ssh_opts} #{@user}@#{@host} 'cd #{@path} && git clone --depth 1 #{@repository} #{@application} && cd #{@application} #{checkout} && bundle install --deployment --without development test cucumber && rake inploy:local:setup RAILS_ENV=#{environment} environment=#{environment}'" + expect_command "ssh #{@ssh_opts} #{@user}@#{@host} 'cd #{@path} && git clone --depth 1 #{@repository} #{@application} && cd #{@application} #{checkout} && bundle install --deployment --without development test cucumber && bundle exec rake inploy:local:setup RAILS_ENV=#{environment} environment=#{environment}'" end context "with template rails3" do