Class: Opticon::Notifier::Email
- Inherits:
-
Object
- Object
- Opticon::Notifier::Email
- Defined in:
- lib/opticon/notifier.rb
Overview
Sends failure notifications via email to the given list of recipients.
To set options, configure Opticon::Mailer the same way you would any other ActionMailer. For example, to send via SMTP:
Opticon::Mailer.delivery_method = :smtp
Opticon::Mailer.server_settings = {
:address => "mail.nowhere.foo",
:domain => "nowhere.foo",
:authentication => :login,
:user_name => "mail_user",
:password => "topsecret"
}
Constant Summary collapse
- @@resend =
The same notification will not be resent over and over again unless this is set to true.
false
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#recipients ⇒ Object
Returns the value of attribute recipients.
Instance Method Summary collapse
-
#initialize(recipients, options = {}) ⇒ Email
constructor
A new instance of Email.
- #notify(failures) ⇒ Object
Constructor Details
#initialize(recipients, options = {}) ⇒ Email
Returns a new instance of Email.
28 29 30 31 |
# File 'lib/opticon/notifier.rb', line 28 def initialize(recipients, = {}) @recipients = recipients @from = [:from] || "opticon@#{ENV['HOSTNAME']}" end |
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
22 23 24 |
# File 'lib/opticon/notifier.rb', line 22 def from @from end |
#recipients ⇒ Object
Returns the value of attribute recipients.
22 23 24 |
# File 'lib/opticon/notifier.rb', line 22 def recipients @recipients end |
Instance Method Details
#notify(failures) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/opticon/notifier.rb', line 33 def notify(failures) failures = [failures] unless failures.kind_of? Array failures_by_uri = {} failures.each do |f| failures_by_uri[f.uri] ||= [] failures_by_uri[f.uri] << f end if ARGV.include?("-v") puts "Notifying #{recipients.inspect} about #{failures.size} failures:" failures.each{|f| puts " #{f.}"} end failures_by_uri.each do |uri, failures| Opticon::Mailer.deliver_failure_notification( uri, failures.collect{|f| f.}.join("\n"), recipients, from ) end end |