lib/god/contacts/prowl.rb in resurrected_god-0.14.0 vs lib/god/contacts/prowl.rb in resurrected_god-1.0.0
- old
+ new
@@ -8,49 +8,48 @@
end
module God
module Contacts
class Prowl < Contact
-
class << self
attr_accessor :apikey
end
def valid?
valid = true
- valid &= complain("Attribute 'apikey' must be specified", self) if self.apikey.nil?
+ valid &= complain("Attribute 'apikey' must be specified", self) if apikey.nil?
valid
end
attr_accessor :apikey
def notify(message, time, priority, category, host)
result = Prowly.notify do |n|
n.apikey = arg(:apikey)
n.priority = map_priority(priority.to_i)
- n.application = category || "God"
- n.event = "on " + host.to_s
- n.description = message.to_s + " at " + time.to_s
+ n.application = category || 'God'
+ n.event = "on #{host}"
+ n.description = "#{message} at #{time}"
end
- if result.succeeded?
- self.info = "sent prowl notification to #{self.name}"
- else
- self.info = "failed to send prowl notification to #{self.name}: #{result.message}"
- end
+ self.info = if result.succeeded?
+ "sent prowl notification to #{name}"
+ else
+ "failed to send prowl notification to #{name}: #{result.message}"
+ end
rescue Object => e
- applog(nil, :info, "failed to send prowl notification to #{self.name}: #{e.message}")
+ applog(nil, :info, "failed to send prowl notification to #{name}: #{e.message}")
applog(nil, :debug, e.backtrace.join("\n"))
end
def map_priority(priority)
case priority
- when 1 then Prowly::Notification::Priority::EMERGENCY
- when 2 then Prowly::Notification::Priority::HIGH
- when 3 then Prowly::Notification::Priority::NORMAL
- when 4 then Prowly::Notification::Priority::MODERATE
- when 5 then Prowly::Notification::Priority::VERY_LOW
- else Prowly::Notification::Priority::NORMAL
+ when 1 then Prowly::Notification::Priority::EMERGENCY
+ when 2 then Prowly::Notification::Priority::HIGH
+ when 3 then Prowly::Notification::Priority::NORMAL
+ when 4 then Prowly::Notification::Priority::MODERATE
+ when 5 then Prowly::Notification::Priority::VERY_LOW
+ else Prowly::Notification::Priority::NORMAL
end
end
end
end
end