cape 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/.yardopts CHANGED
@@ -1 +1 @@
1
- --file MIT-LICENSE.markdown --file History.markdown --no-private --protected --title "Cape"
1
+ --file History.markdown --file License.markdown --no-private --protected --title "Cape"
data/Gemfile CHANGED
@@ -13,7 +13,7 @@ group :doc do
13
13
  end
14
14
 
15
15
  group :tooling do
16
- gem 'guard-rspec', '~> 0'
16
+ gem 'guard-rspec', '~> 2'
17
17
  if RUBY_PLATFORM =~ /darwin/i
18
18
  gem 'rb-fsevent', '~> 0', :require => false
19
19
  end
data/Guardfile CHANGED
@@ -1,4 +1,4 @@
1
- guard 'rspec', :cli => '--color', :version => 2 do
1
+ guard :rspec, :cli => '--color --debugger' do
2
2
  # Run the corresponding spec (or all specs) when code changes.
3
3
  watch( %r{^lib/(.+)\.rb$} ) do |match|
4
4
  corresponding_spec = "spec/#{match[1]}_spec.rb"
@@ -1,5 +1,9 @@
1
1
  # Version history for the _Cape_ project
2
2
 
3
+ ## <a name="v1.5.0"></a>v1.5.0, Tue 10/09/2012
4
+
5
+ * Automatically detect and use Bundler when running Rake
6
+
3
7
  ## <a name="v1.4.0"></a>v1.4.0, Mon 2/06/2012
4
8
 
5
9
  * Cache the Rake task list to improve Capistrano responsiveness
@@ -29,26 +29,28 @@
29
29
  <hNNBNBh=(. / \ `
30
30
  ..
31
31
 
32
- # [<img align="right" src="https://gemnasium.com/njonsson/cape.png" title="Gemnasium build status" />](http://gemnasium.com/njonsson/cape) [<img align="right" src="https://secure.travis-ci.org/njonsson/cape.png?branch=master" title="Travis CI build status" />](http://travis-ci.org/njonsson/cape) Cape
32
+ # [<img align="right" src="https://codeclimate.com/badge.png" title="Code Climate" />](http://codeclimate.com/github/njonsson/cape) [<img align="right" src="https://gemnasium.com/njonsson/cape.png" title="Gemnasium build status" />](http://gemnasium.com/njonsson/cape) [<img align="right" src="https://secure.travis-ci.org/njonsson/cape.png?branch=master" title="Travis CI build status" />](http://travis-ci.org/njonsson/cape) Cape
33
33
 
34
34
  If
35
35
 
36
36
  * **You use [Capistrano](http://capify.org)** to deploy your application, and
37
- * **You have [Rake](http://rake.rubyforge.org) tasks you want to run remotely** — but you don’t want to hand-code Capistrano recipes for each Rake task —
37
+ * **You have [Rake](http://rake.rubyforge.org) tasks that you want to execute remotely** — but you don’t want to hand-code Capistrano recipes for each Rake task —
38
38
 
39
39
  Then
40
40
 
41
- * **You can use the [Cape](http://github.com/njonsson/cape) DSL** within Capistrano recipes to dynamically add recipes for your application’s Rake tasks, and
42
- * **You can run your Rake tasks on your deployed servers,** friction-free, and look like a superhero. _[cue fanfare]_
41
+ * **You can use the [Cape](http://njonsson.github.com/cape) DSL** within Capistrano recipes to dynamically add recipes for your application’s Rake tasks, and
42
+ * **You can execute your Rake tasks on your deployed servers,** friction-free, and look like a superhero. _[cue fanfare]_
43
43
 
44
44
  ## Features
45
45
 
46
46
  * **Mirror Rake tasks** as Capistrano recipes, optionally filtered by namespace or name
47
47
  * **Embed Rake tasks** in Capistrano namespaces
48
48
  * **Pass arguments** to Rake tasks by setting environment variables with the same names
49
- * **Override the default executables** for local and remote Rake installations (`/usr/bin/env rake` is the default)
49
+ * **Specify the Rake executable** for local and remote Rake installations
50
50
  * **Enumerate Rake tasks** for your own purposes
51
51
 
52
+ See what’s changed lately by reading the [project history](http://github.com/njonsson/cape/blob/master/History.markdown).
53
+
52
54
  ## Installation — get your Cape on
53
55
 
54
56
  Install [the RubyGem](http://rubygems.org/gems/cape "Cape at RubyGems.org").
@@ -61,7 +63,7 @@ Or you may want to make Cape a dependency of your project by using [Bundler](htt
61
63
 
62
64
  source 'http://rubygems.org'
63
65
 
64
- gem 'cape'
66
+ gem 'cape', '~> 1'
65
67
 
66
68
  ## Examples
67
69
 
@@ -89,7 +91,7 @@ Rake lists these tasks in the expected fashion.
89
91
 
90
92
  ### Simply mirror all Rake tasks as Capistrano recipes
91
93
 
92
- Add the following to your Capistrano recipes. Note that Cape statements must be executed within a `Cape` block.
94
+ Add the following to your Capistrano recipes. Note that Cape statements must be contained in a `Cape` block.
93
95
 
94
96
  # config/deploy.rb
95
97
 
@@ -137,7 +139,7 @@ On remote computers, via Capistrano:
137
139
 
138
140
  $ cap bag_leaves PAPER_OR_PLASTIC=plastic
139
141
  * executing `bag_leaves'
140
- * executing "cd /path/to/currently/deployed/version/of/your/app && /usr/bin/env rake bag_leaves[plastic]"
142
+ * executing "cd /path/to/currently/deployed/version/of/your/app && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake bag_leaves[plastic]"
141
143
  servers: ["your.server.name"]
142
144
  [your.server.name] executing command
143
145
  ** [out :: your.server.name] (in /path/to/currently/deployed/version/of/your/app)
@@ -147,7 +149,7 @@ On remote computers, via Capistrano:
147
149
 
148
150
  ### Mirror some Rake tasks, but not others
149
151
 
150
- Cape lets you filter the Rake tasks to be mirrored. Note that Cape statements must be executed within a `Cape` block.
152
+ Cape lets you filter the Rake tasks to be mirrored. Note that Cape statements must be contained in a `Cape` block.
151
153
 
152
154
  # config/deploy.rb
153
155
 
@@ -161,7 +163,7 @@ Cape lets you filter the Rake tasks to be mirrored. Note that Cape statements mu
161
163
 
162
164
  ### Mirror Rake tasks that require Capistrano recipe options and/or environment variables
163
165
 
164
- Cape lets you specify options used for defining Capistrano recipes. You can also specify remote environment variables to be set when running Rake tasks. Note that Cape statements must be executed within a `Cape` block.
166
+ Cape lets you specify options used for defining Capistrano recipes. You can also specify remote environment variables to be set when executing Rake tasks. Note that Cape statements must be contained in a `Cape` block.
165
167
 
166
168
  # config/deploy.rb
167
169
 
@@ -185,19 +187,32 @@ The above is equivalent to the following manually-defined Capistrano recipes.
185
187
 
186
188
  # These translations to Capistrano are just for illustration.
187
189
 
190
+ RAKE = '/usr/bin/env ' +
191
+ '`' +
192
+ '/usr/bin/env bundle check >/dev/null 2>&1; ' +
193
+ 'case $? in ' +
194
+ # Exit code 0: bundle is defined and installed
195
+ # Exit code 1: bundle is defined but not installed
196
+ '0|1 ) ' +
197
+ 'echo bundle exec ' +
198
+ ';; ' +
199
+ 'esac' +
200
+ '` ' +
201
+ 'rake'
202
+
188
203
  task :routes, :roles => :app do
189
- run "cd #{current_path} && /usr/bin/env rake routes"
204
+ run "cd #{current_path} && #{RAKE} routes"
190
205
  end
191
206
 
192
207
  namespace :db do
193
208
  task :migrate, :roles => :app do
194
- run "cd #{current_path} && /usr/bin/env rake db:migrate RAILS_ENV=#{rails_env}"
209
+ run "cd #{current_path} && #{RAKE} db:migrate RAILS_ENV=#{rails_env}"
195
210
  end
196
211
  end
197
212
 
198
213
  ### Mirror Rake tasks into a Capistrano namespace
199
214
 
200
- Cape plays friendly with the Capistrano DSL for organizing Rake tasks in Capistrano namespaces. Note that Cape statements must be executed within a `Cape` block.
215
+ Cape plays friendly with the Capistrano DSL for organizing Rake tasks in Capistrano namespaces. Note that Cape statements must be contained in a `Cape` block.
201
216
 
202
217
  # config/deploy.rb
203
218
 
@@ -212,7 +227,7 @@ Cape plays friendly with the Capistrano DSL for organizing Rake tasks in Capistr
212
227
 
213
228
  ### Iterate over available Rake tasks
214
229
 
215
- Cape lets you enumerate Rake tasks, optionally filtering them by task name or namespace. Note that Cape statements must be executed within a `Cape` block.
230
+ Cape lets you enumerate Rake tasks, optionally filtering them by task name or namespace. Note that Cape statements must be contained in a `Cape` block.
216
231
 
217
232
  # config/deploy.rb
218
233
 
@@ -235,15 +250,21 @@ Cape lets you enumerate Rake tasks, optionally filtering them by task name or na
235
250
 
236
251
  ### Configure Rake execution
237
252
 
238
- Cape lets you specify how Rake should be executed on the local computer and on remote computers. Note that Cape statements must be executed within a `Cape` block.
253
+ Cape lets you specify how Rake should be run on the local computer and on remote computers. But the default behavior is most likely just right for your needs:
254
+
255
+ * It detects whether Bundler is installed on the computer
256
+ * It detects whether the project uses Bundler to manage its dependencies
257
+ * It runs Rake via Bundler if the above conditions are true; otherwise, it runs Rake directly
258
+
259
+ Note that Cape statements must be contained in a `Cape` block.
239
260
 
240
261
  # config/deploy.rb
241
262
 
242
263
  require 'cape'
243
264
 
244
- # Configure Cape to execute Rake via Bundler, both locally and remotely.
245
- Cape.local_rake_executable = '/usr/bin/env bundle exec rake'
246
- Cape.remote_rake_executable = '/usr/bin/env bundle exec rake'
265
+ # Configure Cape never to run Rake via Bundler, neither locally nor remotely.
266
+ Cape.local_rake_executable = '/usr/bin/env rake'
267
+ Cape.remote_rake_executable = '/usr/bin/env rake'
247
268
 
248
269
  Cape do
249
270
  # Create Capistrano recipes for all Rake tasks.
@@ -252,7 +273,11 @@ Cape lets you specify how Rake should be executed on the local computer and on r
252
273
 
253
274
  ## Known issues
254
275
 
255
- For now, only Rake tasks that have descriptions can be mirrored or enumerated.
276
+ **A Rake task that lacks a description cannot be mirrored or enumerated.** This is pending [an enhancement to Rake](http://github.com/jimweirich/rake/pull/99 "Rake pull request #99 (“Add ‘--include-hidden-tasks’ option to enhance ‘-T’ and ‘-D’ ”)").
277
+
278
+ **A Rake task whose name collides with a Ruby method cannot be mirrored.** For example, the name of [Rails](http://rubyonrails.org)’s _db:fixtures:load_ task collides with the Ruby Core Library’s [_Kernel::load_ method](http://ruby-doc.org/core/Kernel.html#method-i-load) because that method is mixed into all objects. If you try to mirror _db:fixtures:load_, Capistrano will raise an exception. There is [a questionable workaround](http://github.com/njonsson/cape/issues/7#issuecomment-5632718 "Comment on Cape issue #7 (“defining a task named ‘load’ would shadow an existing method with that name (ArgumentError)”)") for this.
279
+
280
+ **A Rake task is always executed in the Capistrano deployment’s _current_path_.** You may need to execute a task under _release_path_ or another remote filesystem location, but this is not possible at present. [Discuss](http://github.com/njonsson/cape/issues/9 "Cape issue #9 (“Cape Always Runs the Mirrorred Rake Tasks Under $current_path”)") this.
256
281
 
257
282
  ## Contributing
258
283
 
@@ -262,4 +287,4 @@ Your patches are welcome, and you will receive attribution here for good stuff.
262
287
 
263
288
  ## License
264
289
 
265
- Released under the [MIT License](http://github.com/njonsson/cape/blob/master/MIT-LICENSE.markdown).
290
+ Released under the [MIT License](http://github.com/njonsson/cape/blob/master/License.markdown).
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.platform = Gem::Platform::RUBY
16
16
  s.authors = ['Nils Jonsson']
17
17
  s.email = %w(cape@nilsjonsson.com)
18
- s.homepage = 'http://github.com/njonsson/cape'
18
+ s.homepage = 'http://njonsson.github.com/cape'
19
19
  s.license = 'MIT'
20
20
 
21
21
  s.rubyforge_project = 'cape'
@@ -90,7 +90,7 @@ Feature: The #mirror_rake_tasks DSL method, inside a Capistrano namespace, witho
90
90
  Then the output should contain:
91
91
  """
92
92
  * executing `ns:with_period'
93
- * executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_period"
93
+ * executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period"
94
94
  """
95
95
 
96
96
  Scenario: mirror Rake task 'without_period' with its description
@@ -197,7 +197,7 @@ Feature: The #mirror_rake_tasks DSL method, inside a Capistrano namespace, witho
197
197
  Then the output should contain:
198
198
  """
199
199
  * executing `ns:my_namespace'
200
- * executing "cd /path/to/current/deployed/application && /usr/bin/env rake my_namespace"
200
+ * executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake my_namespace"
201
201
  """
202
202
 
203
203
  Scenario: mirror Rake task 'my_namespace:in_a_namespace' with its description
@@ -91,7 +91,7 @@ Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and
91
91
  Then the output should contain:
92
92
  """
93
93
  * executing `with_period'
94
- * executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_period RAILS_ENV=\"production\""
94
+ * executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period RAILS_ENV=\"production\""
95
95
  `with_period' is only run for servers matching {:roles=>:app}, but no servers matched
96
96
  """
97
97
 
@@ -112,7 +112,7 @@ Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and
112
112
  Then the output should contain:
113
113
  """
114
114
  * executing `with_period'
115
- * executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_period"
115
+ * executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period"
116
116
  `with_period' is only run for servers matching {:roles=>:app}, but no servers matched
117
117
  """
118
118
 
@@ -133,7 +133,7 @@ Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and
133
133
  Then the output should contain:
134
134
  """
135
135
  * executing `with_period'
136
- * executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_period"
136
+ * executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period"
137
137
  `with_period' is only run for servers matching {:roles=>:app}, but no servers matched
138
138
  """
139
139
 
@@ -198,7 +198,7 @@ Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and
198
198
  Then the output should contain:
199
199
  """
200
200
  * executing `with_three_args'
201
- * executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_three_args[\"a value for an_arg1\",\"a value for an_arg2\",\"a value for an_arg3\"] RAILS_ENV=\"production\""
201
+ * executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_three_args[\"a value for an_arg1\",\"a value for an_arg2\",\"a value for an_arg3\"] RAILS_ENV=\"production\""
202
202
  `with_three_args' is only run for servers matching {:roles=>:app}, but no servers matched
203
203
  """
204
204
 
@@ -219,7 +219,7 @@ Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and
219
219
  Then the output should contain:
220
220
  """
221
221
  * executing `with_three_args'
222
- * executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_three_args[,\"a value for an_arg2\",] RAILS_ENV=\"production\""
222
+ * executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_three_args[,\"a value for an_arg2\",] RAILS_ENV=\"production\""
223
223
  `with_three_args' is only run for servers matching {:roles=>:app}, but no servers matched
224
224
  """
225
225
 
@@ -85,6 +85,6 @@ Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and
85
85
  Then the output should contain:
86
86
  """
87
87
  * executing `with_period'
88
- * executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_period"
88
+ * executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period"
89
89
  `with_period' is only run for servers matching {:roles=>:app}, but no servers matched
90
90
  """
@@ -84,7 +84,7 @@ Feature: The #mirror_rake_tasks DSL method without arguments
84
84
  Then the output should contain:
85
85
  """
86
86
  * executing `with_period'
87
- * executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_period"
87
+ * executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period"
88
88
  """
89
89
 
90
90
  Scenario: mirror Rake task 'without_period' with its description
@@ -181,7 +181,7 @@ Feature: The #mirror_rake_tasks DSL method without arguments
181
181
  Then the output should contain:
182
182
  """
183
183
  * executing `my_namespace'
184
- * executing "cd /path/to/current/deployed/application && /usr/bin/env rake my_namespace"
184
+ * executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake my_namespace"
185
185
  """
186
186
 
187
187
  Scenario: mirror Rake task 'my_namespace:in_a_namespace' with its description
@@ -236,7 +236,7 @@ Feature: The #mirror_rake_tasks DSL method without arguments
236
236
  Then the output should contain:
237
237
  """
238
238
  * executing `my_namespace:my_nested_namespace:in_a_nested_namespace'
239
- * executing "cd /path/to/current/deployed/application && /usr/bin/env rake my_namespace:my_nested_namespace:in_a_nested_namespace"
239
+ * executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake my_namespace:my_nested_namespace:in_a_nested_namespace"
240
240
  """
241
241
 
242
242
  Scenario: mirror Rake task 'with_two_args' with its description
@@ -297,7 +297,7 @@ Feature: The #mirror_rake_tasks DSL method without arguments
297
297
  Then the output should contain:
298
298
  """
299
299
  * executing `with_three_args'
300
- * executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_three_args[\"a value for an_arg1\",\"a value for an_arg2\",\"a value for an_arg3\"]"
300
+ * executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_three_args[\"a value for an_arg1\",\"a value for an_arg2\",\"a value for an_arg3\"]"
301
301
 
302
302
  """
303
303
 
@@ -315,7 +315,7 @@ Feature: The #mirror_rake_tasks DSL method without arguments
315
315
  Then the output should contain:
316
316
  """
317
317
  * executing `with_three_args'
318
- * executing "cd /path/to/current/deployed/application && /usr/bin/env rake with_three_args[,\"a value for an_arg2\",]"
318
+ * executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_three_args[,\"a value for an_arg2\",]"
319
319
 
320
320
  """
321
321
 
@@ -31,7 +31,7 @@ Feature: The #local_rake_executable and #remote_rake_executable DSL attributes
31
31
  """
32
32
  And the output should contain:
33
33
  """
34
- We left the remote Rake executable as "/usr/bin/env rake"
34
+ We left the remote Rake executable as "/usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake"
35
35
  """
36
36
  And the output should contain:
37
37
  """
@@ -61,7 +61,7 @@ Feature: The #local_rake_executable and #remote_rake_executable DSL attributes
61
61
  """
62
62
  And the output should contain:
63
63
  """
64
- We left the local Rake executable as "/usr/bin/env rake"
64
+ We left the local Rake executable as "/usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake"
65
65
  """
66
66
  And the output should contain:
67
67
  """
@@ -217,6 +217,7 @@ module Cape
217
217
 
218
218
  protected
219
219
 
220
+ # Returns an abstraction of the Rake installation and available tasks.
220
221
  def rake
221
222
  @rake ||= Rake.new
222
223
  end
@@ -3,8 +3,23 @@ module Cape
3
3
  # An abstraction of the Rake installation and available tasks.
4
4
  class Rake
5
5
 
6
- # The default command used to run Rake.
7
- DEFAULT_EXECUTABLE = '/usr/bin/env rake'.freeze
6
+ # The default command used to run Rake. We use `bundle check` to detect the
7
+ # presence of Bundler and a Bundler configuration. If Bundler is installed
8
+ # on the computer and configured, we prepend `rake` with `bundle exec`.
9
+ DEFAULT_EXECUTABLE = (
10
+ '/usr/bin/env ' +
11
+ '`' +
12
+ '/usr/bin/env bundle check >/dev/null 2>&1; ' +
13
+ 'case $? in ' +
14
+ # Exit code 0: bundle is defined and installed
15
+ # Exit code 1: bundle is defined but not installed
16
+ '0|1 ) ' +
17
+ 'echo bundle exec ' +
18
+ ';; ' +
19
+ 'esac' +
20
+ '` ' +
21
+ 'rake'
22
+ ).freeze
8
23
 
9
24
  # Sets the command used to run Rake on remote computers.
10
25
  #
@@ -34,7 +49,6 @@ module Cape
34
49
  #
35
50
  # @param [String, Symbol] task_expression the full name of a task or
36
51
  # namespace to filter; optional
37
- # @param [Proc] block a block that processes tasks
38
52
  #
39
53
  # @yield [task] a block that processes tasks
40
54
  # @yieldparam [Hash] task metadata on a task
@@ -129,7 +143,7 @@ module Cape
129
143
  end
130
144
 
131
145
  def fetch_output
132
- `#{local_executable} --tasks 2> /dev/null`
146
+ `#{local_executable} --tasks 2>/dev/null`
133
147
  end
134
148
  end
135
149
 
@@ -5,9 +5,9 @@ module Cape
5
5
 
6
6
  # Conditionally transforms the specified _noun_ into its plural form.
7
7
  #
8
- # @param [String] noun a singular noun
9
- # @param [Fixnum] count the quantity of _noun_; optional
10
- # @return [String] the plural of _noun_, unless _count_ is +1+
8
+ # @param [String] singular_noun a singular noun
9
+ # @param [Fixnum] count the quantity of _singular_noun_; optional
10
+ # @return [String] the plural of _singular_noun_, unless _count_ is +1+
11
11
  def self.pluralize(singular_noun, count=2)
12
12
  return singular_noun if count == 1
13
13
 
@@ -1,6 +1,6 @@
1
1
  module Cape
2
2
 
3
3
  # The version of Cape.
4
- VERSION = '1.4.0'
4
+ VERSION = '1.5.0'
5
5
 
6
6
  end
@@ -7,10 +7,8 @@ describe Cape::Capistrano do
7
7
  end
8
8
 
9
9
  describe 'with specified attributes' do
10
- subject {
11
- described_class.new :rake => 'I see you have the machine that goes "Bing!"'
12
- }
10
+ subject { described_class.new :rake => 'the specified value of #rake' }
13
11
 
14
- its(:rake) { should == 'I see you have the machine that goes "Bing!"' }
12
+ its(:rake) { should == 'the specified value of #rake' }
15
13
  end
16
14
  end
@@ -1,12 +1,12 @@
1
1
  require 'cape/core_ext/hash'
2
2
 
3
3
  describe Hash do
4
- describe '#slice' do
5
- it 'should return the expected Hash' do
6
- hash = {:foo => 'bar', :baz => 'qux', :quux => 'corge'}
7
- hash.slice(:baz, :quux).should == {:baz => 'qux', :quux => 'corge'}
4
+ subject { {:foo => 'bar', :baz => 'qux', :quux => 'corge'} }
8
5
 
9
- {}.slice(:foo).should == {}
6
+ describe '-- when sent #slice with keys that are present and those that are not --' do
7
+ it 'should return the expected subset hash' do
8
+ subject.slice(:baz, :fizzle, :quux).should == {:baz => 'qux',
9
+ :quux => 'corge'}
10
10
  end
11
11
  end
12
12
  end
@@ -1,7 +1,15 @@
1
1
  require 'cape/core_ext/symbol'
2
2
 
3
3
  describe Symbol do
4
- it 'should compare as expected to another Symbol' do
4
+ it '-- when sent #<=> with a lower symbol -- should return 1' do
5
5
  (:foo <=> :bar).should == 1
6
6
  end
7
+
8
+ it '-- when sent #<=> with a higher symbol -- should return -1' do
9
+ (:baz <=> :qux).should == -1
10
+ end
11
+
12
+ it '-- when sent #<=> with itself -- should return 0' do
13
+ (:quux <=> :quux).should == 0
14
+ end
7
15
  end
@@ -3,6 +3,7 @@ require 'cape/capistrano'
3
3
  require 'cape/core_ext/hash'
4
4
  require 'cape/core_ext/symbol'
5
5
  require 'cape/rake'
6
+ require ::File.expand_path('../../spec_helper', __FILE__)
6
7
 
7
8
  describe Cape::DSL do
8
9
  subject do
@@ -22,7 +23,7 @@ describe Cape::DSL do
22
23
  Cape::Rake. stub!(:new).and_return mock_rake
23
24
  end
24
25
 
25
- describe 'when sent #each_rake_task' do
26
+ describe '-- when sent #each_rake_task --' do
26
27
  def do_each_rake_task(&block)
27
28
  subject.each_rake_task(task_expression, &block)
28
29
  end
@@ -41,7 +42,7 @@ describe Cape::DSL do
41
42
  end
42
43
  end
43
44
 
44
- describe 'when sent #mirror_rake_tasks' do
45
+ describe '-- when sent #mirror_rake_tasks' do
45
46
  before :each do
46
47
  mock_rake.stub!(:each_task).and_yield({:name => task_expression})
47
48
  subject.stub! :raise_unless_capistrano
@@ -51,7 +52,7 @@ describe Cape::DSL do
51
52
  subject.mirror_rake_tasks(*arguments, &block)
52
53
  end
53
54
 
54
- describe 'with two scalar arguments' do
55
+ describe 'with two scalar arguments --' do
55
56
  specify do
56
57
  lambda {
57
58
  do_mirror_rake_tasks task_expression, task_expression
@@ -63,17 +64,17 @@ describe Cape::DSL do
63
64
 
64
65
  shared_examples_for 'a successful call' do |task_expression_in_use,
65
66
  options_in_use|
66
- it 'should collect Rake#each_task' do
67
+ specify 'by collecting Rake#each_task' do
67
68
  mock_rake.should_receive(:each_task).with task_expression_in_use
68
69
  do_mirror_rake_tasks
69
70
  end
70
71
 
71
- it 'should verify that Capistrano is in use' do
72
+ specify 'by verifying that Capistrano is in use' do
72
73
  subject.should_receive :raise_unless_capistrano
73
74
  do_mirror_rake_tasks
74
75
  end
75
76
 
76
- describe 'should Capistrano#define_rake_wrapper for Rake#each_task' do
77
+ describe 'by sending Capistrano#define_rake_wrapper for Rake#each_task' do
77
78
  specify 'with the expected task' do
78
79
  mock_capistrano.should_receive(:define_rake_wrapper).with do |task,
79
80
  named_arguments|
@@ -107,75 +108,75 @@ describe Cape::DSL do
107
108
  end
108
109
  end
109
110
 
110
- it 'should return itself' do
111
+ specify 'by returning itself' do
111
112
  do_mirror_rake_tasks.should == subject
112
113
  end
113
114
  end
114
115
 
115
- describe 'with one scalar argument, an options hash, and a block' do
116
+ describe 'with one scalar argument, an options hash, and a block --' do
116
117
  def do_mirror_rake_tasks
117
118
  super 'task:expression', :bar => :baz do |env|
118
119
  env['AN_ENV_VAR'] = 'an environment variable'
119
120
  end
120
121
  end
121
122
 
122
- it_should_behave_like 'a successful call', 'task:expression', :bar => :baz
123
+ should_behave_like 'a successful call', 'task:expression', :bar => :baz
123
124
  end
124
125
 
125
- describe 'with one scalar argument and an options hash' do
126
+ describe 'with one scalar argument and an options hash --' do
126
127
  def do_mirror_rake_tasks
127
128
  super 'task:expression', :bar => :baz
128
129
  end
129
130
 
130
- it_should_behave_like 'a successful call', 'task:expression', :bar => :baz
131
+ should_behave_like 'a successful call', 'task:expression', :bar => :baz
131
132
  end
132
133
 
133
- describe 'with an options hash and a block' do
134
+ describe 'with an options hash and a block --' do
134
135
  def do_mirror_rake_tasks
135
136
  super :bar => :baz do |env|
136
137
  env['AN_ENV_VAR'] = 'an environment variable'
137
138
  end
138
139
  end
139
140
 
140
- it_should_behave_like 'a successful call', nil, :bar => :baz
141
+ should_behave_like 'a successful call', nil, :bar => :baz
141
142
  end
142
143
 
143
- describe 'with an options hash' do
144
+ describe 'with an options hash --' do
144
145
  def do_mirror_rake_tasks
145
146
  super :bar => :baz
146
147
  end
147
148
 
148
- it_should_behave_like 'a successful call', nil, :bar => :baz
149
+ should_behave_like 'a successful call', nil, :bar => :baz
149
150
  end
150
151
 
151
- describe 'with one scalar argument and a block' do
152
+ describe 'with one scalar argument and a block --' do
152
153
  def do_mirror_rake_tasks
153
154
  super 'task:expression' do |env|
154
155
  env['AN_ENV_VAR'] = 'an environment variable'
155
156
  end
156
157
  end
157
158
 
158
- it_should_behave_like('a successful call', 'task:expression', {})
159
+ should_behave_like('a successful call', 'task:expression', {})
159
160
  end
160
161
 
161
- describe 'with one scalar argument' do
162
+ describe 'with one scalar argument --' do
162
163
  def do_mirror_rake_tasks
163
164
  super 'task:expression'
164
165
  end
165
166
 
166
- it_should_behave_like('a successful call', 'task:expression', {})
167
+ should_behave_like('a successful call', 'task:expression', {})
167
168
  end
168
169
 
169
- describe 'without arguments' do
170
+ describe 'without arguments --' do
170
171
  def do_mirror_rake_tasks
171
172
  super
172
173
  end
173
174
 
174
- it_should_behave_like('a successful call', nil, {})
175
+ should_behave_like('a successful call', nil, {})
175
176
  end
176
177
  end
177
178
 
178
- describe 'when sent #local_rake_executable' do
179
+ describe '-- when sent #local_rake_executable --' do
179
180
  before :each do
180
181
  mock_rake.stub!(:local_executable).and_return 'foo'
181
182
  end
@@ -190,7 +191,7 @@ describe Cape::DSL do
190
191
  end
191
192
  end
192
193
 
193
- describe 'when sent #remote_rake_executable' do
194
+ describe '-- when sent #remote_rake_executable --' do
194
195
  before :each do
195
196
  mock_rake.stub!(:remote_executable).and_return 'foo'
196
197
  end
@@ -2,14 +2,12 @@ require 'cape/rake'
2
2
 
3
3
  describe Cape::Rake do
4
4
  describe '::DEFAULT_EXECUTABLE' do
5
- subject { Cape::Rake::DEFAULT_EXECUTABLE }
6
-
7
- it { should == '/usr/bin/env rake' }
5
+ subject { described_class::DEFAULT_EXECUTABLE }
8
6
 
9
7
  it { should be_frozen }
10
8
  end
11
9
 
12
- describe '#==' do
10
+ describe '-- when sent #== --' do
13
11
  it('should recognize equivalent instances to be equal') {
14
12
  described_class.new.should == described_class.new
15
13
  }
@@ -23,22 +21,28 @@ describe Cape::Rake do
23
21
  }
24
22
  end
25
23
 
26
- describe 'without specified attributes' do
27
- its(:local_executable) { should == '/usr/bin/env rake' }
24
+ describe '-- without specified attributes --' do
25
+ its(:local_executable) { should == described_class::DEFAULT_EXECUTABLE }
28
26
 
29
- its(:remote_executable) { should == '/usr/bin/env rake' }
27
+ its(:remote_executable) { should == described_class::DEFAULT_EXECUTABLE }
30
28
  end
31
29
 
32
- describe 'with specified attributes' do
33
- subject { described_class.new :local_executable => 'And now for something',
34
- :remote_executable => 'completely different' }
30
+ describe '-- with specified attributes --' do
31
+ subject {
32
+ described_class.new :local_executable => 'the specified value of #local_executable',
33
+ :remote_executable => 'the specified value of #remote_executable'
34
+ }
35
35
 
36
- its(:local_executable) { should == 'And now for something' }
36
+ its(:local_executable) {
37
+ should == 'the specified value of #local_executable'
38
+ }
37
39
 
38
- its(:remote_executable) { should == 'completely different' }
40
+ its(:remote_executable) {
41
+ should == 'the specified value of #remote_executable'
42
+ }
39
43
  end
40
44
 
41
- describe 'caching: ' do
45
+ describe '-- with respect to caching --' do
42
46
  before :each do
43
47
  subject.stub!(:fetch_output).and_return output
44
48
  end
@@ -51,7 +55,7 @@ rake baz # baz
51
55
  end_output
52
56
  }
53
57
 
54
- describe '#each_task' do
58
+ describe 'when sent #each_task,' do
55
59
  it 'should build and use a cache' do
56
60
  subject.should_receive(:fetch_output).once.and_return output
57
61
  subject.each_task do |t|
@@ -85,7 +89,7 @@ rake baz # baz
85
89
  end
86
90
  end
87
91
 
88
- describe '#expire_cache!' do
92
+ describe 'when sent #expire_cache!,' do
89
93
  it 'should expire the cache' do
90
94
  subject.should_receive(:fetch_output).twice.and_return output
91
95
  subject.each_task do |t|
@@ -96,15 +100,15 @@ rake baz # baz
96
100
  end
97
101
  end
98
102
 
99
- describe '#local_executable=' do
100
- describe 'with the same value' do
103
+ describe 'when sent #local_executable=' do
104
+ describe 'with the same value,' do
101
105
  it 'should not expire the cache' do
102
106
  subject.should_not_receive :expire_cache!
103
107
  subject.local_executable = subject.local_executable
104
108
  end
105
109
  end
106
110
 
107
- describe 'with a different value' do
111
+ describe 'with a different value,' do
108
112
  it 'should expire the cache' do
109
113
  subject.should_receive(:expire_cache!).once
110
114
  subject.local_executable = subject.local_executable + ' foo'
@@ -10,7 +10,7 @@ describe Cape::Util do
10
10
  Cape::Util.pluralize('foo', 2).should == 'foos'
11
11
  end
12
12
 
13
- it "should not pluralize for a count of 1" do
13
+ it "should not pluralize 'foo' for a count of 1" do
14
14
  Cape::Util.pluralize('foo', 1).should == 'foo'
15
15
  end
16
16
 
@@ -1,5 +1,5 @@
1
1
  require 'cape/version'
2
2
 
3
- describe Cape::VERSION do
4
- it { should =~ /^\d+\.\d+\.\d+/ }
3
+ describe 'Cape::VERSION' do
4
+ specify { Cape::VERSION.should =~ /^\d+\.\d+\.\d+/ }
5
5
  end
@@ -0,0 +1,4 @@
1
+ RSpec.configure do |c|
2
+ c.alias_it_should_behave_like_to :should_behave_like,
3
+ 'should behave like'
4
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cape
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 1.4.0
10
+ version: 1.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nils Jonsson
@@ -15,12 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-06 00:00:00 Z
18
+ date: 2012-10-09 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: aruba
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
23
  none: false
25
24
  requirements:
26
25
  - - ~>
@@ -30,11 +29,11 @@ dependencies:
30
29
  - 0
31
30
  version: "0"
32
31
  type: :development
33
- version_requirements: *id001
32
+ requirement: *id001
33
+ prerelease: false
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: capistrano
36
- prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
37
  none: false
39
38
  requirements:
40
39
  - - ~>
@@ -44,11 +43,11 @@ dependencies:
44
43
  - 2
45
44
  version: "2"
46
45
  type: :development
47
- version_requirements: *id002
46
+ requirement: *id002
47
+ prerelease: false
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rake
50
- prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
50
+ version_requirements: &id003 !ruby/object:Gem::Requirement
52
51
  none: false
53
52
  requirements:
54
53
  - - ~>
@@ -58,11 +57,11 @@ dependencies:
58
57
  - 0
59
58
  version: "0"
60
59
  type: :development
61
- version_requirements: *id003
60
+ requirement: *id003
61
+ prerelease: false
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: rspec
64
- prerelease: false
65
- requirement: &id004 !ruby/object:Gem::Requirement
64
+ version_requirements: &id004 !ruby/object:Gem::Requirement
66
65
  none: false
67
66
  requirements:
68
67
  - - ~>
@@ -72,7 +71,8 @@ dependencies:
72
71
  - 2
73
72
  version: "2"
74
73
  type: :development
75
- version_requirements: *id004
74
+ requirement: *id004
75
+ prerelease: false
76
76
  description: |-
77
77
  Cape dynamically generates Capistrano recipes for Rake tasks.
78
78
  It provides a DSL for reflecting on Rake tasks and mirroring
@@ -94,7 +94,7 @@ files:
94
94
  - Gemfile
95
95
  - Guardfile
96
96
  - History.markdown
97
- - MIT-LICENSE.markdown
97
+ - License.markdown
98
98
  - README.markdown
99
99
  - Rakefile
100
100
  - cape.gemspec
@@ -132,7 +132,8 @@ files:
132
132
  - spec/cape/util_spec.rb
133
133
  - spec/cape/version_spec.rb
134
134
  - spec/cape_spec.rb
135
- homepage: http://github.com/njonsson/cape
135
+ - spec/spec_helper.rb
136
+ homepage: http://njonsson.github.com/cape
136
137
  licenses:
137
138
  - MIT
138
139
  post_install_message:
@@ -163,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
164
  requirements: []
164
165
 
165
166
  rubyforge_project: cape
166
- rubygems_version: 1.8.11
167
+ rubygems_version: 1.8.24
167
168
  signing_key:
168
169
  specification_version: 3
169
170
  summary: Dynamically generates Capistrano recipes for Rake tasks
@@ -193,4 +194,5 @@ test_files:
193
194
  - spec/cape/util_spec.rb
194
195
  - spec/cape/version_spec.rb
195
196
  - spec/cape_spec.rb
197
+ - spec/spec_helper.rb
196
198
  has_rdoc: true