pulsar 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/pulsar/commands/list.rb +7 -5
- data/lib/pulsar/commands/main.rb +27 -16
- data/lib/pulsar/helpers/clamp.rb +4 -0
- data/lib/pulsar/version.rb +1 -1
- data/spec/pulsar/commands/list_spec.rb +7 -0
- data/spec/pulsar/commands/main_spec.rb +13 -0
- data/spec/pulsar/helpers/clamp_spec.rb +12 -0
- data/spec/support/dummies/dummy_conf/apps/other_dummy_app/defaults.rb +7 -0
- data/spec/support/dummies/dummy_conf/apps/other_dummy_app/production.rb +5 -0
- data/spec/support/dummies/dummy_conf/apps/other_dummy_app/staging.rb +5 -0
- data/spec/support/modules/helpers.rb +5 -1
- metadata +10 -4
data/lib/pulsar/commands/list.rb
CHANGED
@@ -4,12 +4,14 @@ module Pulsar
|
|
4
4
|
|
5
5
|
def execute
|
6
6
|
Bundler.with_clean_env do
|
7
|
-
|
8
|
-
|
9
|
-
list_apps
|
7
|
+
begin
|
8
|
+
fetch_repo
|
10
9
|
|
11
|
-
|
12
|
-
|
10
|
+
list_apps
|
11
|
+
ensure
|
12
|
+
remove_capfile unless keep_capfile?
|
13
|
+
remove_repo unless keep_repo?
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
data/lib/pulsar/commands/main.rb
CHANGED
@@ -12,29 +12,40 @@ module Pulsar
|
|
12
12
|
"do everything pulsar does (build a Capfile) but don't run the cap command",
|
13
13
|
:default => false
|
14
14
|
|
15
|
-
|
15
|
+
unless File.exists?("#{Dir.pwd}/config.ru")
|
16
|
+
parameter "APPLICATION", "the application which you would like to deploy. Pass a comma separated list to deploy multiple applications at once"
|
17
|
+
end
|
18
|
+
|
16
19
|
parameter "ENVIRONMENT", "the environment on which you would like to deploy" do |env|
|
17
20
|
%w(production staging development).include?(env) ? env : raise(ArgumentError)
|
18
21
|
end
|
22
|
+
|
19
23
|
parameter "[TASKS] ...", "the arguments and/or options that will be passed to capistrano", :default => "deploy"
|
20
24
|
|
21
25
|
def execute
|
22
|
-
|
23
|
-
target = "#{app}:#{environment}"
|
24
|
-
|
25
|
-
Bundler.with_clean_env do
|
26
|
-
fetch_repo
|
27
|
-
bundle_install
|
28
|
-
create_capfile
|
29
|
-
build_capfile(target)
|
30
|
-
|
31
|
-
unless skip_cap_run?
|
32
|
-
cap_args = [tasks_list].flatten.join(" ")
|
33
|
-
run_capistrano(cap_args)
|
34
|
-
end
|
26
|
+
apps = application.split(',') rescue [ File.basename(Dir.pwd) ]
|
35
27
|
|
36
|
-
|
37
|
-
|
28
|
+
apps.each do |app|
|
29
|
+
target = "#{app}:#{environment}"
|
30
|
+
|
31
|
+
Bundler.with_clean_env do
|
32
|
+
begin
|
33
|
+
fetch_repo
|
34
|
+
bundle_install
|
35
|
+
create_capfile
|
36
|
+
build_capfile(target)
|
37
|
+
|
38
|
+
unless skip_cap_run?
|
39
|
+
cap_args = [tasks_list].flatten.join(" ")
|
40
|
+
run_capistrano(cap_args)
|
41
|
+
end
|
42
|
+
ensure
|
43
|
+
remove_capfile unless keep_capfile?
|
44
|
+
remove_repo unless keep_repo?
|
45
|
+
|
46
|
+
reset_for_other_app!
|
47
|
+
end
|
48
|
+
end
|
38
49
|
end
|
39
50
|
end
|
40
51
|
end
|
data/lib/pulsar/helpers/clamp.rb
CHANGED
@@ -120,6 +120,10 @@ module Pulsar
|
|
120
120
|
rm_rf(config_path, :verbose => verbose?)
|
121
121
|
end
|
122
122
|
|
123
|
+
def reset_for_other_app!
|
124
|
+
@capfile_name = @configuration_path = @now = nil
|
125
|
+
end
|
126
|
+
|
123
127
|
def run_capistrano(args)
|
124
128
|
cd(config_path, :verbose => verbose?) do
|
125
129
|
run_cmd("bundle exec cap CONFIG_PATH=#{config_path} --file #{capfile_path} #{args}", :verbose => verbose?)
|
data/lib/pulsar/version.rb
CHANGED
@@ -12,6 +12,13 @@ describe Pulsar::ListCommand do
|
|
12
12
|
expect { pulsar.run(full_list_args + %w(--keep-repo)) }.to change{ Dir.glob("#{tmp_path}/conf-repo*").length }.by(1)
|
13
13
|
end
|
14
14
|
|
15
|
+
it "removes the temp directory even if it's raised an error" do
|
16
|
+
Pulsar::ListCommand.any_instance.stub(:list_apps) { raise 'error' }
|
17
|
+
pulsar.run(full_list_args) rescue nil
|
18
|
+
|
19
|
+
Dir.glob("#{tmp_path}/conf-repo*").should be_empty
|
20
|
+
end
|
21
|
+
|
15
22
|
context "--conf-repo option" do
|
16
23
|
it "is required" do
|
17
24
|
expect { pulsar.parse([]) }.to raise_error(Clamp::UsageError)
|
@@ -13,6 +13,13 @@ describe Pulsar::MainCommand do
|
|
13
13
|
expect { pulsar.run(full_cap_args + %w(--keep-repo) + dummy_app) }.to change{ Dir.glob("#{tmp_path}/conf-repo*").length }.by(1)
|
14
14
|
end
|
15
15
|
|
16
|
+
it "removes the temp directory even if it's raised an error" do
|
17
|
+
Pulsar::MainCommand.any_instance.stub(:run_capistrano) { raise 'error' }
|
18
|
+
pulsar.run(base_args + [ "--tmp-dir", tmp_path, "--keep-capfile" ] + dummy_app) rescue nil
|
19
|
+
|
20
|
+
Dir.glob("#{tmp_path}/conf-repo*").should be_empty
|
21
|
+
end
|
22
|
+
|
16
23
|
it "copies a the repo when there is a dir with same name" do
|
17
24
|
system("mkdir #{tmp_path}/conf-repo")
|
18
25
|
expect { pulsar.run(full_cap_args + %w(--keep-repo) + dummy_app) }.to change{ Dir.glob("#{tmp_path}/conf-repo*").length }.by(1)
|
@@ -26,6 +33,12 @@ describe Pulsar::MainCommand do
|
|
26
33
|
end
|
27
34
|
end
|
28
35
|
|
36
|
+
it "supports multiple apps via comma separated argument" do
|
37
|
+
apps_to_deploy = [ 'dummy_app,other_dummy_app', 'production' ]
|
38
|
+
|
39
|
+
expect { pulsar.run(full_cap_args + apps_to_deploy) }.to change{ Dir.glob("#{tmp_path}/capfile-*").length }.by(2)
|
40
|
+
end
|
41
|
+
|
29
42
|
context "Capfile" do
|
30
43
|
it "uses base.rb in staging stage" do
|
31
44
|
pulsar.run(full_cap_args + dummy_app(:staging))
|
@@ -8,4 +8,16 @@ describe Pulsar::Helpers::Clamp do
|
|
8
8
|
expect { run_cmd("return 1", {}) }.to raise_error
|
9
9
|
end
|
10
10
|
end
|
11
|
+
|
12
|
+
context "reset_for_other_app!" do
|
13
|
+
it "resets instance variables written by the module" do
|
14
|
+
cap, conf, time = capfile_path, config_path, time_to_deploy
|
15
|
+
|
16
|
+
reset_for_other_app!
|
17
|
+
|
18
|
+
capfile_path.should_not == cap
|
19
|
+
config_path.should_not == conf
|
20
|
+
time_to_deploy.should_not == time
|
21
|
+
end
|
22
|
+
end
|
11
23
|
end
|
@@ -19,8 +19,12 @@ module Helpers
|
|
19
19
|
File.join(File.dirname(__FILE__), "..", "dummies", "dummy_app")
|
20
20
|
end
|
21
21
|
|
22
|
+
def tmp_dir
|
23
|
+
"tmp"
|
24
|
+
end
|
25
|
+
|
22
26
|
def tmp_path
|
23
|
-
File.join(File.dirname(__FILE__), "..",
|
27
|
+
File.join(File.dirname(__FILE__), "..", tmp_dir)
|
24
28
|
end
|
25
29
|
|
26
30
|
def dummy_app(stage = :production)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pulsar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: clamp
|
@@ -184,6 +184,9 @@ files:
|
|
184
184
|
- spec/support/dummies/dummy_conf/apps/dummy_app/recipes/production/custom_recipe.rb
|
185
185
|
- spec/support/dummies/dummy_conf/apps/dummy_app/recipes/staging/custom_recipe.rb
|
186
186
|
- spec/support/dummies/dummy_conf/apps/dummy_app/staging.rb
|
187
|
+
- spec/support/dummies/dummy_conf/apps/other_dummy_app/defaults.rb
|
188
|
+
- spec/support/dummies/dummy_conf/apps/other_dummy_app/production.rb
|
189
|
+
- spec/support/dummies/dummy_conf/apps/other_dummy_app/staging.rb
|
187
190
|
- spec/support/dummies/dummy_conf/recipes/generic/recipe.rb
|
188
191
|
- spec/support/modules/helpers.rb
|
189
192
|
- spec/support/modules/output_capture.rb
|
@@ -202,7 +205,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
202
205
|
version: '0'
|
203
206
|
segments:
|
204
207
|
- 0
|
205
|
-
hash:
|
208
|
+
hash: 3212148214793715680
|
206
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
210
|
none: false
|
208
211
|
requirements:
|
@@ -211,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
214
|
version: '0'
|
212
215
|
segments:
|
213
216
|
- 0
|
214
|
-
hash:
|
217
|
+
hash: 3212148214793715680
|
215
218
|
requirements: []
|
216
219
|
rubyforge_project:
|
217
220
|
rubygems_version: 1.8.24
|
@@ -236,6 +239,9 @@ test_files:
|
|
236
239
|
- spec/support/dummies/dummy_conf/apps/dummy_app/recipes/production/custom_recipe.rb
|
237
240
|
- spec/support/dummies/dummy_conf/apps/dummy_app/recipes/staging/custom_recipe.rb
|
238
241
|
- spec/support/dummies/dummy_conf/apps/dummy_app/staging.rb
|
242
|
+
- spec/support/dummies/dummy_conf/apps/other_dummy_app/defaults.rb
|
243
|
+
- spec/support/dummies/dummy_conf/apps/other_dummy_app/production.rb
|
244
|
+
- spec/support/dummies/dummy_conf/apps/other_dummy_app/staging.rb
|
239
245
|
- spec/support/dummies/dummy_conf/recipes/generic/recipe.rb
|
240
246
|
- spec/support/modules/helpers.rb
|
241
247
|
- spec/support/modules/output_capture.rb
|