Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make use of Rake's '--all' command-line option where available

Remove assertions about hidden tasks, because they may or may not be supported
by the version of Rake installed.
  • Loading branch information...
commit 15f9206611dff08f1a2c6245a00343a94e85d78d 1 parent 329ae58
@njonsson authored
Showing with 34 additions and 84 deletions.
  1. +7 −1 README.markdown
  2. +1 −1  cape.gemspec
  3. +1 −1  features/dsl/each_rake_task/with_defined_namespace_argument.feature
  4. +1 −1  features/dsl/each_rake_task/with_defined_task_argument.feature
  5. +2 −2 features/dsl/each_rake_task/with_undefined_argument.feature
  6. +2 −7 features/dsl/each_rake_task/without_arguments.feature
  7. +1 −1  features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_defined_namespace_argument.feature
  8. +1 −1  features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_defined_task_argument.feature
  9. +1 −1  features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_undefined_argument.feature
  10. +2 −20 features/dsl/mirror_rake_tasks/inside_capistrano_namespace/without_arguments.feature
  11. +1 −1  features/dsl/mirror_rake_tasks/with_defined_namespace_argument.feature
  12. +2 −20 features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options_arguments_and_environment_variables.feature
  13. +1 −1  features/dsl/mirror_rake_tasks/with_defined_task_argument.feature
  14. +1 −1  features/dsl/mirror_rake_tasks/with_undefined_argument.feature
  15. +2 −3 features/dsl/mirror_rake_tasks/with_valid_options_argument.feature
  16. +2 −18 features/dsl/mirror_rake_tasks/without_arguments.feature
  17. +1 −1  features/dsl/rake_executable.feature
  18. +3 −1 lib/cape/capistrano.rb
  19. +2 −2 lib/cape/rake.rb
