whiskey_disk 0.4.4 → 0.4.5

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.4
1
+ 0.4.5
data/lib/whiskey_disk.rb CHANGED
@@ -119,12 +119,25 @@ class WhiskeyDisk
119
119
  end
120
120
 
121
121
  def if_task_defined(task, cmd)
122
- %Q{if [[ `rake -P | grep #{task}` != "" ]]; then #{cmd}; fi}
122
+ %Q{if [[ `#{env_vars} rake -P | grep #{task}` != "" ]]; then #{cmd}; fi}
123
123
  end
124
124
 
125
- def conditional_clone(repo, path)
126
- "if [ -e #{path} ]; then echo 'Repository already cloned to [#{path}]. Skipping.'; " +
127
- "else git clone #{repo} #{tail_path(path)} ; fi"
125
+ def clone_repository(repo, path)
126
+ enqueue "cd #{parent_path(path)}"
127
+ enqueue("if [ -e #{path} ]; then echo 'Repository already cloned to [#{path}]. Skipping.'; " +
128
+ "else git clone #{repo} #{tail_path(path)} ; fi")
129
+ end
130
+
131
+ def refresh_checkout(path, repo_branch)
132
+ enqueue "cd #{path}"
133
+ enqueue "git fetch origin +refs/heads/#{repo_branch}:refs/remotes/origin/#{repo_branch}"
134
+ enqueue "git reset --hard origin/#{repo_branch}"
135
+ end
136
+
137
+ def run_rake_task(path, task_name)
138
+ enqueue "cd #{path}"
139
+ enqueue(if_file_present("#{self[:deploy_to]}/Rakefile",
140
+ if_task_defined(task_name, "#{env_vars} rake --trace #{task_name} to=#{self[:environment]}")))
128
141
  end
129
142
 
130
143
  def ensure_main_parent_path_is_present
@@ -139,28 +152,22 @@ class WhiskeyDisk
139
152
 
140
153
  def checkout_main_repository
141
154
  needs(:deploy_to, :repository)
142
- enqueue "cd #{parent_path(self[:deploy_to])}"
143
- enqueue conditional_clone(self[:repository], self[:deploy_to])
155
+ clone_repository(self[:repository], self[:deploy_to])
144
156
  end
145
157
 
146
158
  def checkout_configuration_repository
147
159
  needs(:deploy_config_to, :config_repository)
148
- enqueue "cd #{parent_path(self[:deploy_config_to])}"
149
- enqueue conditional_clone(self[:config_repository], self[:deploy_config_to])
160
+ clone_repository(self[:config_repository], self[:deploy_config_to])
150
161
  end
151
162
 
152
163
  def update_main_repository_checkout
153
164
  needs(:deploy_to)
154
- enqueue "cd #{self[:deploy_to]}"
155
- enqueue "git fetch origin +refs/heads/#{branch}:refs/remotes/origin/#{branch}"
156
- enqueue "git reset --hard origin/#{branch}"
165
+ refresh_checkout(self[:deploy_to], branch)
157
166
  end
158
167
 
159
168
  def update_configuration_repository_checkout
160
169
  needs(:deploy_config_to)
161
- enqueue "cd #{self[:deploy_config_to]}"
162
- enqueue "git fetch origin +refs/heads/#{config_branch}:refs/remotes/origin/#{config_branch}"
163
- enqueue "git reset --hard origin/#{config_branch}"
170
+ refresh_checkout(self[:deploy_config_to], config_branch)
164
171
  end
165
172
 
166
173
  def refresh_configuration
@@ -171,18 +178,12 @@ class WhiskeyDisk
171
178
 
172
179
  def run_post_setup_hooks
173
180
  needs(:deploy_to)
174
- enqueue "cd #{self[:deploy_to]}"
175
- enqueue(if_file_present("#{self[:deploy_to]}/Rakefile",
176
- if_task_defined("deploy:post_setup",
177
- "#{env_vars} rake --trace deploy:post_setup to=#{self[:environment]}")))
181
+ run_rake_task(self[:deploy_to], "deploy:post_setup")
178
182
  end
179
183
 
180
184
  def run_post_deploy_hooks
181
185
  needs(:deploy_to)
182
- enqueue "cd #{self[:deploy_to]}"
183
- enqueue(if_file_present("#{self[:deploy_to]}/Rakefile",
184
- if_task_defined("deploy:post_deploy",
185
- "#{env_vars} rake --trace deploy:post_deploy to=#{self[:environment]}")))
186
+ run_rake_task(self[:deploy_to], "deploy:post_deploy")
186
187
  end
187
188
  end
188
189
  end
@@ -362,6 +362,16 @@ describe 'WhiskeyDisk' do
362
362
  WhiskeyDisk.buffer.join(' ').should.match(%r{if \[ -e /path/to/main/repo/Rakefile \]; then .*; fi})
363
363
  end
364
364
 
365
+ it 'should ensure that any rake ENV variable are set when checking for deploy:post_setup tasks' do
366
+ @parameters = { 'deploy_to' => '/path/to/main/repo', 'rake_env' => { 'RAILS_ENV' => 'production', 'FOO' => 'bar' } }
367
+ WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
368
+ WhiskeyDisk.reset
369
+ WhiskeyDisk.run_post_setup_hooks
370
+ @parameters['rake_env'].each_pair do |k,v|
371
+ WhiskeyDisk.buffer.join(' ').should.match(%r{#{k}='#{v}' .*rake -P})
372
+ end
373
+ end
374
+
365
375
  it 'should make the post setup rake tasks conditional on the deploy:post_setup rake task being defined' do
366
376
  WhiskeyDisk.run_post_setup_hooks
367
377
  WhiskeyDisk.buffer.join(' ').should.match(%r{if \[\[ \`rake -P | grep deploy:post_setup\` != "" \]\]; })
@@ -406,6 +416,16 @@ describe 'WhiskeyDisk' do
406
416
  WhiskeyDisk.buffer.join(' ').should.match(%r{cd /path/to/main/repo})
407
417
  end
408
418
 
419
+ it 'should ensure that any rake ENV variable are set when checking for deploy:post_setup tasks' do
420
+ @parameters = { 'deploy_to' => '/path/to/main/repo', 'rake_env' => { 'RAILS_ENV' => 'production', 'FOO' => 'bar' } }
421
+ WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
422
+ WhiskeyDisk.reset
423
+ WhiskeyDisk.run_post_deploy_hooks
424
+ @parameters['rake_env'].each_pair do |k,v|
425
+ WhiskeyDisk.buffer.join(' ').should.match(%r{#{k}='#{v}' .*rake -P})
426
+ end
427
+ end
428
+
409
429
  it 'should make the post deployment rake tasks conditional on the presence of a Rakefile in the deployment path' do
410
430
  WhiskeyDisk.run_post_deploy_hooks
411
431
  WhiskeyDisk.buffer.join(' ').should.match(%r{if \[ -e /path/to/main/repo/Rakefile \]; then .*; fi})
data/whiskey_disk.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{whiskey_disk}
8
- s.version = "0.4.4"
8
+ s.version = "0.4.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rick Bradley"]
12
- s.date = %q{2010-07-23}
12
+ s.date = %q{2010-08-31}
13
13
  s.default_executable = %q{wd}
14
14
  s.description = %q{Opinionated gem for doing fast git-based server deployments.}
15
15
  s.email = %q{rick@rickbradley.com}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whiskey_disk
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 4
10
- version: 0.4.4
9
+ - 5
10
+ version: 0.4.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rick Bradley
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-23 00:00:00 -05:00
18
+ date: 2010-08-31 00:00:00 -05:00
19
19
  default_executable: wd
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency