Class | Capistrano::TaskDefinition |
In: |
lib/capistrano/task_definition.rb
lib/capistrano/task_definition.rb |
Parent: | Object |
Represents the definition of a single task.
body | [R] | |
body | [R] | |
desc | [R] | |
desc | [R] | |
max_hosts | [R] | |
max_hosts | [R] | |
name | [R] | |
name | [R] | |
namespace | [R] | |
namespace | [R] | |
on_error | [R] | |
on_error | [R] | |
options | [R] | |
options | [R] |
# File lib/capistrano/task_definition.rb, line 8 8: def initialize(name, namespace, options={}, &block) 9: @name, @namespace, @options = name, namespace, options 10: @desc = @options.delete(:desc) 11: @on_error = options.delete(:on_error) 12: @max_hosts = options[:max_hosts] && options[:max_hosts].to_i 13: @body = block or raise ArgumentError, "a task requires a block" 14: @servers = nil 15: end
# File lib/capistrano/task_definition.rb, line 8 8: def initialize(name, namespace, options={}, &block) 9: @name, @namespace, @options = name, namespace, options 10: @desc = @options.delete(:desc) 11: @on_error = options.delete(:on_error) 12: @max_hosts = options[:max_hosts] && options[:max_hosts].to_i 13: @body = block or raise ArgumentError, "a task requires a block" 14: @servers = nil 15: end
Returns the first sentence of the full description. If max_length is given, the result will be truncated if it is longer than max_length, and an ellipsis appended.
# File lib/capistrano/task_definition.rb, line 54 54: def brief_description(max_length=nil) 55: brief = description[/^.*?\.(?=\s|$)/] || description 56: 57: if max_length && brief.length > max_length 58: brief = brief[0,max_length-3] + "..." 59: end 60: 61: brief 62: end
Returns the first sentence of the full description. If max_length is given, the result will be truncated if it is longer than max_length, and an ellipsis appended.
# File lib/capistrano/task_definition.rb, line 54 54: def brief_description(max_length=nil) 55: brief = description[/^.*?\.(?=\s|$)/] || description 56: 57: if max_length && brief.length > max_length 58: brief = brief[0,max_length-3] + "..." 59: end 60: 61: brief 62: end
Indicates whether the task wants to continue, even if a server has failed previously
# File lib/capistrano/task_definition.rb, line 66 66: def continue_on_error? 67: @on_error == :continue 68: end
Indicates whether the task wants to continue, even if a server has failed previously
# File lib/capistrano/task_definition.rb, line 66 66: def continue_on_error? 67: @on_error == :continue 68: end
Returns the description for this task, with newlines collapsed and whitespace stripped. Returns the empty string if there is no description for this task.
# File lib/capistrano/task_definition.rb, line 31 31: def description(rebuild=false) 32: @description = nil if rebuild 33: @description ||= begin 34: description = @desc || "" 35: 36: indentation = description[/\A\s+/] 37: if indentation 38: reformatted_description = "" 39: description.strip.each_line do |line| 40: line = line.chomp.sub(/^#{indentation}/, "") 41: line = line.gsub(/#{indentation}\s*/, " ") if line[/^\S/] 42: reformatted_description << line << "\n" 43: end 44: description = reformatted_description 45: end 46: 47: description.strip.gsub(/\r\n/, "\n") 48: end 49: end
Returns the description for this task, with newlines collapsed and whitespace stripped. Returns the empty string if there is no description for this task.
# File lib/capistrano/task_definition.rb, line 31 31: def description(rebuild=false) 32: @description = nil if rebuild 33: @description ||= begin 34: description = @desc || "" 35: 36: indentation = description[/\A\s+/] 37: if indentation 38: reformatted_description = "" 39: description.strip.each_line do |line| 40: line = line.chomp.sub(/^#{indentation}/, "") 41: line = line.gsub(/#{indentation}\s*/, " ") if line[/^\S/] 42: reformatted_description << line << "\n" 43: end 44: description = reformatted_description 45: end 46: 47: description.strip.gsub(/\r\n/, "\n") 48: end 49: end
Returns the task‘s fully-qualified name, including the namespace
# File lib/capistrano/task_definition.rb, line 18 18: def fully_qualified_name 19: @fully_qualified_name ||= begin 20: if namespace.default_task == self 21: namespace.fully_qualified_name 22: else 23: [namespace.fully_qualified_name, name].compact.join(":") 24: end 25: end 26: end
Returns the task‘s fully-qualified name, including the namespace
# File lib/capistrano/task_definition.rb, line 18 18: def fully_qualified_name 19: @fully_qualified_name ||= begin 20: if namespace.default_task == self 21: namespace.fully_qualified_name 22: else 23: [namespace.fully_qualified_name, name].compact.join(":") 24: end 25: end 26: end