View
8 README.markdown
@@ -273,7 +273,13 @@ Note that Cape statements must be contained in a `Cape` block.
## Known issues
-**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’ ”)").
+**A Rake task that lacks a description can be mirrored or enumerated only if Rake v0.9.3 or newer is installed.** Older versions of Rake did not support enumerating such tasks. You may want to make Rake v0.9.3 a dependency of your project:
+
+ # Gemfile
+
+ source 'http://rubygems.org'
+
+ gem 'rake', '>= 0.9.3'
**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.
View
2  cape.gemspec
@@ -32,6 +32,6 @@ Gem::Specification.new do |s|
s.add_development_dependency 'aruba', '~> 0'
s.add_development_dependency 'capistrano', '~> 2'
- s.add_development_dependency 'rake', '~> 0'
+ s.add_development_dependency 'rake'
s.add_development_dependency 'rspec', '~> 2'
end
View
2  features/dsl/each_rake_task/with_defined_namespace_argument.feature
@@ -21,7 +21,7 @@ Feature: The #each_rake_task DSL method with an argument of a defined namespace
end
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should not contain:
"""
View
2  features/dsl/each_rake_task/with_defined_task_argument.feature
@@ -20,7 +20,7 @@ Feature: The #each_rake_task DSL method with an argument of a defined task
end
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should contain:
"""
View
4 features/dsl/each_rake_task/with_undefined_argument.feature
@@ -20,7 +20,7 @@ Feature: The #each_rake_task DSL method with an undefined argument
end
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should not contain:
"""
@@ -44,7 +44,7 @@ Feature: The #each_rake_task DSL method with an undefined argument
end
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should not contain:
"""
View
9 features/dsl/each_rake_task/without_arguments.feature
@@ -4,7 +4,7 @@ Feature: The #each_rake_task DSL method without arguments
As a developer using Cape,
I want to use the Cape DSL.
- Scenario: enumerate all non-hidden Rake tasks
+ Scenario: enumerate all Rake tasks
Given a full-featured Rakefile
And a Capfile with:
"""
@@ -21,7 +21,7 @@ Feature: The #each_rake_task DSL method without arguments
end
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should contain:
"""
@@ -80,8 +80,3 @@ Feature: The #each_rake_task DSL method without arguments
Parameters: ["an_arg1", "an_arg2", "an_arg3"]
Description: "My task with three arguments"
"""
- And the output should not contain:
- """
-
- Name: "hidden_task"
- """
View
2  features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_defined_namespace_argument.feature
@@ -14,7 +14,7 @@ Feature: The #mirror_rake_tasks DSL method, inside a Capistrano namespace, with
end
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should not contain "cap ns:with_period"
And the output should contain:
"""
View
2  features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_defined_task_argument.feature
@@ -14,7 +14,7 @@ Feature: The #mirror_rake_tasks DSL method, inside a Capistrano namespace, with
end
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should contain:
"""
cap ns:with_period # Ends with period.
View
2  features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_undefined_argument.feature
@@ -14,7 +14,7 @@ Feature: The #mirror_rake_tasks DSL method, inside a Capistrano namespace, with
end
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should not contain "cap ns:with_period"
Scenario: do not mirror Rake task 'with_period'
View
22 features/dsl/mirror_rake_tasks/inside_capistrano_namespace/without_arguments.feature
@@ -4,7 +4,7 @@ Feature: The #mirror_rake_tasks DSL method, inside a Capistrano namespace, witho
As a developer using Cape,
I want to use the Cape DSL.
- Scenario: mirror all non-hidden Rake tasks
+ Scenario: mirror all Rake tasks
Given a full-featured Rakefile
And a Capfile with:
"""
@@ -14,7 +14,7 @@ Feature: The #mirror_rake_tasks DSL method, inside a Capistrano namespace, witho
end
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should contain:
"""
cap ns:with_period # Ends with period.
@@ -51,7 +51,6 @@ Feature: The #mirror_rake_tasks DSL method, inside a Capistrano namespace, witho
"""
cap ns:with_three_args # My task with three arguments.
"""
- And the output should not contain "cap hidden_task"
Scenario: mirror Rake task 'with_period' with its description
Given a full-featured Rakefile
@@ -289,20 +288,3 @@ Feature: The #mirror_rake_tasks DSL method, inside a Capistrano namespace, witho
"""
-
- Scenario: do not mirror Rake task 'hidden_task'
- Given a full-featured Rakefile
- And a Capfile with:
- """
- namespace :ns do
- Cape do |cape|
- cape.mirror_rake_tasks
- end
- end
- """
- When I run `cap -e ns:hidden_task`
- Then the output should contain exactly:
- """
- The task `ns:hidden_task' does not exist.
-
- """
View
2  features/dsl/mirror_rake_tasks/with_defined_namespace_argument.feature
@@ -12,7 +12,7 @@ Feature: The #mirror_rake_tasks DSL method with an argument of a defined namespa
mirror_rake_tasks 'my_namespace'
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should not contain "cap with_period"
And the output should contain:
"""
View
22 ...es/dsl/mirror_rake_tasks/with_defined_task_and_valid_options_arguments_and_environment_variables.feature
@@ -4,7 +4,7 @@ Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and
As a developer using Cape,
I want to use the Cape DSL.
- Scenario: mirror all non-hidden Rake tasks with the specified options
+ Scenario: mirror all Rake tasks with the specified options
Given a full-featured Rakefile
And a Capfile with:
"""
@@ -14,7 +14,7 @@ Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and
end
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should contain:
"""
cap with_period # Ends with period.
@@ -51,7 +51,6 @@ Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and
"""
cap with_three_args # My task with three arguments.
"""
- And the output should not contain "cap hidden_task"
Scenario: mirror Rake task 'with_period' with its description
Given a full-featured Rakefile
@@ -222,20 +221,3 @@ Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and
* 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\""
`with_three_args' is only run for servers matching {:roles=>:app}, but no servers matched
"""
-
- Scenario: do not mirror Rake task 'hidden_task'
- Given a full-featured Rakefile
- And a Capfile with:
- """
- Cape do
- mirror_rake_tasks :roles => :app do |env|
- env['RAILS_ENV'] = rails_env
- end
- end
- """
- When I run `cap -e hidden_task`
- Then the output should contain exactly:
- """
- The task `hidden_task' does not exist.
-
- """
View
2  features/dsl/mirror_rake_tasks/with_defined_task_argument.feature
@@ -12,7 +12,7 @@ Feature: The #mirror_rake_tasks DSL method with an argument of a defined task
mirror_rake_tasks 'with_period'
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should contain:
"""
cap with_period # Ends with period.
View
2  features/dsl/mirror_rake_tasks/with_undefined_argument.feature
@@ -12,7 +12,7 @@ Feature: The #mirror_rake_tasks DSL method with an undefined argument
mirror_rake_tasks 'this_does_not_exist'
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should not contain "cap with_period"
Scenario: do not mirror Rake task 'with_period'
View
5 features/dsl/mirror_rake_tasks/with_valid_options_argument.feature
@@ -4,7 +4,7 @@ Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and
As a developer using Cape,
I want to use the Cape DSL.
- Scenario: mirror all non-hidden Rake tasks with the specified options
+ Scenario: mirror all Rake tasks with the specified options
Given a full-featured Rakefile
And a Capfile with:
"""
@@ -12,7 +12,7 @@ Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and
mirror_rake_tasks :roles => :app
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should contain:
"""
cap with_period # Ends with period.
@@ -49,7 +49,6 @@ Feature: The #mirror_rake_tasks DSL method with arguments of a defined task and
"""
cap with_three_args # My task with three arguments.
"""
- And the output should not contain "cap hidden_task"
Scenario: mirror Rake task 'with_period' with its description
Given a full-featured Rakefile
View
20 features/dsl/mirror_rake_tasks/without_arguments.feature
@@ -4,7 +4,7 @@ Feature: The #mirror_rake_tasks DSL method without arguments
As a developer using Cape,
I want to use the Cape DSL.
- Scenario: mirror all non-hidden Rake tasks
+ Scenario: mirror all Rake tasks
Given a full-featured Rakefile
And a Capfile with:
"""
@@ -12,7 +12,7 @@ Feature: The #mirror_rake_tasks DSL method without arguments
mirror_rake_tasks
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should contain:
"""
cap with_period # Ends with period.
@@ -49,7 +49,6 @@ Feature: The #mirror_rake_tasks DSL method without arguments
"""
cap with_three_args # My task with three arguments.
"""
- And the output should not contain "cap hidden_task"
Scenario: mirror Rake task 'with_period' with its description
Given a full-featured Rakefile
@@ -318,18 +317,3 @@ Feature: The #mirror_rake_tasks DSL method without arguments
* 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\",]"
"""
-
- Scenario: do not mirror Rake task 'hidden_task'
- Given a full-featured Rakefile
- And a Capfile with:
- """
- Cape do
- mirror_rake_tasks
- end
- """
- When I run `cap -e hidden_task`
- Then the output should contain exactly:
- """
- The task `hidden_task' does not exist.
-
- """
View
2  features/dsl/rake_executable.feature
@@ -24,7 +24,7 @@ Feature: The #local_rake_executable and #remote_rake_executable DSL attributes
end
end
"""
- When I run `cap -T`
+ When I run `cap -vT`
Then the output should contain:
"""
We changed the local Rake executable to "echo \"rake this-comes-from-overridden-rake # This comes from overridden Rake\" #"
View
4 lib/cape/capistrano.rb
@@ -64,7 +64,9 @@ def build_capistrano_description(task, options, &block)
return nil unless task[:description]
description = [task[:description]]
- description << '.' unless task[:description].end_with?('.')
+ unless task[:description].empty? || task[:description].end_with?('.')
+ description << '.'
+ end
unless (parameters = Array(task[:parameters])).empty?
noun = Util.pluralize('variable', parameters.length)
View
4 lib/cape/rake.rb
@@ -59,7 +59,7 @@ def each_task(task_expression=nil)
task_expression = task_expression ?
::Regexp.escape(task_expression.to_s) :
'.+?'
- regexp = /^rake (#{task_expression}(?::.+?)?)(?:\[(.+?)\])?\s+# (.+)/
+ regexp = /^rake (#{task_expression}(?::.+?)?)(?:\[(.+?)\])?\s+#\s*(.*)/
each_output_line do |l|
unless (matches = l.chomp.match(regexp))
next
@@ -143,7 +143,7 @@ def each_output_line(&block)
end
def fetch_output
- `#{local_executable} --tasks 2>/dev/null`
+ `#{local_executable} --all --tasks 2>/dev/null || #{local_executable} --tasks 2>/dev/null`
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.