mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Make sure 'desc' applies to the next defined task, in any namespace.
git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@6697 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
7c4d877349
commit
845f0d2ca6
3 changed files with 18 additions and 17 deletions
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Make sure 'desc' applies to the next defined task, in any namespace. [Jamis Buck]
|
||||||
|
|
||||||
* Fix shell so that servers for a task are correctly discovered. [Jamis Buck]
|
* Fix shell so that servers for a task are correctly discovered. [Jamis Buck]
|
||||||
|
|
||||||
* Added before(), after(), and on() callback creation methods. [Jamis Buck]
|
* Added before(), after(), and on() callback creation methods. [Jamis Buck]
|
||||||
|
|
|
@ -29,7 +29,6 @@ module Capistrano
|
||||||
initialize_without_namespaces(*args)
|
initialize_without_namespaces(*args)
|
||||||
@tasks = {}
|
@tasks = {}
|
||||||
@namespaces = {}
|
@namespaces = {}
|
||||||
@next_description = nil
|
|
||||||
end
|
end
|
||||||
private :initialize_with_namespaces
|
private :initialize_with_namespaces
|
||||||
|
|
||||||
|
@ -46,6 +45,14 @@ module Capistrano
|
||||||
@next_description = text
|
@next_description = text
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the value set by the last, pending "desc" call. If +reset+ is
|
||||||
|
# not false, the value will be reset immediately afterwards.
|
||||||
|
def next_description(reset=false)
|
||||||
|
@next_description
|
||||||
|
ensure
|
||||||
|
@next_description = nil if reset
|
||||||
|
end
|
||||||
|
|
||||||
# Open a namespace in which to define new tasks. If the namespace was
|
# Open a namespace in which to define new tasks. If the namespace was
|
||||||
# defined previously, it will be reopened, otherwise a new namespace
|
# defined previously, it will be reopened, otherwise a new namespace
|
||||||
# will be created for the given name.
|
# will be created for the given name.
|
||||||
|
@ -84,8 +91,7 @@ module Capistrano
|
||||||
raise ArgumentError, "defining a task named `#{name}' would shadow an existing #{thing} with that name"
|
raise ArgumentError, "defining a task named `#{name}' would shadow an existing #{thing} with that name"
|
||||||
end
|
end
|
||||||
|
|
||||||
tasks[name] = TaskDefinition.new(name, self, {:desc => @next_description}.merge(options), &block)
|
tasks[name] = TaskDefinition.new(name, self, {:desc => next_description(:reset)}.merge(options), &block)
|
||||||
@next_description = nil
|
|
||||||
|
|
||||||
if !task_already_defined
|
if !task_already_defined
|
||||||
metaclass = class << self; self; end
|
metaclass = class << self; self; end
|
||||||
|
@ -177,6 +183,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
include Capistrano::Configuration::Namespaces
|
include Capistrano::Configuration::Namespaces
|
||||||
|
undef :desc, :next_description
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,20 +54,6 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
|
||||||
assert @config.namespaces[:outer].namespaces[:inner].tasks.key?(:nested)
|
assert @config.namespaces[:outer].namespaces[:inner].tasks.key?(:nested)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_pending_desc_should_disappear_when_enclosing_namespace_terminates
|
|
||||||
@config.namespace :outer do
|
|
||||||
desc "Something to say"
|
|
||||||
end
|
|
||||||
|
|
||||||
@config.namespace :outer do
|
|
||||||
task :testing do
|
|
||||||
puts "testing"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_nil @config.namespaces[:outer].tasks[:testing].options[:desc]
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_pending_desc_should_apply_only_to_immediately_subsequent_task
|
def test_pending_desc_should_apply_only_to_immediately_subsequent_task
|
||||||
@config.desc "A description"
|
@config.desc "A description"
|
||||||
@config.task(:testing) { puts "foo" }
|
@config.task(:testing) { puts "foo" }
|
||||||
|
@ -76,6 +62,12 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
|
||||||
assert_nil @config.tasks[:another].options[:desc]
|
assert_nil @config.tasks[:another].options[:desc]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_pending_desc_should_apply_only_to_next_task_in_any_namespace
|
||||||
|
@config.desc "A description"
|
||||||
|
@config.namespace(:outer) { task(:testing) { puts "foo" } }
|
||||||
|
assert_equal "A description", @config.namespaces[:outer].tasks[:testing].options[:desc]
|
||||||
|
end
|
||||||
|
|
||||||
def test_defining_task_without_block_should_raise_error
|
def test_defining_task_without_block_should_raise_error
|
||||||
assert_raises(ArgumentError) do
|
assert_raises(ArgumentError) do
|
||||||
@config.task(:testing)
|
@config.task(:testing)
|
||||||
|
|
Loading…
Reference in a new issue