Class: Capistrano::TaskDefinition

### Home Classes Methods

### In Files

- lib/capistrano/task_definition.rb

### Parent

Object

### Methods

- ::new
- #brief_description
- #continue_on_error?
- #description
- #fully_qualified_name
- #name=

### Files

- help.txt

### Class/Module Index

Quicksearch

- Capistrano
- Capistrano::CLI
- Capistrano::CLI::Execute
- Capistrano::CLI::Execute::ClassMethods
- Capistrano::CLI::Help
- Capistrano::CLI::Options
- Capistrano::CLI::Options::ClassMethods
- Capistrano::CLI::UI
- Capistrano::CLI::UI::ClassMethods
- Capistrano::Callback
- Capistrano::Command
- Capistrano::Command::Tree
- Capistrano::Command::Tree::Branch
- Capistrano::Command::Tree::ConditionBranch
- Capistrano::Command::Tree::ConditionBranch::Evaluator
- Capistrano::Command::Tree::ElseBranch
- Capistrano::Configuration
- Capistrano::Configuration::Actions
- Capistrano::Configuration::Actions::FileTransfer
- Capistrano::Configuration::Actions::Inspect
- Capistrano::Configuration::Actions::Invocation
- Capistrano::Configuration::Actions::Invocation::ClassMethods
- Capistrano::Configuration::AliasTask
- Capistrano::Configuration::Callbacks
- Capistrano::Configuration::Connections
- Capistrano::Configuration::Execution
- Capistrano::Configuration::Loading
- Capistrano::Configuration::Loading::ClassMethods
- Capistrano::Configuration::LogFormatters
- Capistrano::Configuration::Namespaces
- Capistrano::Configuration::Namespaces::Namespace
- Capistrano::Configuration::Roles
- Capistrano::Configuration::Servers
- Capistrano::Configuration::Variables
- Capistrano::Deploy
- Capistrano::Deploy::Dependencies
- Capistrano::Deploy::LocalDependency
- Capistrano::Deploy::RemoteDependency
- Capistrano::Deploy::SCM
- Capistrano::Deploy::SCM::Accurev
- Capistrano::Deploy::SCM::Accurev::InternalRevision
- Capistrano::Deploy::SCM::Base
- Capistrano::Deploy::SCM::Base::LocalProxy
- Capistrano::Deploy::SCM::Bzr
- Capistrano::Deploy::SCM::Cvs
- Capistrano::Deploy::SCM::Darcs
- Capistrano::Deploy::SCM::Git
- Capistrano::Deploy::SCM::Mercurial
- Capistrano::Deploy::SCM::None
- Capistrano::Deploy::SCM::Perforce
- Capistrano::Deploy::SCM::Subversion
- Capistrano::Deploy::Strategy
- Capistrano::Deploy::Strategy::Base
- Capistrano::Deploy::Strategy::Checkout
- Capistrano::Deploy::Strategy::Copy
- Capistrano::Deploy::Strategy::Export
- Capistrano::Deploy::Strategy::Remote
- Capistrano::Deploy::Strategy::RemoteCache
- Capistrano::Deploy::Strategy::UnsharedRemoteCache
- Capistrano::ProcCallback
- Capistrano::Processable
- Capistrano::Processable::SessionAssociation
- Capistrano::RemoteError
- Capistrano::Role
- Capistrano::Role::DynamicServerList
- Capistrano::SSH
- Capistrano::ServerDefinition
- Capistrano::Shell
- Capistrano::TaskCallback
- Capistrano::TaskDefinition
- Capistrano::Transfer
- Capistrano::Transfer::SFTPTransferWrapper
- Capistrano::Version
- Kernel
- Object
- String

No matching classes.

# Capistrano::TaskDefinition

### Attributes

body[R]
desc[R]
max_hosts[R]
name[R]
namespace[R]
on_error[R]
options[R]

### Public Class Methods

new(name, namespace, options={}, &block) click to toggle source

    # File lib/capistrano/task_definition.rb, line 9
    def initialize(name, namespace, options={}, &block)
      @name, @namespace, @options = name, namespace, options
      @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
    end

### Public Instance Methods

brief_description(max_length=nil) click to toggle source

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 60
    def brief_description(max_length=nil)
      brief = description[/^.*?\.(?=\s|$)/] || description

      if max_length && brief.length > max_length
        brief = brief[0,max_length-3] + "..."
      end

      brief
    end

continue_on_error?() click to toggle source

Indicates whether the task wants to continue, even if a server has failed previously

    # File lib/capistrano/task_definition.rb, line 72
    def continue_on_error?
      @on_error == :continue
    end

description(rebuild=false) click to toggle source

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 37
    def description(rebuild=false)
      @description = nil if rebuild
      @description ||= begin
        description = @desc || ""

        indentation = description[/\A\s+/]
        if indentation
          reformatted_description = ""
          description.strip.each_line do |line|
            line = line.chomp.sub(/^#{indentation}/, "")
            line = line.gsub(/#{indentation}\s*/, " ") if line[/^\S/]
            reformatted_description << line << "\n"
          end
          description = reformatted_description
        end

        description.strip.gsub(/\r\n/, "\n")
      end
    end

fully_qualified_name() click to toggle source

Returns the task's fully-qualified name, including the namespace

    # File lib/capistrano/task_definition.rb, line 19
    def fully_qualified_name
      @fully_qualified_name ||= begin
        if namespace.default_task == self
          namespace.fully_qualified_name
        else
          [namespace.fully_qualified_name, name].compact.join(":")
        end
      end
    end

name=(value) click to toggle source

    # File lib/capistrano/task_definition.rb, line 29
    def name=(value)
      raise ArgumentError, "expected a valid task name" if !value.respond_to?(:to_sym)
      @name = value.to_sym
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.