Class: Blankpad::DeploymentNotifier::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/blankpad/deployment_notifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(capistrano, deployer) ⇒ Message

Returns a new instance of Message.



61
62
63
64
# File 'lib/blankpad/deployment_notifier.rb', line 61

def initialize(capistrano, deployer)
  @capistrano = capistrano
  @deployer = deployer
end

Instance Attribute Details

#capistranoObject (readonly)

Returns the value of attribute capistrano.



59
60
61
# File 'lib/blankpad/deployment_notifier.rb', line 59

def capistrano
  @capistrano
end

Instance Method Details

#bodyObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/blankpad/deployment_notifier.rb', line 75

def body
  body = <<EOM
#{@deployer} has deployed revision #{capistrano[:current_revision]} of #{capistrano[:application]} to #{capistrano[:stage]}

Application: #{capistrano[:application]}
Stage: #{capistrano[:stage]}
Repository: #{capistrano[:repository]}
Current Revision: #{capistrano[:current_revision]}
Previous revision: #{capistrano[:previous_revision]}
EOM
  body = capistrano[:message] + "\n\n#{body}" if capistrano[:message]

  body
end

#headersObject



66
67
68
69
70
71
72
73
# File 'lib/blankpad/deployment_notifier.rb', line 66

def headers
  {
    "Subject"  => "[DEPLOY] #{capistrano[:application]} #{capistrano[:stage]}",
    "From"     => DeploymentNotifier.from,
    "To"       => DeploymentNotifier.recipients.join(", "),
    "X-Mailer" => "DeploymentNotifier"
  }
end

#to_sObject



90
91
92
# File 'lib/blankpad/deployment_notifier.rb', line 90

def to_s
  headers.collect { |key, value| "#{key}: #{value}" }.join("\n") << "\n\n#{body}"
end