class AvoDeploy::Task::Task

Attributes

block[RW]
desc[RW]
name[RW]
remote_except[RW]
remote_only[RW]
scope[RW]
visibility[RW]

Public Class Methods

from_task_block(name, options, &block) click to toggle source

Creates a new task from a task block in the deployment configuration process

@param name [Symbol] name of the task @param options [Hash] command options @param block [Block] code block of the task @return [Task] the task instance

# File lib/avodeploy/task/task.rb, line 37
def self.from_task_block(name, options, &block)
  instance = self.new

  instance.name = name
  instance.block = block

  instance.scope = :local

  if options.has_key?(:scope) && options[:scope] == :remote
    instance.scope = :remote
  end

  instance.visibility = :public

  if options.has_key?(:visibility) && options[:visibility] == :private
    instance.visibility = :private
  end

  if options.has_key?(:desc)
    instance.desc = options[:desc]
  end

  if options.has_key?(:only)
    instance.remote_only = options[:only]
  end

  if options.has_key?(:except)
    instance.remote_except = options[:except]
  end

  instance
end

Public Instance Methods

invoke(env, options = {}) click to toggle source

Runs the code of a task

@param env [TaskExecutionEnvironment] the environment to invoke the task in @param options [Hash] a hash contining additional options @return [mixed] result of the code block

# File lib/avodeploy/task/task.rb, line 75
def invoke(env, options = {})
  raise ArgumentError 'env must be a valid TaskExecutionEnvironment' unless env.kind_of?(TaskExecutionEnvironment)

  avo = AvoDeploy::Deployment.instance

  avo.log.debug "Running task #{@name}"

  env.instance_eval(&@block)
end