pulsar 0.1.1 → 0.2.0
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/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +1 -0
- data/lib/pulsar/commands/list.rb +1 -1
- data/lib/pulsar/commands/main.rb +21 -9
- data/lib/pulsar/helpers/capistrano.rb +13 -6
- data/lib/pulsar/helpers/clamp.rb +145 -107
- data/lib/pulsar/options/conf_repo.rb +12 -0
- data/lib/pulsar/version.rb +1 -1
- data/pulsar.gemspec +1 -1
- data/spec/pulsar/commands/list_spec.rb +28 -0
- data/spec/pulsar/commands/main_spec.rb +46 -0
- data/spec/pulsar/helpers/capistrano_spec.rb +44 -0
- data/spec/pulsar/helpers/clamp_spec.rb +22 -0
- data/spec/spec_helper.rb +4 -1
- metadata +10 -7
- data/.rvmrc +0 -51
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pulsar
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3
|
data/.travis.yml
CHANGED
data/lib/pulsar/commands/list.rb
CHANGED
data/lib/pulsar/commands/main.rb
CHANGED
@@ -12,7 +12,7 @@ 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
|
+
if !from_application_path?
|
16
16
|
parameter "APPLICATION", "the application which you would like to deploy. Pass a comma separated list to deploy multiple applications at once"
|
17
17
|
end
|
18
18
|
|
@@ -23,9 +23,7 @@ module Pulsar
|
|
23
23
|
parameter "[TASKS] ...", "the arguments and/or options that will be passed to capistrano", :default => "deploy"
|
24
24
|
|
25
25
|
def execute
|
26
|
-
|
27
|
-
|
28
|
-
apps.each do |app|
|
26
|
+
find_apps.each do |app|
|
29
27
|
target = "#{app}:#{environment}"
|
30
28
|
|
31
29
|
Bundler.with_clean_env do
|
@@ -36,17 +34,31 @@ module Pulsar
|
|
36
34
|
build_capfile(target)
|
37
35
|
|
38
36
|
unless skip_cap_run?
|
39
|
-
cap_args = [tasks_list].flatten.join(" ")
|
37
|
+
cap_args = [ tasks_list ].flatten.join(" ")
|
40
38
|
run_capistrano(cap_args)
|
41
39
|
end
|
42
40
|
ensure
|
43
|
-
|
44
|
-
remove_repo unless keep_repo?
|
45
|
-
|
46
|
-
reset_for_other_app!
|
41
|
+
cleanup!
|
47
42
|
end
|
48
43
|
end
|
49
44
|
end
|
50
45
|
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def find_apps
|
50
|
+
if from_application_path?
|
51
|
+
[ ENV['PULSAR_APP_NAME'] || File.basename(application_path) ]
|
52
|
+
else
|
53
|
+
application.split(',')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def cleanup!
|
58
|
+
remove_capfile unless keep_capfile?
|
59
|
+
remove_repo unless keep_repo?
|
60
|
+
|
61
|
+
reset_for_other_app!
|
62
|
+
end
|
51
63
|
end
|
52
64
|
end
|
@@ -12,12 +12,15 @@ module Pulsar
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def method_missing(meth, *args, &block)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
recipes = "#{ENV['CONFIG_PATH']}/recipes/#{meth}"
|
16
|
+
|
17
|
+
File.directory?(recipes) || raise("There are no recipes of type #{meth}")
|
18
|
+
|
19
|
+
args.each do |arg|
|
20
|
+
recipe = "#{recipes}/#{arg}.rb"
|
21
|
+
File.exists?(recipe) || raise("There is no #{arg} recipe")
|
22
|
+
|
23
|
+
@cap_conf.send(:load, recipe)
|
21
24
|
end
|
22
25
|
end
|
23
26
|
end
|
@@ -25,6 +28,10 @@ module Pulsar
|
|
25
28
|
def load_recipes(&block)
|
26
29
|
DSL.new(self, &block)
|
27
30
|
end
|
31
|
+
|
32
|
+
def from_application_path?
|
33
|
+
ENV.has_key?('APP_PATH')
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
30
37
|
end
|
data/lib/pulsar/helpers/clamp.rb
CHANGED
@@ -4,162 +4,200 @@ module Pulsar
|
|
4
4
|
module Helpers
|
5
5
|
module Clamp
|
6
6
|
include FileUtils
|
7
|
-
|
8
|
-
def build_capfile(args)
|
9
|
-
app, stage = args.split(":")
|
10
7
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
include_app(app, stage) if app
|
15
|
-
|
16
|
-
# Recipes
|
17
|
-
include_app_recipes(app, stage) if app
|
8
|
+
def self.included(base)
|
9
|
+
base.extend(InstanceAndClassMethods)
|
10
|
+
include InstanceMethods
|
18
11
|
end
|
19
12
|
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
module InstanceAndClassMethods
|
14
|
+
def from_application_path?
|
15
|
+
File.exists?("#{Dir.pwd}/config.ru")
|
23
16
|
end
|
24
17
|
end
|
25
18
|
|
26
|
-
|
27
|
-
|
28
|
-
end
|
19
|
+
module InstanceMethods
|
20
|
+
include InstanceAndClassMethods
|
29
21
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
22
|
+
def application_path
|
23
|
+
Dir.pwd if from_application_path?
|
24
|
+
end
|
25
|
+
|
26
|
+
def build_capfile(args)
|
27
|
+
app, stage = args.split(":")
|
34
28
|
|
35
|
-
|
36
|
-
|
37
|
-
|
29
|
+
# Variables
|
30
|
+
set_log_level
|
31
|
+
include_base_conf
|
32
|
+
include_app(app, stage) if app
|
38
33
|
|
39
|
-
|
40
|
-
|
41
|
-
|
34
|
+
# Recipes
|
35
|
+
include_app_recipes(app, stage) if app
|
36
|
+
end
|
42
37
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
fetch_directory_repo(conf_repo)
|
38
|
+
def bundle_install
|
39
|
+
cd(config_path, :verbose => verbose?) do
|
40
|
+
run_cmd("bundle install --quiet", :verbose => verbose?)
|
41
|
+
end
|
48
42
|
end
|
49
|
-
end
|
50
43
|
|
51
|
-
|
52
|
-
|
53
|
-
fetch_git_repo(repo)
|
54
|
-
else
|
55
|
-
run_cmd("cp -rp #{repo} #{config_path}", :verbose => verbose?)
|
44
|
+
def capfile_path
|
45
|
+
@capfile_name ||= "#{tmp_dir}/capfile-#{time_to_deploy}"
|
56
46
|
end
|
57
|
-
end
|
58
47
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
48
|
+
def cd(path, opts, &block)
|
49
|
+
puts "Directory: #{path.white}".yellow if opts[:verbose]
|
50
|
+
FileUtils.cd(path) { yield }
|
51
|
+
end
|
52
|
+
|
53
|
+
def config_path
|
54
|
+
@configuration_path ||= "#{tmp_dir}/conf-repo-#{time_to_deploy}"
|
55
|
+
end
|
63
56
|
|
64
|
-
|
65
|
-
|
66
|
-
|
57
|
+
def create_capfile
|
58
|
+
touch(capfile_path, :verbose => verbose?)
|
59
|
+
end
|
67
60
|
|
68
|
-
|
69
|
-
|
61
|
+
def fetch_repo
|
62
|
+
if conf_repo =~ /\A[a-zA-Z-]+\/[a-zA-Z-]+\Z/
|
63
|
+
fetch_git_repo("git@github.com:#{conf_repo}.git")
|
64
|
+
else
|
65
|
+
fetch_directory_repo(conf_repo)
|
66
|
+
end
|
70
67
|
end
|
71
68
|
|
72
|
-
|
73
|
-
|
69
|
+
def fetch_directory_repo(repo)
|
70
|
+
if File.directory?("#{repo}/.git")
|
71
|
+
fetch_git_repo(repo)
|
72
|
+
else
|
73
|
+
run_cmd("cp -rp #{repo} #{config_path}", :verbose => verbose?)
|
74
|
+
end
|
74
75
|
end
|
75
|
-
end
|
76
76
|
|
77
|
-
|
78
|
-
|
77
|
+
def fetch_git_repo(repo)
|
78
|
+
git_options = "--quiet --depth=1 --branch #{conf_branch}"
|
79
|
+
run_cmd("git clone #{git_options} #{repo} #{config_path}", :verbose => verbose?)
|
80
|
+
end
|
81
|
+
|
82
|
+
def include_app(app, stage=nil)
|
83
|
+
app_file = "#{config_path}/apps/#{app}/defaults.rb"
|
84
|
+
stage_file = "#{config_path}/apps/#{app}/#{stage}.rb"
|
85
|
+
|
86
|
+
if File.exists?(app_file)
|
87
|
+
run_cmd("cat #{app_file} >> #{capfile_path}", :verbose => verbose?)
|
88
|
+
end
|
79
89
|
|
80
|
-
|
81
|
-
|
90
|
+
if stage
|
91
|
+
run_cmd("cat #{stage_file} >> #{capfile_path}", :verbose => verbose?)
|
92
|
+
end
|
82
93
|
end
|
83
94
|
|
84
|
-
|
85
|
-
|
95
|
+
def include_app_recipes(app, stage=nil)
|
96
|
+
recipes_dir = "#{config_path}/apps/#{app}/recipes"
|
97
|
+
|
98
|
+
Dir.glob("#{recipes_dir}/*.rb").each do |recipe|
|
86
99
|
run_cmd("cat #{recipe} >> #{capfile_path}", :verbose => verbose?)
|
87
100
|
end
|
101
|
+
|
102
|
+
if stage
|
103
|
+
Dir.glob("#{recipes_dir}/#{stage}/*.rb").each do |recipe|
|
104
|
+
run_cmd("cat #{recipe} >> #{capfile_path}", :verbose => verbose?)
|
105
|
+
end
|
106
|
+
end
|
88
107
|
end
|
89
|
-
end
|
90
108
|
|
91
|
-
|
92
|
-
|
93
|
-
|
109
|
+
def include_base_conf
|
110
|
+
run_cmd("cat #{config_path}/apps/base.rb >> #{capfile_path}", :verbose => verbose?)
|
111
|
+
end
|
94
112
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
113
|
+
def list_apps
|
114
|
+
apps = Dir["#{config_path}/apps/*"].each do |app|
|
115
|
+
if File.directory?(app)
|
116
|
+
app_name = File.basename(app)
|
117
|
+
app_envs = []
|
100
118
|
|
101
|
-
|
102
|
-
|
103
|
-
|
119
|
+
Dir["#{app}/*"].each do |env|
|
120
|
+
environments = %w(development staging production)
|
121
|
+
env_name = File.basename(env, '.rb')
|
104
122
|
|
105
|
-
|
106
|
-
|
123
|
+
if environments.include?(env_name)
|
124
|
+
app_envs << env_name
|
125
|
+
end
|
107
126
|
end
|
127
|
+
|
128
|
+
puts "#{app_name.cyan}: #{app_envs.map(&:magenta).join(', ')}"
|
108
129
|
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def load_configuration
|
134
|
+
conf_path = application_path || Dir.home
|
135
|
+
conf_file = File.join(conf_path, ".pulsar")
|
136
|
+
|
137
|
+
if File.file?(conf_file)
|
138
|
+
File.readlines(conf_file).each do |line|
|
139
|
+
conf, value = line.split("=")
|
109
140
|
|
110
|
-
|
141
|
+
ENV[conf] = value.chomp.gsub('"', '')
|
142
|
+
end
|
111
143
|
end
|
112
144
|
end
|
113
|
-
end
|
114
145
|
|
115
|
-
|
116
|
-
|
117
|
-
|
146
|
+
def remove_capfile
|
147
|
+
rm_rf(capfile_path, :verbose => verbose?)
|
148
|
+
end
|
118
149
|
|
119
|
-
|
120
|
-
|
121
|
-
|
150
|
+
def remove_repo
|
151
|
+
rm_rf(config_path, :verbose => verbose?)
|
152
|
+
end
|
122
153
|
|
123
|
-
|
124
|
-
|
125
|
-
|
154
|
+
def reset_for_other_app!
|
155
|
+
@capfile_name = @configuration_path = @now = nil
|
156
|
+
end
|
157
|
+
|
158
|
+
def run_capistrano(args)
|
159
|
+
cmd = "bundle exec cap"
|
160
|
+
env = "CONFIG_PATH=#{config_path}"
|
161
|
+
opts = "--file #{capfile_path}"
|
126
162
|
|
127
|
-
|
128
|
-
|
129
|
-
|
163
|
+
env += " APP_PATH=#{application_path}" unless application_path.nil?
|
164
|
+
|
165
|
+
cd(config_path, :verbose => verbose?) do
|
166
|
+
run_cmd("#{cmd} #{env} #{opts} #{args}", :verbose => verbose?)
|
167
|
+
end
|
130
168
|
end
|
131
|
-
end
|
132
169
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
170
|
+
def rm_rf(path, opts)
|
171
|
+
puts "Remove: #{path.white}".yellow if opts[:verbose]
|
172
|
+
FileUtils.rm_rf(path)
|
173
|
+
end
|
137
174
|
|
138
|
-
|
139
|
-
|
140
|
-
|
175
|
+
def run_cmd(cmd, opts)
|
176
|
+
puts "Command: #{cmd.white}".yellow if opts[:verbose]
|
177
|
+
system(cmd)
|
141
178
|
|
142
|
-
|
143
|
-
|
179
|
+
raise "Command #{cmd} Failed" if $? != 0
|
180
|
+
end
|
144
181
|
|
145
|
-
|
146
|
-
|
147
|
-
|
182
|
+
def set_log_level
|
183
|
+
level = log_level.upcase
|
184
|
+
levels = %w(IMPORTANT INFO DEBUG)
|
148
185
|
|
149
|
-
|
186
|
+
level = levels.first unless levels.include?(level)
|
150
187
|
|
151
|
-
|
188
|
+
cmd = "echo 'logger.level = logger.level = Capistrano::Logger::#{level}' >> #{capfile_path}"
|
152
189
|
|
153
|
-
|
154
|
-
|
190
|
+
run_cmd(cmd, :verbose => verbose?)
|
191
|
+
end
|
155
192
|
|
156
|
-
|
157
|
-
|
158
|
-
|
193
|
+
def time_to_deploy
|
194
|
+
@now ||= Time.now.strftime("%Y-%m-%d-%H%M%S-s#{rand(9999)}")
|
195
|
+
end
|
159
196
|
|
160
|
-
|
161
|
-
|
162
|
-
|
197
|
+
def touch(file, opts)
|
198
|
+
puts "Touch: #{file.white}".yellow if opts[:verbose]
|
199
|
+
FileUtils.touch(file)
|
200
|
+
end
|
163
201
|
end
|
164
202
|
end
|
165
203
|
end
|
@@ -23,6 +23,18 @@ module Pulsar
|
|
23
23
|
"a directory where to put the configuration repo to build capfile with",
|
24
24
|
:default => "/tmp/pulsar"
|
25
25
|
end
|
26
|
+
|
27
|
+
#
|
28
|
+
# TODO: find a way to fix this hack. This is made so that
|
29
|
+
# load_configuration() is called before Clamp parses command
|
30
|
+
# line arguments (and runs into errors because no conf repo
|
31
|
+
# is defined).
|
32
|
+
#
|
33
|
+
def parse(arguments)
|
34
|
+
self.class.send(:include, Pulsar::Helpers::Clamp)
|
35
|
+
load_configuration
|
36
|
+
super
|
37
|
+
end
|
26
38
|
end
|
27
39
|
end
|
28
40
|
end
|
data/lib/pulsar/version.rb
CHANGED
data/pulsar.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
|
|
14
14
|
to store all your precious configurations and recipes to build Capistrano
|
15
15
|
deploys on it.
|
16
16
|
}
|
17
|
-
gem.homepage = "
|
17
|
+
gem.homepage = "http://pulsar.nebulab.it"
|
18
18
|
|
19
19
|
gem.files = `git ls-files`.split($/)
|
20
20
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -19,6 +19,34 @@ describe Pulsar::ListCommand do
|
|
19
19
|
Dir.glob("#{tmp_path}/conf-repo*").should be_empty
|
20
20
|
end
|
21
21
|
|
22
|
+
it "reads configuration variables from .pulsar file in home" do
|
23
|
+
env_vars = [ "PULSAR_CONF_REPO=\"#{dummy_conf_path}\"\n"]
|
24
|
+
|
25
|
+
File.stub(:file?).and_return(true)
|
26
|
+
File.stub(:readlines).with("#{Dir.home}/.pulsar").and_return(env_vars)
|
27
|
+
|
28
|
+
pulsar.run(full_list_args)
|
29
|
+
|
30
|
+
ENV.should have_key('PULSAR_CONF_REPO')
|
31
|
+
ENV['PULSAR_CONF_REPO'].should == dummy_conf_path
|
32
|
+
end
|
33
|
+
|
34
|
+
it "reads configuration variables from .pulsar file in rack app directory" do
|
35
|
+
env_vars = [ "PULSAR_CONF_REPO=\"#{dummy_conf_path}\"\n"]
|
36
|
+
|
37
|
+
File.stub(:file?).and_return(true)
|
38
|
+
File.stub(:readlines).with("#{File.expand_path(dummy_rack_app_path)}/.pulsar").and_return(env_vars)
|
39
|
+
|
40
|
+
FileUtils.cd(dummy_rack_app_path) do
|
41
|
+
reload_main_command
|
42
|
+
|
43
|
+
pulsar.run(full_list_args)
|
44
|
+
end
|
45
|
+
|
46
|
+
ENV.should have_key('PULSAR_CONF_REPO')
|
47
|
+
ENV['PULSAR_CONF_REPO'].should == dummy_conf_path
|
48
|
+
end
|
49
|
+
|
22
50
|
context "--conf-repo option" do
|
23
51
|
it "is required" do
|
24
52
|
expect { pulsar.parse([]) }.to raise_error(Clamp::UsageError)
|
@@ -39,6 +39,40 @@ describe Pulsar::MainCommand do
|
|
39
39
|
expect { pulsar.run(full_cap_args + apps_to_deploy) }.to change{ Dir.glob("#{tmp_path}/capfile-*").length }.by(2)
|
40
40
|
end
|
41
41
|
|
42
|
+
it "reads configuration variables from .pulsar file in home" do
|
43
|
+
env_vars = [ "PULSAR_APP_NAME=\"dummy_app\"\n", "PULSAR_CONF_REPO=\"#{dummy_conf_path}\"\n"]
|
44
|
+
|
45
|
+
File.stub(:file?).and_return(true)
|
46
|
+
File.stub(:readlines).with("#{Dir.home}/.pulsar").and_return(env_vars)
|
47
|
+
|
48
|
+
pulsar.run(full_cap_args + dummy_app)
|
49
|
+
|
50
|
+
ENV.should have_key('PULSAR_APP_NAME')
|
51
|
+
ENV['PULSAR_APP_NAME'].should == "dummy_app"
|
52
|
+
|
53
|
+
ENV.should have_key('PULSAR_CONF_REPO')
|
54
|
+
ENV['PULSAR_CONF_REPO'].should == dummy_conf_path
|
55
|
+
end
|
56
|
+
|
57
|
+
it "reads configuration variables from .pulsar file in rack app directory" do
|
58
|
+
env_vars = [ "PULSAR_APP_NAME=\"dummy_app\"\n", "PULSAR_CONF_REPO=\"#{dummy_conf_path}\"\n"]
|
59
|
+
|
60
|
+
File.stub(:file?).and_return(true)
|
61
|
+
File.stub(:readlines).with("#{File.expand_path(dummy_rack_app_path)}/.pulsar").and_return(env_vars)
|
62
|
+
|
63
|
+
FileUtils.cd(dummy_rack_app_path) do
|
64
|
+
reload_main_command
|
65
|
+
|
66
|
+
pulsar.run(full_cap_args + %w(production))
|
67
|
+
end
|
68
|
+
|
69
|
+
ENV.should have_key('PULSAR_APP_NAME')
|
70
|
+
ENV['PULSAR_APP_NAME'].should == "dummy_app"
|
71
|
+
|
72
|
+
ENV.should have_key('PULSAR_CONF_REPO')
|
73
|
+
ENV['PULSAR_CONF_REPO'].should == dummy_conf_path
|
74
|
+
end
|
75
|
+
|
42
76
|
context "Capfile" do
|
43
77
|
it "uses base.rb in staging stage" do
|
44
78
|
pulsar.run(full_cap_args + dummy_app(:staging))
|
@@ -103,6 +137,18 @@ describe Pulsar::MainCommand do
|
|
103
137
|
latest_capfile.should include("# This is apps/dummy_app/recipes/production/custom_recipe.rb")
|
104
138
|
latest_capfile.should_not include("# This is apps/dummy_app/recipes/staging/custom_recipe.rb")
|
105
139
|
end
|
140
|
+
|
141
|
+
it "uses dirname from PULSAR_APP_NAME when inside a rack app directory" do
|
142
|
+
ENV["PULSAR_APP_NAME"] = "other_dummy_app"
|
143
|
+
|
144
|
+
FileUtils.cd(dummy_rack_app_path) do
|
145
|
+
reload_main_command
|
146
|
+
pulsar.run(full_cap_args + %w(production))
|
147
|
+
end
|
148
|
+
|
149
|
+
latest_capfile.should include("# This is apps/other_dummy_app/defaults.rb")
|
150
|
+
latest_capfile.should include("# This is apps/other_dummy_app/production.rb")
|
151
|
+
end
|
106
152
|
end
|
107
153
|
|
108
154
|
context "--version option" do
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pulsar::Helpers::Capistrano do
|
4
|
+
include Pulsar::Helpers::Capistrano
|
5
|
+
|
6
|
+
context "load_recipes" do
|
7
|
+
it "loads capistrano recipes from CONFIG_PATH env variable" do
|
8
|
+
ENV['CONFIG_PATH'] = "/config/path"
|
9
|
+
File.stub(:directory?).and_return(true)
|
10
|
+
File.stub(:exists?).and_return(true)
|
11
|
+
|
12
|
+
self.should_receive(:load).with("/config/path/recipes/generic/recipe.rb")
|
13
|
+
|
14
|
+
load_recipes { generic :recipe }
|
15
|
+
end
|
16
|
+
|
17
|
+
it "raises a missing recipe type exception when no recipe folder is found" do
|
18
|
+
File.stub(:directory?).and_return(false)
|
19
|
+
|
20
|
+
expect { load_recipes { generic :recipe } }.to raise_error(RuntimeError, /no recipes of type generic/)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "raises a missing recipe exception when no recipe is found" do
|
24
|
+
File.stub(:directory?).and_return(true)
|
25
|
+
File.stub(:exists?).and_return(false)
|
26
|
+
|
27
|
+
expect { load_recipes { generic :missing_recipe } }.to raise_error(RuntimeError, /no missing_recipe recipe/)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "from_application_path?" do
|
32
|
+
it "returns true if APP_PATH env variable is set" do
|
33
|
+
ENV['APP_PATH'] = "/app/path"
|
34
|
+
|
35
|
+
from_application_path?.should be_true
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns false if APP_PATH env variable is not set" do
|
39
|
+
ENV.delete('APP_PATH')
|
40
|
+
|
41
|
+
from_application_path?.should be_false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -20,4 +20,26 @@ describe Pulsar::Helpers::Clamp do
|
|
20
20
|
time_to_deploy.should_not == time
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
context "run_capistrano" do
|
25
|
+
before do
|
26
|
+
self.stub!(:config_path).and_return(dummy_conf_path)
|
27
|
+
self.stub!(:verbose?).and_return(false)
|
28
|
+
self.stub!(:capfile_path).and_return('/stubbed/capfile')
|
29
|
+
end
|
30
|
+
|
31
|
+
it "runs capistrano when pulsar is invoked from outside the application directory" do
|
32
|
+
self.should_receive(:run_cmd).with("bundle exec cap CONFIG_PATH=#{config_path} --file #{capfile_path} deploy", anything)
|
33
|
+
|
34
|
+
run_capistrano("deploy")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "runs capistrano when pulsar is invoked from inside the application directory" do
|
38
|
+
self.stub!(:application_path).and_return("/app/path")
|
39
|
+
|
40
|
+
self.should_receive(:run_cmd).with("bundle exec cap CONFIG_PATH=#{config_path} APP_PATH=#{application_path} --file #{capfile_path} deploy", anything)
|
41
|
+
|
42
|
+
run_capistrano("deploy")
|
43
|
+
end
|
44
|
+
end
|
23
45
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -22,7 +22,10 @@ RSpec.configure do |config|
|
|
22
22
|
config.include Helpers
|
23
23
|
config.include OutputCapture
|
24
24
|
|
25
|
-
config.before(:
|
25
|
+
config.before(:each) do
|
26
|
+
Dir.stub(:home).and_return("/fake/home")
|
27
|
+
|
28
|
+
ENV.delete("PULSAR_APP_NAME")
|
26
29
|
ENV.delete("PULSAR_CONF_REPO")
|
27
30
|
end
|
28
31
|
|
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.
|
4
|
+
version: 0.2.0
|
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-04-
|
13
|
+
date: 2013-04-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: clamp
|
@@ -135,7 +135,8 @@ extra_rdoc_files: []
|
|
135
135
|
files:
|
136
136
|
- .gitignore
|
137
137
|
- .rspec
|
138
|
-
- .
|
138
|
+
- .ruby-gemset
|
139
|
+
- .ruby-version
|
139
140
|
- .travis.yml
|
140
141
|
- Gemfile
|
141
142
|
- LICENSE.txt
|
@@ -173,6 +174,7 @@ files:
|
|
173
174
|
- spec/pulsar/commands/list_spec.rb
|
174
175
|
- spec/pulsar/commands/main_spec.rb
|
175
176
|
- spec/pulsar/commands/utils_spec.rb
|
177
|
+
- spec/pulsar/helpers/capistrano_spec.rb
|
176
178
|
- spec/pulsar/helpers/clamp_spec.rb
|
177
179
|
- spec/spec_helper.rb
|
178
180
|
- spec/support/dummies/dummy_app/config.ru
|
@@ -191,7 +193,7 @@ files:
|
|
191
193
|
- spec/support/modules/helpers.rb
|
192
194
|
- spec/support/modules/output_capture.rb
|
193
195
|
- spec/support/tmp/.gitkeep
|
194
|
-
homepage:
|
196
|
+
homepage: http://pulsar.nebulab.it
|
195
197
|
licenses: []
|
196
198
|
post_install_message:
|
197
199
|
rdoc_options: []
|
@@ -205,7 +207,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
207
|
version: '0'
|
206
208
|
segments:
|
207
209
|
- 0
|
208
|
-
hash:
|
210
|
+
hash: 889216235847406742
|
209
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
212
|
none: false
|
211
213
|
requirements:
|
@@ -214,10 +216,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
216
|
version: '0'
|
215
217
|
segments:
|
216
218
|
- 0
|
217
|
-
hash:
|
219
|
+
hash: 889216235847406742
|
218
220
|
requirements: []
|
219
221
|
rubyforge_project:
|
220
|
-
rubygems_version: 1.8.
|
222
|
+
rubygems_version: 1.8.25
|
221
223
|
signing_key:
|
222
224
|
specification_version: 3
|
223
225
|
summary: Pulsar helps with Capistrano configuration management. It uses a repository
|
@@ -228,6 +230,7 @@ test_files:
|
|
228
230
|
- spec/pulsar/commands/list_spec.rb
|
229
231
|
- spec/pulsar/commands/main_spec.rb
|
230
232
|
- spec/pulsar/commands/utils_spec.rb
|
233
|
+
- spec/pulsar/helpers/capistrano_spec.rb
|
231
234
|
- spec/pulsar/helpers/clamp_spec.rb
|
232
235
|
- spec/spec_helper.rb
|
233
236
|
- spec/support/dummies/dummy_app/config.ru
|
data/.rvmrc
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
-
# development environment upon cd'ing into the directory
|
5
|
-
|
6
|
-
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
-
# Only full ruby name is supported here, for short names use:
|
8
|
-
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
-
environment_id="ruby-1.9.3-p286@pulsar"
|
10
|
-
|
11
|
-
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
-
# rvmrc_rvm_version="1.16.13 (stable)" # 1.10.1 seams as a safe start
|
13
|
-
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
-
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
-
# return 1
|
16
|
-
# }
|
17
|
-
|
18
|
-
# First we attempt to load the desired environment directly from the environment
|
19
|
-
# file. This is very fast and efficient compared to running through the entire
|
20
|
-
# CLI and selector. If you want feedback on which environment was used then
|
21
|
-
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
-
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
-
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
-
then
|
25
|
-
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
-
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
-
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
-
else
|
29
|
-
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
-
rvm --create "$environment_id" || {
|
31
|
-
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
-
return 1
|
33
|
-
}
|
34
|
-
fi
|
35
|
-
|
36
|
-
# If you use bundler, this might be useful to you:
|
37
|
-
if [[ -s Gemfile ]] && {
|
38
|
-
! builtin command -v bundle >/dev/null ||
|
39
|
-
builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
40
|
-
}
|
41
|
-
then
|
42
|
-
printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
-
gem install bundler
|
44
|
-
fi
|
45
|
-
if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
-
then
|
47
|
-
bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
48
|
-
fi
|
49
|
-
|
50
|
-
alias pulsar="ruby bin/pulsar"
|
51
|
-
alias pulsar-utils="ruby bin/pulsar-utils"
|