lib/backup/notifier/prowl.rb in backup-4.4.1 vs lib/backup/notifier/prowl.rb in backup-5.0.0.beta.1

- old
+ new

@@ -1,12 +1,10 @@ -# encoding: utf-8 -require 'uri' +require "uri" module Backup module Notifier class Prowl < Base - ## # Application name # Tell something like your server name. Example: "Server1 Backup" attr_accessor :application @@ -14,14 +12,17 @@ # API-Key # Create a Prowl account and request an API key on prowlapp.com. attr_accessor :api_key def initialize(model, &block) - @message = lambda do |model, data| - "#{ model.label } (#{ model.trigger })" - end + @message = + lambda do |m, _| + "#{m.label} (#{m.trigger})" + end + super + instance_eval(&block) if block_given? end private @@ -45,24 +46,23 @@ def notify!(status) send_message(status) end def send_message(status) - uri = 'https://api.prowlapp.com/publicapi/add' + 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) + 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) + headers: { "Content-Type" => "application/x-www-form-urlencoded" }, + body: URI.encode_www_form(data) } - options.merge!(:expects => 200) # raise error if unsuccessful + options[:expects] = 200 # raise error if unsuccessful Excon.post(uri, options) end - end end end