whiskey_disk 0.5.2 → 0.5.3

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/README.markdown CHANGED
@@ -364,3 +364,8 @@ to see what we have in mind for the near future.
364
364
  - [http://toroid.org/ams/git-website-howto](http://toroid.org/ams/git-website-howto)
365
365
 
366
366
 
367
+ ### Contributors ###
368
+
369
+ - Rick Bradley (rick@rickbradley.com, github:rick)
370
+ - Jeremy Holland (jeremy@jeremypholland.com, github:therubyneck): feature/bugfix contributions
371
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.3
@@ -8,24 +8,29 @@ class WhiskeyDisk
8
8
  return ENV['to'] unless ENV['to'] =~ /:/
9
9
  ENV['to'].split(/:/)[1]
10
10
  end
11
-
11
+
12
12
  def specified_project_name
13
13
  return false unless (ENV['to'] && ENV['to'] =~ /:/)
14
14
  ENV['to'].split(/:/).first
15
15
  end
16
-
16
+
17
+ def override_project_name!(data)
18
+ return if ENV['to'] && ENV['to'] =~ /:/
19
+ ENV['to'] = data[environment_name]['project'] + ':' + ENV['to'] if data[environment_name]['project']
20
+ end
21
+
17
22
  def path
18
23
  (ENV['path'] && ENV['path'] != '') ? ENV['path'] : false
19
24
  end
20
-
25
+
21
26
  def check_staleness?
22
27
  !!(ENV['check'] && ENV['check'] =~ /^(?:t(?:rue)?|y(?:es)?|1)$/)
23
28
  end
24
-
29
+
25
30
  def contains_rakefile?(path)
26
31
  File.exists?(File.expand_path(File.join(path, 'Rakefile')))
27
32
  end
28
-
33
+
29
34
  def find_rakefile_from_current_path
30
35
  original_path = Dir.pwd
31
36
  while (!contains_rakefile?(Dir.pwd))
@@ -36,38 +41,38 @@ class WhiskeyDisk
36
41
  ensure
37
42
  Dir.chdir(original_path)
38
43
  end
39
-
44
+
40
45
  def base_path
41
46
  return path if path
42
47
  find_rakefile_from_current_path
43
48
  end
44
-
49
+
45
50
  def configuration_file
46
51
  return path if path and File.file?(path)
47
-
52
+
48
53
  files = []
49
54
 
50
55
  files += [
51
56
  File.join(base_path, 'deploy', specified_project_name, "#{environment_name}.yml"), # /deploy/foo/staging.yml
52
57
  File.join(base_path, 'deploy', "#{specified_project_name}.yml") # /deploy/foo.yml
53
58
  ] if specified_project_name
54
-
55
- files += [
59
+
60
+ files += [
56
61
  File.join(base_path, 'deploy', "#{environment_name}.yml"), # /deploy/staging.yml
57
62
  File.join(base_path, "#{environment_name}.yml"), # /staging.yml
58
63
  File.join(base_path, 'deploy.yml') # /deploy.yml
59
64
  ]
60
-
65
+
61
66
  files.each { |file| return file if File.exists?(file) }
62
-
67
+
63
68
  raise "Could not locate configuration file in path [#{base_path}]"
64
69
  end
65
-
70
+
66
71
  def configuration_data
67
72
  raise "Configuration file [#{configuration_file}] not found!" unless File.exists?(configuration_file)
68
73
  File.read(configuration_file)
69
74
  end
70
-
75
+
71
76
  def project_name
72
77
  specified_project_name || 'unnamed_project'
73
78
  end
@@ -77,12 +82,12 @@ class WhiskeyDisk
77
82
  return depth if data.has_key?('repository')
78
83
  repository_depth(data.values.first, depth + 1)
79
84
  end
80
-
85
+
81
86
  # is this data hash a bottom-level data hash without an environment name?
82
87
  def needs_environment_scoping?(data)
83
88
  repository_depth(data) == 0
84
89
  end
85
-
90
+
86
91
  # is this data hash an environment data hash without a project name?
87
92
  def needs_project_scoping?(data)
88
93
  repository_depth(data) == 1
@@ -93,33 +98,34 @@ class WhiskeyDisk
93
98
  { environment_name => data }
94
99
  end
95
100
 
96
- def add_project_scoping(data)
101
+ def add_project_scoping(data)
97
102
  return data unless needs_project_scoping?(data)
103
+ override_project_name!(data)
98
104
  { project_name => data }
99
105
  end
100
106
 
101
107
  def normalize_data(data)
102
108
  add_project_scoping(add_environment_scoping(data.clone))
103
- end
104
-
109
+ end
110
+
105
111
  def load_data
106
112
  normalize_data(YAML.load(configuration_data))
107
113
  rescue Exception => e
108
114
  raise %Q{Error reading configuration file [#{configuration_file}]: "#{e}"}
109
115
  end
110
-
116
+
111
117
  def filter_data(data)
112
118
  raise "No configuration file defined data for environment [#{environment_name}]" unless data[project_name][environment_name]
113
119
  data[project_name][environment_name].merge({
114
- 'environment' => environment_name,
120
+ 'environment' => environment_name,
115
121
  'project' => project_name
116
122
  })
117
123
  end
118
-
124
+
119
125
  def fetch
120
126
  raise "Cannot determine current environment -- try rake ... to=staging, for example." unless environment_name
121
127
  filter_data(load_data)
122
128
  end
123
129
  end
124
130
  end
125
- end
131
+ end
@@ -11,37 +11,37 @@ describe WhiskeyDisk::Config do
11
11
  ENV['to'] = nil
12
12
  WhiskeyDisk::Config.environment_name.should == false
13
13
  end
14
-
14
+
15
15
  it 'should return false when the ENV["to"] setting is blank' do
16
16
  ENV['to'] = ''
17
- WhiskeyDisk::Config.environment_name.should == false
17
+ WhiskeyDisk::Config.environment_name.should == false
18
18
  end
19
-
19
+
20
20
  it 'should return the ENV["to"] setting when it is non-blank' do
21
21
  ENV['to'] = 'staging'
22
22
  WhiskeyDisk::Config.environment_name.should == 'staging'
23
23
  end
24
-
24
+
25
25
  it 'should return the environment portion of the ENV["to"] setting when a project is specified' do
26
26
  ENV['to'] = 'project:staging'
27
- WhiskeyDisk::Config.environment_name.should == 'staging'
27
+ WhiskeyDisk::Config.environment_name.should == 'staging'
28
28
  end
29
29
  end
30
-
30
+
31
31
  describe 'when determining whether to do a staleness check before updating' do
32
32
  it 'should return false when there is no ENV["check"] setting' do
33
33
  ENV['check'] = nil
34
34
  WhiskeyDisk::Config.check_staleness?.should == false
35
35
  end
36
-
36
+
37
37
  it 'should return false when the ENV["check"] setting is blank' do
38
38
  ENV['check'] = ''
39
- WhiskeyDisk::Config.check_staleness?.should == false
39
+ WhiskeyDisk::Config.check_staleness?.should == false
40
40
  end
41
-
41
+
42
42
  it 'should return true if the ENV["check"] setting is "t"' do
43
43
  ENV['check'] = 't'
44
- WhiskeyDisk::Config.check_staleness?.should == true
44
+ WhiskeyDisk::Config.check_staleness?.should == true
45
45
  end
46
46
 
47
47
  it 'should return true if the ENV["check"] setting is "true"' do
@@ -51,50 +51,50 @@ describe WhiskeyDisk::Config do
51
51
 
52
52
  it 'should return true if the ENV["check"] setting is "y"' do
53
53
  ENV['check'] = 'y'
54
- WhiskeyDisk::Config.check_staleness?.should == true
54
+ WhiskeyDisk::Config.check_staleness?.should == true
55
55
  end
56
56
 
57
57
  it 'should return true if the ENV["check"] setting is "yes"' do
58
58
  ENV['check'] = 'yes'
59
- WhiskeyDisk::Config.check_staleness?.should == true
59
+ WhiskeyDisk::Config.check_staleness?.should == true
60
60
  end
61
61
 
62
62
  it 'should return true if the ENV["check"] setting is "1"' do
63
63
  ENV['check'] = '1'
64
- WhiskeyDisk::Config.check_staleness?.should == true
64
+ WhiskeyDisk::Config.check_staleness?.should == true
65
65
  end
66
66
  end
67
-
67
+
68
68
  describe 'when fetching configuration' do
69
69
  before do
70
70
  ENV['to'] = @env = 'foo:staging'
71
71
  end
72
-
72
+
73
73
  it 'should fail if the current environment cannot be determined' do
74
74
  ENV['to'] = nil
75
75
  lambda { WhiskeyDisk::Config.fetch }.should.raise
76
76
  end
77
-
77
+
78
78
  it 'should fail if the configuration file does not exist' do
79
79
  WhiskeyDisk::Config.stub!(:configuration_file).and_return(__FILE__ + "_.crap")
80
80
  lambda { WhiskeyDisk::Config.fetch }.should.raise
81
81
  end
82
-
82
+
83
83
  it 'should fail if the configuration file cannot be read' do
84
84
  WhiskeyDisk::Config.stub!(:configuration_file).and_return("/tmp")
85
- lambda { WhiskeyDisk::Config.fetch }.should.raise
85
+ lambda { WhiskeyDisk::Config.fetch }.should.raise
86
86
  end
87
-
87
+
88
88
  it 'should fail if the configuration file is invalid' do
89
89
  YAML.stub!(:load).and_raise
90
- lambda { WhiskeyDisk::Config.fetch }.should.raise
90
+ lambda { WhiskeyDisk::Config.fetch }.should.raise
91
91
  end
92
-
92
+
93
93
  it 'should fail if the configuration file does not define data for this environment' do
94
94
  WhiskeyDisk::Config.stub!(:configuration_data).and_return(YAML.dump({'foo' => { 'production' => { 'a' => 'b'}}}))
95
95
  lambda { WhiskeyDisk::Config.fetch }.should.raise
96
96
  end
97
-
97
+
98
98
  it 'should return the configuration yaml file data for this environment as a hash' do
99
99
  staging = { 'foo' => 'bar', 'repository' => 'xyzzy' }
100
100
  WhiskeyDisk::Config.stub!(:configuration_data).and_return(YAML.dump({'foo' => { 'production' => { 'repository' => 'b'}, 'staging' => staging }}))
@@ -103,63 +103,70 @@ describe WhiskeyDisk::Config do
103
103
  result[k].should == v
104
104
  end
105
105
  end
106
-
106
+
107
107
  it 'should not include configuration information for other environments in the returned hash' do
108
108
  staging = { 'foo' => 'bar', 'baz' => 'xyzzy' }
109
109
  WhiskeyDisk::Config.stub!(:configuration_data).and_return(YAML.dump({ 'production' => { 'repository' => 'c', 'a' => 'b'}, 'staging' => staging }))
110
110
  WhiskeyDisk::Config.fetch['a'].should.be.nil
111
111
  end
112
-
112
+
113
113
  it 'should include the environment in the hash' do
114
114
  staging = { 'foo' => 'bar', 'baz' => 'xyzzy' }
115
115
  WhiskeyDisk::Config.stub!(:configuration_data).and_return(YAML.dump({'foo' => { 'production' => { 'repository' => 'b'}, 'staging' => staging }}))
116
116
  WhiskeyDisk::Config.fetch['environment'].should == 'staging'
117
117
  end
118
-
118
+
119
119
  it 'should not allow overriding the environment in the configuration file' do
120
120
  staging = { 'foo' => 'bar', 'repository' => 'xyzzy', 'environment' => 'production' }
121
121
  WhiskeyDisk::Config.stub!(:configuration_data).and_return(YAML.dump({'foo' => { 'production' => { 'repository' => 'b'}, 'staging' => staging }}))
122
122
  WhiskeyDisk::Config.fetch['environment'].should == 'staging'
123
123
  end
124
-
124
+
125
125
  it 'should include the project handle in the hash' do
126
126
  staging = { 'foo' => 'bar', 'repository' => 'xyzzy' }
127
127
  WhiskeyDisk::Config.stub!(:configuration_data).and_return(YAML.dump({'foo' => { 'production' => { 'repository' => 'b'}, 'staging' => staging }}))
128
128
  WhiskeyDisk::Config.fetch['project'].should == 'foo'
129
129
  end
130
-
131
- it 'should not allow overriding the project handle in the configuration file' do
130
+
131
+ it 'should not allow overriding the project handle in the configuration file when a project root is specified' do
132
132
  staging = { 'foo' => 'bar', 'repository' => 'xyzzy', 'project' => 'diskey_whisk' }
133
133
  WhiskeyDisk::Config.stub!(:configuration_data).and_return(YAML.dump({'foo' => { 'production' => { 'repository' => 'b'}, 'staging' => staging }}))
134
134
  WhiskeyDisk::Config.fetch['project'].should == 'foo'
135
135
  end
136
+
137
+ it 'should allow overriding the project handle in the configuration file when a project root is not specified' do
138
+ ENV['to'] = @env = 'staging'
139
+ staging = { 'foo' => 'bar', 'repository' => 'xyzzy', 'project' => 'diskey_whisk' }
140
+ WhiskeyDisk::Config.stub!(:configuration_data).and_return(YAML.dump({'production' => { 'repository' => 'b'}, 'staging' => staging }))
141
+ WhiskeyDisk::Config.fetch['project'].should == 'diskey_whisk'
142
+ end
136
143
  end
137
-
144
+
138
145
  describe 'returning configuration data from a configuration file' do
139
146
  it 'should fail if the configuration file does not exist' do
140
147
  WhiskeyDisk::Config.stub!(:configuration_file).and_return(CURRENT_FILE + '._crap')
141
148
  lambda { WhiskeyDisk::Config.configuration_data }.should.raise
142
149
  end
143
-
150
+
144
151
  it 'should return the contents of the configuration file' do
145
152
  WhiskeyDisk::Config.stub!(:configuration_file).and_return(CURRENT_FILE)
146
153
  File.stub!(:read).with(CURRENT_FILE).and_return('file contents')
147
154
  WhiskeyDisk::Config.configuration_data.should == 'file contents'
148
155
  end
149
156
  end
150
-
157
+
151
158
  describe 'transforming data from the configuration file' do
152
159
  it 'should fail if the configuration data cannot be loaded' do
153
160
  WhiskeyDisk::Config.stub!(:configuration_data).and_raise
154
161
  lambda { WhiskeyDisk::Config.load_data }.should.raise
155
162
  end
156
-
163
+
157
164
  it 'should fail if converting the configuration data from YAML fails' do
158
165
  WhiskeyDisk::Config.stub!(:configuration_data).and_return('configuration data')
159
166
  YAML.stub!(:load).and_raise
160
167
  lambda { WhiskeyDisk::Config.load_data }.should.raise
161
168
  end
162
-
169
+
163
170
  it 'should return a normalized version of the un-YAMLized configuration data' do
164
171
  data = { 'a' => 'b', 'c' => 'd' }
165
172
  WhiskeyDisk::Config.stub!(:configuration_data).and_return(YAML.dump(data))
@@ -167,53 +174,89 @@ describe WhiskeyDisk::Config do
167
174
  WhiskeyDisk::Config.load_data.should == 'normalized data'
168
175
  end
169
176
  end
170
-
177
+
171
178
  describe 'normalizing YAML data from the configuration file' do
172
179
  before do
173
180
  ENV['to'] = @env = 'foo:staging'
174
-
181
+
175
182
  @bare_data = { 'repository' => 'git://foo/bar.git', 'domain' => 'ogc@ogtastic.com' }
176
183
  @env_data = { 'staging' => @bare_data }
177
184
  @proj_data = { 'foo' => @env_data }
178
185
  end
179
-
186
+
180
187
  it 'should fail if the configuration data is not a hash' do
181
188
  lambda { WhiskeyDisk::Config.normalize_data([]) }.should.raise
182
189
  end
183
190
 
184
- describe 'when no project name is specified via ENV["to"]' do
191
+ describe 'when no project name is specified via ENV["to"]' do
185
192
  before do
186
193
  ENV['to'] = @env = 'staging'
187
194
  end
188
-
195
+
189
196
  it 'should return the original data if it has both project and environment scoping' do
190
197
  WhiskeyDisk::Config.normalize_data(@proj_data).should == @proj_data
191
198
  end
192
-
193
- it 'should return the original data wrapped in project scope, using a dummy project, if it has environment scoping but no project scoping' do
194
- WhiskeyDisk::Config.normalize_data(@env_data).should == { 'unnamed_project' => @env_data }
199
+
200
+ describe 'when no project name is specified in the bare config hash' do
201
+ it 'should return the original data wrapped in project scope, using a dummy project, if it has environment scoping but no project scoping' do
202
+ WhiskeyDisk::Config.normalize_data(@env_data).should == { 'unnamed_project' => @env_data }
203
+ end
204
+
205
+ it 'should return the original data wrapped in a project scope, using a dummy project, and an environment scope if it has neither scoping' do
206
+ WhiskeyDisk::Config.normalize_data(@bare_data).should == { 'unnamed_project' => { 'staging' => @bare_data } }
207
+ end
195
208
  end
196
-
197
- it 'should return the original data wrapped in a project scope, using a dummy project, and an environment scope if it has neither scoping' do
198
- WhiskeyDisk::Config.normalize_data(@bare_data).should == { 'unnamed_project' => { 'staging' => @bare_data } }
209
+
210
+ describe 'when a project name is specified in the bare config hash' do
211
+ before do
212
+ @bare_data['project'] = 'whiskey_disk'
213
+ end
214
+
215
+ it 'should return the original data wrapped in project scope if it has environment scoping but no project scoping' do
216
+ WhiskeyDisk::Config.normalize_data(@env_data).should == { 'whiskey_disk' => @env_data }
217
+ end
218
+
219
+ it 'should return the original data wrapped in a project scope and an environment scope if it has neither scoping' do
220
+ WhiskeyDisk::Config.normalize_data(@bare_data).should == { 'whiskey_disk' => { 'staging' => @bare_data } }
221
+ end
199
222
  end
200
223
  end
201
224
 
202
- describe 'when a project name is specified via ENV["to"]' do
225
+ describe 'when a project name is specified via ENV["to"]' do
203
226
  before do
204
227
  ENV['to'] = @env = 'whiskey_disk:staging'
205
228
  end
206
-
207
- it 'should return the original data if it has both project and environment scoping' do
208
- WhiskeyDisk::Config.normalize_data(@proj_data).should == @proj_data
209
- end
210
-
211
- it 'should return the original data wrapped in project scope if it has environment scoping but no project scoping' do
212
- WhiskeyDisk::Config.normalize_data(@env_data).should == { 'whiskey_disk' => @env_data }
229
+
230
+ describe 'when a project name is not specified in the bare config hash' do
231
+ it 'should return the original data if it has both project and environment scoping' do
232
+ WhiskeyDisk::Config.normalize_data(@proj_data).should == @proj_data
233
+ end
234
+
235
+ it 'should return the original data wrapped in project scope if it has environment scoping but no project scoping' do
236
+ WhiskeyDisk::Config.normalize_data(@env_data).should == { 'whiskey_disk' => @env_data }
237
+ end
238
+
239
+ it 'should return the original data wrapped in a project scope and an environment scope if it has neither scoping' do
240
+ WhiskeyDisk::Config.normalize_data(@bare_data).should == { 'whiskey_disk' => { 'staging' => @bare_data } }
241
+ end
213
242
  end
214
-
215
- it 'should return the original data wrapped in a project scope and an environment scope if it has neither scoping' do
216
- WhiskeyDisk::Config.normalize_data(@bare_data).should == { 'whiskey_disk' => { 'staging' => @bare_data } }
243
+
244
+ describe 'when a project name is specified in the bare config hash' do
245
+ before do
246
+ @bare_data['project'] = 'whiskey_disk'
247
+ end
248
+
249
+ it 'should return the original data if it has both project and environment scoping' do
250
+ WhiskeyDisk::Config.normalize_data(@proj_data).should == @proj_data
251
+ end
252
+
253
+ it 'should return the original data wrapped in project scope if it has environment scoping but no project scoping' do
254
+ WhiskeyDisk::Config.normalize_data(@env_data).should == { 'whiskey_disk' => @env_data }
255
+ end
256
+
257
+ it 'should return the original data wrapped in a project scope and an environment scope if it has neither scoping' do
258
+ WhiskeyDisk::Config.normalize_data(@bare_data).should == { 'whiskey_disk' => { 'staging' => @bare_data } }
259
+ end
217
260
  end
218
261
  end
219
262
  end
@@ -221,17 +264,17 @@ describe WhiskeyDisk::Config do
221
264
  describe 'computing the project name from a configuration hash' do
222
265
  it 'should return the project name from the ENV["to"] setting when it is available' do
223
266
  ENV['to'] = 'foo:staging'
224
- WhiskeyDisk::Config.project_name.should == 'foo'
267
+ WhiskeyDisk::Config.project_name.should == 'foo'
225
268
  end
226
-
227
- it 'should fail when ENV["to"] is unset' do
269
+
270
+ it 'should return "unnamed_project" when ENV["to"] is unset' do
228
271
  ENV['to'] = ''
229
- WhiskeyDisk::Config.project_name.should == 'unnamed_project'
272
+ WhiskeyDisk::Config.project_name.should == 'unnamed_project'
230
273
  end
231
-
274
+
232
275
  it 'should return "unnamed_project" when no ENV["to"] project setting is available' do
233
276
  ENV['to'] = 'staging'
234
- WhiskeyDisk::Config.project_name.should == 'unnamed_project'
277
+ WhiskeyDisk::Config.project_name.should == 'unnamed_project'
235
278
  end
236
279
  end
237
280
 
@@ -239,47 +282,47 @@ describe WhiskeyDisk::Config do
239
282
  before do
240
283
  ENV['to'] = @env = 'staging'
241
284
  end
242
-
243
- describe 'and no path is specified' do
285
+
286
+ describe 'and no path is specified' do
244
287
  before do
245
288
  ENV['path'] = @path = nil
246
289
  end
247
-
290
+
248
291
  describe 'and a project name is specified in ENV["to"]' do
249
292
  before do
250
293
  ENV['to'] = @env = 'foo:staging'
251
294
  end
252
-
295
+
253
296
  it 'should return the path to deploy/foo/<environment>.yml under the project base path if it exists' do
254
297
  WhiskeyDisk::Config.stub!(:base_path).and_return('/path/to/project/config')
255
298
  File.stub!(:exists?).with('/path/to/project/config/deploy/foo/staging.yml').and_return(true)
256
- WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/deploy/foo/staging.yml'
299
+ WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/deploy/foo/staging.yml'
257
300
  end
258
-
259
- it 'should return the path to deploy/foo.yml under the project base path if it exists' do
301
+
302
+ it 'should return the path to deploy/foo.yml under the project base path if it exists' do
260
303
  WhiskeyDisk::Config.stub!(:base_path).and_return('/path/to/project/config')
261
304
  File.stub!(:exists?).with('/path/to/project/config/deploy/foo/staging.yml').and_return(false)
262
305
  File.stub!(:exists?).with('/path/to/project/config/deploy/foo.yml').and_return(true)
263
- WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/deploy/foo.yml'
306
+ WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/deploy/foo.yml'
264
307
  end
265
-
308
+
266
309
  it 'should return the path to a per-environment configuration file in the deploy/ directory under the project base path if it exists' do
267
310
  WhiskeyDisk::Config.stub!(:base_path).and_return('/path/to/project/config')
268
311
  File.stub!(:exists?).with('/path/to/project/config/deploy/foo/staging.yml').and_return(false)
269
312
  File.stub!(:exists?).with('/path/to/project/config/deploy/foo.yml').and_return(false)
270
313
  File.stub!(:exists?).with('/path/to/project/config/deploy/staging.yml').and_return(true)
271
- WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/deploy/staging.yml'
314
+ WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/deploy/staging.yml'
272
315
  end
273
-
316
+
274
317
  it 'should return the path to a per-environment configuration file under the project base path if it exists' do
275
318
  WhiskeyDisk::Config.stub!(:base_path).and_return('/path/to/project/config')
276
319
  File.stub!(:exists?).with('/path/to/project/config/deploy/foo/staging.yml').and_return(false)
277
320
  File.stub!(:exists?).with('/path/to/project/config/deploy/foo.yml').and_return(false)
278
321
  File.stub!(:exists?).with('/path/to/project/config/deploy/staging.yml').and_return(false)
279
322
  File.stub!(:exists?).with('/path/to/project/config/staging.yml').and_return(true)
280
- WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/staging.yml'
323
+ WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/staging.yml'
281
324
  end
282
-
325
+
283
326
  it 'should return the path to deploy.yml under the project base path' do
284
327
  WhiskeyDisk::Config.stub!(:base_path).and_return('/path/to/project/config')
285
328
  File.stub!(:exists?).with('/path/to/project/config/deploy/foo/staging.yml').and_return(false)
@@ -300,21 +343,21 @@ describe WhiskeyDisk::Config do
300
343
  lambda { WhiskeyDisk::Config.configuration_file }.should.raise
301
344
  end
302
345
  end
303
-
304
- describe 'and no project name is specified in ENV["to"]' do
346
+
347
+ describe 'and no project name is specified in ENV["to"]' do
305
348
  it 'should return the path to a per-environment configuration file in the deploy/ directory under the project base path if it exists' do
306
349
  WhiskeyDisk::Config.stub!(:base_path).and_return('/path/to/project/config')
307
350
  File.stub!(:exists?).with('/path/to/project/config/deploy/staging.yml').and_return(true)
308
- WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/deploy/staging.yml'
351
+ WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/deploy/staging.yml'
309
352
  end
310
-
353
+
311
354
  it 'should return the path to a per-environment configuration file under the project base path if it exists' do
312
355
  WhiskeyDisk::Config.stub!(:base_path).and_return('/path/to/project/config')
313
356
  File.stub!(:exists?).with('/path/to/project/config/deploy/staging.yml').and_return(false)
314
357
  File.stub!(:exists?).with('/path/to/project/config/staging.yml').and_return(true)
315
- WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/staging.yml'
358
+ WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/staging.yml'
316
359
  end
317
-
360
+
318
361
  it 'should return the path to deploy.yml under the project base path' do
319
362
  WhiskeyDisk::Config.stub!(:base_path).and_return('/path/to/project/config')
320
363
  File.stub!(:exists?).with('/path/to/project/config/deploy/staging.yml').and_return(false)
@@ -343,37 +386,37 @@ describe WhiskeyDisk::Config do
343
386
  File.stub!(:exists?).with(@path).and_return(true)
344
387
  WhiskeyDisk::Config.configuration_file.should == @path
345
388
  end
346
-
389
+
347
390
  describe 'and a path which points to a directory is specified' do
348
391
  before do
349
392
  ENV['path'] = @path = CURRENT
350
393
  end
351
-
394
+
352
395
  describe 'and a project name is specified in ENV["to"]' do
353
396
  before do
354
397
  ENV['to'] = @env = 'foo:staging'
355
398
  end
356
-
399
+
357
400
  it 'should return the path to deploy/foo/<environment>.yml under the project base path if it exists' do
358
401
  WhiskeyDisk::Config.stub!(:base_path).and_return(@path)
359
402
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'foo', 'staging.yml')).and_return(true)
360
- WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'deploy', 'foo' ,'staging.yml')
403
+ WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'deploy', 'foo' ,'staging.yml')
361
404
  end
