Class: Airbrussh::Capistrano::Tasks

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Airbrussh::Colors
Defined in:
lib/airbrussh/capistrano/tasks.rb

Overview

Encapsulates the rake behavior that integrates Airbrussh into Capistrano. This class allows us to easily test the behavior using a mock to stand in for the Capistrano DSL.

See airbrussh/capistrano.rb to see how this class is used.

Constant Summary

Constants included from Airbrussh::Colors

Airbrussh::Colors::ANSI_CODES

Instance Method Summary collapse

Constructor Details

#initialize(dsl, stderr = $stderr, config = Airbrussh.configuration) ⇒ Tasks

Returns a new instance of Tasks.



22
23
24
25
26
27
28
29
# File 'lib/airbrussh/capistrano/tasks.rb', line 22

def initialize(dsl, stderr=$stderr, config=Airbrussh.configuration)
  @dsl = dsl
  @stderr = stderr
  @config = config

  configure
  warn_if_missing_dsl
end

Instance Method Details

#deploy_failedObject

Behavior for the rake deploy:failed task.



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/airbrussh/capistrano/tasks.rb', line 38

def deploy_failed
  return unless airbrussh_is_being_used?
  return if log_file.nil?

  error_line
  error_line(red("** DEPLOY FAILED"))
  error_line(yellow("** Refer to #{log_file} for details. "\
                    "Here are the last 20 lines:"))
  error_line
  error_line(tail_log_file)
end

#load_defaultsObject

Behavior for the rake load:defaults task.



32
33
34
35
# File 'lib/airbrussh/capistrano/tasks.rb', line 32

def load_defaults
  require "sshkit/formatter/airbrussh"
  set :format, :airbrussh
end