Class: Fyi::Notifier::Email
- Inherits:
-
Object
- Object
- Fyi::Notifier::Email
- Defined in:
- lib/fyi/notifiers/email.rb
Overview
Emails the results of command execution via SMTP.
By default only failures are emailed.
Instance Method Summary collapse
-
#initialize(options) ⇒ Email
constructor
Options you may supply:.
- #notify(command, result, duration, output, error = '', host = '') ⇒ Object
Constructor Details
#initialize(options) ⇒ Email
Options you may supply:
from
: the from address to
: the to address on_success
: whether to notify when the command succeeded.
Optional. Defaults to false.
on_failure
: whether to notify when the command failed.
Optional. Defaults to true.
smtp
: you should supply SMTP config options under this key.
SMTP config options are whatever Mail takes. github.com/mikel/mail/blob/master/lib/mail/network/delivery_methods/smtp.rb
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fyi/notifiers/email.rb', line 22 def initialize @from = ['from'] @to = ['to'] @on_success = ['on_success'] # Notify of failures by default. @on_failure = .has_key?('on_failure') ? ['on_failure'] : true smtp = symbolize_keys(['smtp']) Mail.defaults do delivery_method :smtp, smtp end end |
Instance Method Details
#notify(command, result, duration, output, error = '', host = '') ⇒ Object
35 36 37 |
# File 'lib/fyi/notifiers/email.rb', line 35 def notify command, result, duration, output, error = '', host = '' send_email(command, result, duration, output, error, host) if should_notify?(result) end |