class GuardWebHookNotifier::Notifier

Constants

DEFAULTS

Public Class Methods

new(opts = {}) click to toggle source
Calls superclass method
# File lib/guard-webhook-notifier/notifier.rb, line 12
def initialize(opts = {})
  super
  @options = DEFAULTS.merge(opts)
end

Public Instance Methods

notify(message, opts = {}) click to toggle source
Calls superclass method
# File lib/guard-webhook-notifier/notifier.rb, line 17
def notify(message, opts = {})
  super
  send(message, opts) rescue Faraday::Error
end

Private Instance Methods

send(message, opts) click to toggle source
# File lib/guard-webhook-notifier/notifier.rb, line 24
def send(message, opts)
  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: message, options: opts }.to_json
  end
end