Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added option app_folder.

  • Loading branch information...
commit 689af166a57a2f253530a51f2d862fd781f9c733 1 parent 1ad4160
@jtadeulopes jtadeulopes authored committed
Showing with 21 additions and 4 deletions.
  1. +1 −0  deploy.rb.sample
  2. +7 −2 lib/inploy/deploy.rb
  3. +13 −2 spec/deploy_spec.rb
View
1  deploy.rb.sample
@@ -11,3 +11,4 @@ hosts = ['hooters', 'geni']
#sudo = false
#cache_dirs = %w(public/cache)
#skip_steps = nil
+#app_folder = nil
View
9 lib/inploy/deploy.rb
@@ -3,7 +3,7 @@ class Deploy
include Helper
include DSL
- attr_accessor :repository, :user, :application, :hosts, :path, :ssh_opts, :branch, :environment,
+ attr_accessor :repository, :user, :application, :hosts, :path, :app_folder, :ssh_opts, :branch, :environment,
:port, :skip_steps, :cache_dirs, :sudo
define_callbacks :after_setup, :before_restarting_server
@@ -15,6 +15,7 @@ def initialize
@environment = 'production'
@user = "deploy"
@path = "/var/local/apps"
+ @app_folder = nil
configure
end
@@ -40,7 +41,7 @@ def remote_install(opts)
end
def remote_setup
- 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}"
+ remote_run "cd #{path} && #{@sudo}git clone --depth 1 #{repository} #{application} && cd #{directory} #{checkout}#{bundle} && #{@sudo}rake inploy:local:setup environment=#{environment}#{skip_steps_cmd}"
end
def local_setup
@@ -71,6 +72,10 @@ def update_code
private
+ def directory
+ app_folder.nil? ? application : "#{application}/#{app_folder}"
+ end
+
def checkout
branch.eql?("master") ? "" : "&& $(git branch | grep -vq #{branch}) && git checkout -f -b #{branch} origin/#{branch}"
end
View
15 spec/deploy_spec.rb
@@ -4,7 +4,7 @@
subject { Inploy::Deploy.new }
- def expect_setup_with(branch, environment = 'production', skip_steps = nil, bundler = false)
+ def expect_setup_with(branch, environment = 'production', skip_steps = nil, bundler = false, app_folder = nil)
if branch.eql? 'master'
checkout = ""
else
@@ -12,7 +12,8 @@ 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 ~/.bundle --without development test" if bundler
- expect_command "ssh #{@ssh_opts} #{@user}@#{@host} 'cd #{@path} && git clone --depth 1 #{@repository} #{@application} && cd #{@application} #{checkout}#{bundler_cmd} && rake inploy:local:setup environment=#{environment}#{skip_steps_cmd}'"
+ 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 environment=#{environment}#{skip_steps_cmd}'"
end
def setup(subject)
@@ -76,6 +77,10 @@ def setup(subject)
subject.path.should eql("/var/local/apps")
end
+ it "should use nil as the default app_path" do
+ subject.app_folder.should be_nil
+ end
+
context "configured" do
before :each do
setup subject
@@ -100,6 +105,12 @@ def setup(subject)
expect_setup_with @branch, @environment, subject.skip_steps
subject.remote_setup
end
+
+ it "should pass app_folder params to local setup" do
+ subject.app_folder = "project"
+ expect_setup_with @branch, @environment, nil, false, subject.app_folder
+ subject.remote_setup
+ end
it "should execute bundle install before local setup if Gemfile exists" do
file_exists "Gemfile"
Please sign in to comment.
Something went wrong with that request. Please try again.