class AvoDeploy::Deployment

Attributes

config[RW]
log[R]
task_manager[RW]

Public Class Methods

configure(&block) click to toggle source

Configures the deployment

@param block [Block] configuration block

# File lib/avodeploy/deployment.rb, line 39
def self.configure(&block)
  @instance = self.instance
  @instance.config.instance_eval(&block)

  # @todo check config and throw exception
end
instance() click to toggle source

Returns the deployment instance

@return [Deployment] the deployment instance

# File lib/avodeploy/deployment.rb, line 49
def self.instance
  if @instance.nil?
    @instance = self.new
  end

  @instance
end
new() click to toggle source

Initializes the deployment

# File lib/avodeploy/deployment.rb, line 27
def initialize
  @stages = {}
  @task_manager = AvoDeploy::Task::TaskManager.new
  @config = AvoDeploy::Config.new

  log_file = File.open('avodeploy.log', 'a')
  @log = ::Logger.new AvoDeploy::MultiIO.new(STDOUT, log_file)
end

Public Instance Methods

handle_abort(e) click to toggle source

Handles exceptions

@param e [Exception] the exception to handle

# File lib/avodeploy/deployment.rb, line 60
def handle_abort(e)
  if log.level == ::Logger::DEBUG
    raise e
  elsif e.class != SystemExit
    @log.error e.message.red
    @log.info 'cleaning up...'

    task_manager.invoke_task_oneshot(:cleanup_local)
  end
  
  Kernel.exit(true)
end