Class: Stoplight::Notifier::Raven

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

Overview

See Also:

Constant Summary collapse

DEFAULT_OPTIONS =
{
  extra: {}
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, formatter = nil, options = {}) ⇒ Raven

Returns a new instance of Raven

Parameters:

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

Options Hash (options):

  • :extra (Hash)

22
23
24
25
26
# File 'lib/stoplight/notifier/raven.rb', line 22

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

Instance Attribute Details

#configuration::Raven::Configuration (readonly)

Returns:

  • (::Raven::Configuration)

12
13
14
# File 'lib/stoplight/notifier/raven.rb', line 12

def configuration
  @configuration
end

#formatterProc (readonly)

Returns:

  • (Proc)

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

def formatter
  @formatter
end

#optionsHash{Symbol => Object} (readonly)

Returns:

  • (Hash{Symbol => Object})

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

def options
  @options
end

Instance Method Details

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


28
29
30
31
32
33
34
35
36
37
# File 'lib/stoplight/notifier/raven.rb', line 28

def notify(light, from_color, to_color, error)
  message = formatter.call(light, from_color, to_color, error)

  h = options.merge(
    configuration: configuration,
    backtrace: (error.backtrace if error)
  )
  ::Raven.capture_message(message, h)
  message
end