Class: GuardWebHookNotifier::Notifier
- Inherits:
-
Guard::Notifier::Base
- Object
- Guard::Notifier::Base
- GuardWebHookNotifier::Notifier
- Defined in:
- lib/guard-webhook-notifier/notifier.rb
Constant Summary collapse
- DEFAULTS =
{ user_agent: "GuardWebHookNotifier/#{VERSION}", url: "http://10.0.2.2:4001/" }
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Notifier
constructor
A new instance of Notifier.
- #notify(message, opts = {}) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Notifier
Returns a new instance of Notifier.
12 13 14 15 |
# File 'lib/guard-webhook-notifier/notifier.rb', line 12 def initialize(opts = {}) super = DEFAULTS.merge(opts) end |
Instance Method Details
#notify(message, opts = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/guard-webhook-notifier/notifier.rb', line 17 def notify(, opts = {}) super conn = Faraday.new(url: opts[:url]) conn.post do |req| req.headers["Content-Type"] = "application/json" req.headers["User-Agent"] = opts[:user_agent] req.body = { message: , options: opts }.to_json end end |