Class: CapGun::Mailer

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
lib/cap_gun_reloaded.rb

Overview

This mailer is configured with a capistrano variable called “cap_gun_email_envelope”

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.load_mailer_config(cap) ⇒ Object

Raises:

  • (ArgumentError)


36
37
38
39
40
41
# File 'lib/cap_gun_reloaded.rb', line 36

def self.load_mailer_config(cap)
 raise ArgumentError, "You must define ActionMailer settings in 'cap_gun_action_mailer_config'" unless cap.cap_gun_action_mailer_config
 raise ArgumentError, "Need at least one recipient." if !cap.exists?(:cap_gun_email_envelope) || cap[:cap_gun_email_envelope][:recipients].blank?

 ActionMailer::Base.smtp_settings = cap.cap_gun_action_mailer_config
end

Instance Method Details

#deployment_notification(capistrano) ⇒ Object

Grab the options for emailing from capistrano (should be set in your deploy file)

Valid options:

:recipients     (required) an array or string of email address(es) that should get notifications
:from           the sender of the notification, defaults to [email protected]
:email_prefix   subject prefix, defaults to [DEPLOY]


49
50
51
52
53
54
55
56
57
# File 'lib/cap_gun_reloaded.rb', line 49

def deployment_notification(capistrano)
  presenter = Presenter.new(capistrano)
  
  content_type "text/plain"
  from         presenter.from
  recipients   presenter.recipients
  subject      presenter.subject
  body         presenter.body
end