Skip to content
Browse files

Remove `before_` and `after_` tasks.

  • Loading branch information...
1 parent bd6ff00 commit 510b1660f29748e5af633994ae33647e169038de @leehambley leehambley committed Feb 19, 2012
Showing with 9 additions and 24 deletions.
  1. +1 −1 lib/capistrano/configuration/namespaces.rb
  2. +8 −11 lib/capistrano/task_definition.rb
  3. +0 −12 test/task_definition_test.rb
View
2 lib/capistrano/configuration/namespaces.rb
@@ -156,7 +156,7 @@ def default_task
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.
View
19 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 @@ def fully_qualified_name
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 @@ def brief_description(max_length=nil)
def continue_on_error?
@on_error == :continue
end
+
end
end
View
12 test/task_definition_test.rb
@@ -38,18 +38,6 @@ def test_raise_an_exception_when_task_names_can_not_be_converted
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)

0 comments on commit 510b166

Please sign in to comment.
Something went wrong with that request. Please try again.