362
-
363
- it 'should return the path to deploy/foo.yml under the project base path if it exists' do
405
+
406
+ it 'should return the path to deploy/foo.yml under the project base path if it exists' do
364
407
  WhiskeyDisk::Config.stub!(:base_path).and_return(@path)
365
408
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'foo', 'staging.yml')).and_return(false)
366
409
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'foo.yml')).and_return(true)
367
410
  WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'deploy', 'foo.yml')
368
411
  end
369
-
412
+
370
413
  it 'should return the path to a per-environment configuration file under deploy/ in the path specified if that file exists' do
371
414
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'foo', 'staging.yml')).and_return(false)
372
415
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'foo.yml')).and_return(false)
373
416
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'staging.yml')).and_return(true)
374
417
  WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'deploy', 'staging.yml')
375
418
  end
376
-
419
+
377
420
  it 'should return the path to a per-environment configuration file in the path specified if that file exists' do
378
421
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'foo', 'staging.yml')).and_return(false)
379
422
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'foo.yml')).and_return(false)
@@ -381,7 +424,7 @@ describe WhiskeyDisk::Config do
381
424
  File.stub!(:exists?).with(File.join(@path, 'staging.yml')).and_return(true)
382
425
  WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'staging.yml')
383
426
  end
384
-
427
+
385
428
  it 'should return the path to deploy.yaml in the path specified if deploy.yml exists' do
