class Nines::Notifier
Public Class Methods
new(contacts)
click to toggle source
# File lib/nines/notifier.rb, line 6 def initialize(contacts) @contacts = contacts end
Public Instance Methods
human_duration(seconds)
click to toggle source
# File lib/nines/notifier.rb, line 22 def human_duration(seconds) case when seconds < 60 then "#{seconds} sec" when seconds < 3600 then "#{seconds/60} min #{seconds%60} sec" when seconds < 86400 then "#{seconds/3600} hr #{seconds%3600/60} min #{seconds%60} sec" else "#{seconds/86400} day #{seconds%86400/3600} hr #{seconds%3600/60} min #{seconds%60} sec" end end
notify!(contact_name, check, details = '')
click to toggle source
# File lib/nines/notifier.rb, line 10 def notify!(contact_name, check, details = '') contact = @contacts[contact_name] email_body = ERB.new(File.open(Nines::App.root + '/lib/nines/email_templates/notification.text.erb').read).result(binding) Mail.deliver do from Nines::App.email_from to contact['email'] subject "#{Nines::App.email_subject_prefix}#{check.name} is #{check.up ? 'UP' : 'DOWN'}" body email_body end end