Class: Blankpad::DeploymentNotifier::Mailer

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

Overview

Responsible for taking the e-mail to send, and sending it using the remote server’s sendmail command.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(capistrano) ⇒ Mailer

Returns a new instance of Mailer.



35
36
37
# File 'lib/blankpad/deployment_notifier.rb', line 35

def initialize(capistrano)
  @capistrano = capistrano
end

Instance Attribute Details

#capistranoObject (readonly)

Returns the value of attribute capistrano.



33
34
35
# File 'lib/blankpad/deployment_notifier.rb', line 33

def capistrano
  @capistrano
end

Instance Method Details

#deliver!Object

Delivers a notification e-mail



40
41
42
# File 'lib/blankpad/deployment_notifier.rb', line 40

def deliver!
  capistrano.run(delivery_command)
end

#delivery_commandObject

Constructs the final command which will be sent run on the server.



45
46
47
# File 'lib/blankpad/deployment_notifier.rb', line 45

def delivery_command
  "echo -en '#{message}' | #{mta_command}"
end

#messageObject



53
54
55
# File 'lib/blankpad/deployment_notifier.rb', line 53

def message
  Message.new(capistrano, Blankpad::DeploymentNotifier.deployer).to_s.gsub(/\n/, "\\n")
end

#mta_commandObject



49
50
51
# File 'lib/blankpad/deployment_notifier.rb', line 49

def mta_command
  "/usr/sbin/sendmail #{DeploymentNotifier.recipients.join(" ")}"
end