386
429
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'foo', 'staging.yml')).and_return(false)
387
430
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'foo.yml')).and_return(false)
@@ -390,7 +433,7 @@ describe WhiskeyDisk::Config do
390
433
  File.stub!(:exists?).with(File.join(@path, 'deploy.yml')).and_return(true)
391
434
  WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'deploy.yml')
392
435
  end
393
-
436
+
394
437
  it 'should fail if no per-environment configuration file nor deploy.yml exists in the path specified' do
395
438
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'foo', 'staging.yml')).and_return(false)
396
439
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'foo.yml')).and_return(false)
@@ -401,25 +444,25 @@ describe WhiskeyDisk::Config do
401
444
  end
402
445
  end
403
446
 
404
- describe 'and no project name is specified in ENV["to"]' do
447
+ describe 'and no project name is specified in ENV["to"]' do
405
448
  it 'should return the path to a per-environment configuration file under deploy/ in the path specified if that file exists' do
406
449
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'staging.yml')).and_return(true)
407
450
  WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'deploy', 'staging.yml')
408
451
  end
409
-
452
+
410
453
  it 'should return the path to a per-environment configuration file in the path specified if that file exists' do
411
454
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'staging.yml')).and_return(false)
412
455
  File.stub!(:exists?).with(File.join(@path, 'staging.yml')).and_return(true)
