Class: Stoplight::Notifier::Honeybadger

Inherits:
Base
  • Object
show all
Defined in:
lib/stoplight/notifier/honeybadger.rb

Overview

See Also:

Constant Summary collapse

DEFAULT_OPTIONS =
{
  parameters: {},
  session: {},
  context: {}
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, formatter = nil, options = {}) ⇒ Honeybadger

Returns a new instance of Honeybadger

Parameters:

  • api_key (String)
  • formatter (Proc, nil) (defaults to: nil)
  • options (Hash{Symbol => Object}) (defaults to: {})

Options Hash (options):

  • :parameters (Hash)
  • :session (Hash)
  • :context (Hash)

26
27
28
29
30
# File 'lib/stoplight/notifier/honeybadger.rb', line 26

def initialize(api_key, formatter = nil, options = {})
  @api_key = api_key
  @formatter = formatter || Default::FORMATTER
  @options = DEFAULT_OPTIONS.merge(options)
end

Instance Attribute Details

#api_keyString (readonly)

Returns:

  • (String)

14
15
16
# File 'lib/stoplight/notifier/honeybadger.rb', line 14

def api_key
  @api_key
end

#formatterProc (readonly)

Returns:

  • (Proc)

16
17
18
# File 'lib/stoplight/notifier/honeybadger.rb', line 16

def formatter
  @formatter
end

#optionsHash{Symbol => Object} (readonly)

Returns:

  • (Hash{Symbol => Object})

18
19
20
# File 'lib/stoplight/notifier/honeybadger.rb', line 18

def options
  @options
end

Instance Method Details

#notify(light, from_color, to_color, error) ⇒ Object


32
33
34
35
36
37
38
39
40
41
# File 'lib/stoplight/notifier/honeybadger.rb', line 32

def notify(light, from_color, to_color, error)
  message = formatter.call(light, from_color, to_color, error)
  h = options.merge(
    api_key: api_key,
    error_message: message,
    backtrace: (error.backtrace if error)
  )
  ::Honeybadger.notify(h)
  message
end