mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Remove before_
and after_
tasks.
This commit is contained in:
parent
bd6ff00fa3
commit
510b1660f2
3 changed files with 9 additions and 24 deletions
|
@ -156,7 +156,7 @@ module Capistrano
|
||||||
return nil if parent.nil?
|
return nil if parent.nil?
|
||||||
return tasks[DEFAULT_TASK]
|
return tasks[DEFAULT_TASK]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the tasks in this namespace as an array of TaskDefinition
|
# Returns the tasks in this namespace as an array of TaskDefinition
|
||||||
# objects. If a non-false parameter is given, all tasks in all
|
# objects. If a non-false parameter is given, all tasks in all
|
||||||
# namespaces under this namespace will be returned as well.
|
# namespaces under this namespace will be returned as well.
|
||||||
|
|
|
@ -1,22 +1,18 @@
|
||||||
require 'capistrano/server_definition'
|
require 'capistrano/server_definition'
|
||||||
|
|
||||||
module Capistrano
|
module Capistrano
|
||||||
# Represents the definition of a single task.
|
|
||||||
class TaskDefinition
|
class TaskDefinition
|
||||||
|
|
||||||
attr_reader :name, :namespace, :options, :body, :desc, :on_error, :max_hosts
|
attr_reader :name, :namespace, :options, :body, :desc, :on_error, :max_hosts
|
||||||
|
|
||||||
def initialize(name, namespace, options={}, &block)
|
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
|
@name, @namespace, @options = name, namespace, options
|
||||||
@desc = @options.delete(:desc)
|
@desc = @options.delete(:desc)
|
||||||
@on_error = options.delete(:on_error)
|
@on_error = options.delete(:on_error)
|
||||||
@max_hosts = options[:max_hosts] && options[:max_hosts].to_i
|
@max_hosts = options[:max_hosts] && options[:max_hosts].to_i
|
||||||
@body = block or raise ArgumentError, "a task requires a block"
|
@body = block or raise ArgumentError, "a task requires a block"
|
||||||
@servers = nil
|
@servers = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the task's fully-qualified name, including the namespace
|
# Returns the task's fully-qualified name, including the namespace
|
||||||
|
@ -29,7 +25,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def name=(value)
|
def name=(value)
|
||||||
raise ArgumentError, "expected a valid task name" if !value.respond_to?(:to_sym)
|
raise ArgumentError, "expected a valid task name" if !value.respond_to?(:to_sym)
|
||||||
@name = value.to_sym
|
@name = value.to_sym
|
||||||
|
@ -76,5 +72,6 @@ module Capistrano
|
||||||
def continue_on_error?
|
def continue_on_error?
|
||||||
@on_error == :continue
|
@on_error == :continue
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,18 +38,6 @@ class TaskDefinitionTest < Test::Unit::TestCase
|
||||||
assert_raises(ArgumentError) { task.name = ['invalid task name'] }
|
assert_raises(ArgumentError) { task.name = ['invalid task name'] }
|
||||||
end
|
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
|
def test_fqn_in_namespace_when_default_should_be_namespace_fqn
|
||||||
ns = namespace("outer:inner")
|
ns = namespace("outer:inner")
|
||||||
task = new_task(:default, ns)
|
task = new_task(:default, ns)
|
||||||
|
|
Loading…
Reference in a new issue