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

Introduced rake wrapper method. #39

Open
wants to merge 3 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
6 changes: 3 additions & 3 deletions lib/inploy/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lib/inploy/dsl.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Inploy
module DSL
include Helper
module ClassMethods
def define_callbacks(*callbacks)
callbacks.each do |callback|
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion lib/inploy/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions lib/inploy/templates/rails3_push.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion spec/deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spec/rails3_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down