diff --git a/lib/capistrano/configuration/namespaces.rb b/lib/capistrano/configuration/namespaces.rb index d95cb304..e7b9f1d4 100644 --- a/lib/capistrano/configuration/namespaces.rb +++ b/lib/capistrano/configuration/namespaces.rb @@ -156,7 +156,7 @@ module Capistrano return nil if parent.nil? return tasks[DEFAULT_TASK] end - + # Returns the tasks in this namespace as an array of TaskDefinition # objects. If a non-false parameter is given, all tasks in all # namespaces under this namespace will be returned as well. diff --git a/lib/capistrano/task_definition.rb b/lib/capistrano/task_definition.rb index de7e45dc..fb9a288b 100644 --- a/lib/capistrano/task_definition.rb +++ b/lib/capistrano/task_definition.rb @@ -1,22 +1,18 @@ require 'capistrano/server_definition' module Capistrano - # Represents the definition of a single task. + class TaskDefinition + attr_reader :name, :namespace, :options, :body, :desc, :on_error, :max_hosts def initialize(name, namespace, options={}, &block) - - if name.to_s =~ /^(?:before_|after_)/ - Kernel.warn("[Deprecation Warning] Naming tasks with before_ and after_ is deprecated, please see the new before() and after() methods. (Offending task name was #{name})") - end - @name, @namespace, @options = name, namespace, options - @desc = @options.delete(:desc) - @on_error = options.delete(:on_error) + @desc = @options.delete(:desc) + @on_error = options.delete(:on_error) @max_hosts = options[:max_hosts] && options[:max_hosts].to_i - @body = block or raise ArgumentError, "a task requires a block" - @servers = nil + @body = block or raise ArgumentError, "a task requires a block" + @servers = nil end # Returns the task's fully-qualified name, including the namespace @@ -29,7 +25,7 @@ module Capistrano end end end - + def name=(value) raise ArgumentError, "expected a valid task name" if !value.respond_to?(:to_sym) @name = value.to_sym @@ -76,5 +72,6 @@ module Capistrano def continue_on_error? @on_error == :continue end + end end diff --git a/test/task_definition_test.rb b/test/task_definition_test.rb index 85c7b9c8..4b47421e 100644 --- a/test/task_definition_test.rb +++ b/test/task_definition_test.rb @@ -38,18 +38,6 @@ class TaskDefinitionTest < Test::Unit::TestCase assert_raises(ArgumentError) { task.name = ['invalid task name'] } end - def test_deprecation_warning_on_method_name_beginning_with_before_underscore - name = "before_test" - Kernel.expects(:warn).with("[Deprecation Warning] Naming tasks with before_ and after_ is deprecated, please see the new before() and after() methods. (Offending task name was #{name})") - new_task(name) - end - - def test_deprecation_warning_on_method_name_beginning_with_after_underscore - name = "after_test" - Kernel.expects(:warn).with("[Deprecation Warning] Naming tasks with before_ and after_ is deprecated, please see the new before() and after() methods. (Offending task name was #{name})") - new_task(name) - end - def test_fqn_in_namespace_when_default_should_be_namespace_fqn ns = namespace("outer:inner") task = new_task(:default, ns)