413
456
  WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'staging.yml')
414
457
  end
415
-
458
+
416
459
  it 'should return the path to deploy.yaml in the path specified if deploy.yml exists' do
417
460
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'staging.yml')).and_return(false)
418
461
  File.stub!(:exists?).with(File.join(@path, 'staging.yml')).and_return(false)
419
462
  File.stub!(:exists?).with(File.join(@path, 'deploy.yml')).and_return(true)
420
463
  WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'deploy.yml')
421
464
  end
422
-
465
+
423
466
  it 'should fail if no per-environment configuration file nor deploy.yml exists in the path specified' do
424
467
  File.stub!(:exists?).with(File.join(@path, 'deploy', 'staging.yml')).and_return(false)
425
468
  File.stub!(:exists?).with(File.join(@path, 'staging.yml')).and_return(false)
@@ -429,49 +472,49 @@ describe WhiskeyDisk::Config do
429
472
  end
430
473
  end
431
474
  end
432
-
475
+
433
476
  describe 'computing the base path for the project' do
434
477
  before do
435
478
  @original_path = Dir.pwd
436
479
  ENV['path'] = @path = nil
437
480
  end
438
-
481
+
439
482
  after do
440
483
  Dir.chdir(@original_path)
441
- end
442
-
484
+ end
485
+
443
486
  describe 'and a "path" environment variable is set' do
