class Backup::Notifier::Prowl
Attributes
api_key[RW]
API-Key Create a Prowl
account and request an API key on prowlapp.com.
application[RW]
Application name Tell something like your server name. Example: “Server1 Backup”
Public Class Methods
new(model, &block)
click to toggle source
Calls superclass method
Backup::Notifier::Base::new
# File lib/backup/notifier/prowl.rb, line 16 def initialize(model, &block) @message = lambda do |m, _| "#{m.label} (#{m.trigger})" end super instance_eval(&block) if block_given? end
Private Instance Methods
notify!(status)
click to toggle source
Notify the user of the backup operation results.
‘status` indicates one of the following:
‘:success` : The backup completed successfully. : Notification will be sent if `on_success` is `true`.
‘:warning` : The backup completed successfully, but warnings were logged. : Notification will be sent if `on_warning` or `on_success` is `true`.
‘:failure` : The backup operation failed. : Notification will be sent if `on_warning` or `on_success` is `true`.
# File lib/backup/notifier/prowl.rb, line 46 def notify!(status) send_message(status) end
send_message(status)
click to toggle source
# File lib/backup/notifier/prowl.rb, line 50 def send_message(status) uri = "https://api.prowlapp.com/publicapi/add" status_data = status_data_for(status) data = { application: application, apikey: api_key, event: status_data[:message], description: message.call(model, status: status_data) } options = { headers: { "Content-Type" => "application/x-www-form-urlencoded" }, body: URI.encode_www_form(data) } options[:expects] = 200 # raise error if unsuccessful Excon.post(uri, options) end