Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
dcrec1 committed Aug 16, 2010
1 parent e81fa47 commit 698af14
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 27 deletions.
16 changes: 9 additions & 7 deletions lib/inploy/deploy.rb
Expand Up @@ -38,13 +38,7 @@ def remote_install(opts)
end

def remote_setup
if branch.eql? "master"
checkout = ""
else
checkout = "&& $(git branch | grep -vq #{branch}) && git checkout -f -b #{branch} origin/#{branch}"
end
bundle_cmd = " && bundle install ~/.bundle" if file_exists?("Gemfile")
remote_run "cd #{path} && #{@sudo}git clone --depth 1 #{repository} #{application} && cd #{application} #{checkout}#{bundle_cmd} && #{@sudo}rake inploy:local:setup environment=#{environment}#{skip_steps_cmd}"
remote_run "cd #{path} && #{@sudo}git clone --depth 1 #{repository} #{application} && cd #{application} #{checkout}#{bundle} && #{@sudo}rake inploy:local:setup environment=#{environment}#{skip_steps_cmd}"
end

def local_setup
Expand Down Expand Up @@ -78,6 +72,14 @@ def update_code

private

def checkout
branch.eql?("master") ? "" : "&& $(git branch | grep -vq #{branch}) && git checkout -f -b #{branch} origin/#{branch}"
end

def bundle
" && #{bundle_cmd}" if using_bundler?
end

def after_update_code
run "git submodule update --init"
copy_sample_files
Expand Down
4 changes: 4 additions & 0 deletions lib/inploy/dsl.rb
Expand Up @@ -33,6 +33,10 @@ def sudo_if_should
@sudo ? 'sudo ' : ''
end

def using_bundler?
file_exists?("Gemfile")
end

def run(command, disable_sudo = false)
log command

Expand Down
12 changes: 10 additions & 2 deletions lib/inploy/helper.rb
Expand Up @@ -52,9 +52,17 @@ def tasks
`rake -T`
end

def bundle_cmd
"bundle install ~/.bundle"
end

def bundle_install
run bundle_cmd
end

def install_gems
if file_exists?("Gemfile")
run "bundle install ~/.bundle"
if using_bundler?
bundle_install
else
rake "gems:install RAILS_ENV=#{environment}" unless skip_step?('install_gems')
end
Expand Down
19 changes: 2 additions & 17 deletions lib/inploy/templates/rails3.rb
@@ -1,23 +1,8 @@
module Inploy
module Templates
module Rails3
def remote_setup
if branch.eql? "master"
checkout = ""
else
checkout = "&& $(git branch | grep -vq #{branch}) && git checkout -f -b #{branch} origin/#{branch}"
end
remote_run "cd #{path} && #{@sudo}git clone --depth 1 #{repository} #{application} && cd #{application} #{checkout} && bundle install ~/.bundle && #{@sudo}rake inploy:local:setup environment=#{environment}"
end

def install_gems
run bundle
end

private

def bundle
"bundle install ~/.bundle"
def using_bundler?
true
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rails3_spec.rb
Expand Up @@ -35,7 +35,7 @@ def expect_setup_with(branch, environment = 'production')

context "on local update" do
it "should not restart server if bundle fails" do
expect_command(subject.send(:bundle)).and_return(false)
expect_command("bundle install ~/.bundle").and_return(false)
dont_accept_command "touch tmp/restart.txt"
subject.local_update
end
Expand Down

0 comments on commit 698af14

Please sign in to comment.