444
487
  before do
445
488
  ENV['path'] = @path = CURRENT
446
489
  Dir.chdir(CURRENT)
447
490
  end
448
-
491
+
449
492
  it 'should return the path set in the "path" environment variable' do
450
- WhiskeyDisk::Config.base_path.should == @path
493
+ WhiskeyDisk::Config.base_path.should == @path
451
494
  end
452
-
495
+
453
496
  it 'should leave the current working path the same as when the base path lookup started' do
454
497
  WhiskeyDisk::Config.base_path
455
498
  Dir.pwd.should == CURRENT
456
499
  end
457
500
  end
458
-
501
+
459
502
  describe 'and there is no Rakefile in the root path to the current directory' do
460
503
  before do
461
504
  Dir.chdir(CURRENT)
462
505
  WhiskeyDisk::Config.stub!(:contains_rakefile?).and_return(false)
463
506
  end
464
-
507
+
465
508
  it 'should return the config directory under the current directory if there is no Rakefile along the root path to the current directory' do
466
509
  WhiskeyDisk::Config.base_path.should == File.join(CURRENT, 'config')
467
510
  end
468
-
511
+
469
512
  it 'should leave the current working path the same as when the base path lookup started' do
470
513
  WhiskeyDisk::Config.base_path
471
514
  Dir.pwd.should == CURRENT
472
515
  end
473
- end
474
-
516
+ end
517
+
475
518
  describe 'and there is a Rakefile in the root path to the current directory' do
476
519
  before do
477
520
  @top = ::File.expand_path(File.join(CURRENT, '..', '..'))
@@ -479,15 +522,15 @@ describe WhiskeyDisk::Config do
479
522
  WhiskeyDisk::Config.stub!(:contains_rakefile?).with(@top).and_return(true)
480
523
  Dir.chdir(CURRENT)
481
524
  end
482
-
525
+
483
526
  it 'return the config directory in the nearest enclosing path with a Rakefile along the root path to the current directory' do
484
527
  WhiskeyDisk::Config.base_path.should == File.join(@top, 'config')
485
528
  end
486
-
529
+
487
530
  it 'should leave the current working path the same as when the base path lookup started' do
488
531
  WhiskeyDisk::Config.base_path
489
532
  Dir.pwd.should == CURRENT
490
533
  end
491
534
  end
492
535
  end
493
- end
536
+ end
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.5.2"
8
+ s.version = "0.5.3"
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-09-06}
12
+ s.date = %q{2010-09-07}
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: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 2
10
- version: 0.5.2
9
+ - 3
10
+ version: 0.5.3
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-09-06 00:00:00 -05:00
18
+ date: 2010-09-07 00:00:00 -05:00
19
19
  default_executable: wd
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency