Class: Bullhorn

Inherits:
Object
  • Object
show all
Includes:
Sender
Defined in:
lib/bullhorn.rb,
lib/bullhorn/plugin.rb,
lib/bullhorn/sender.rb,
lib/bullhorn/backtrace.rb

Defined Under Namespace

Modules: Plugin, Sender Classes: Backtrace

Constant Summary collapse

LANGUAGE =
"ruby"
CLIENT_NAME =
"bullhorn-ruby"
VERSION =
"0.0.5"
URL =
"http://www.bullhorn.it/api/v1/exception"
FILTERING =
%(['"]?\[?%s\]?['"]?=>?([^&\s]*))

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Sender

#notify, #serialize

Constructor Details

#initialize(app, options = {}) ⇒ Bullhorn

Returns a new instance of Bullhorn.



29
30
31
32
33
34
35
36
# File 'lib/bullhorn.rb', line 29

def initialize(app, options = {})
  @app               = app
  @api_key           = options[:api_key] || raise(ArgumentError, ":api_key is required")
  @filters           = Array(options[:filters])
  @url               = options[:url] || URL
  @ignore_exceptions = Array(options[:ignore_exceptions] || default_ignore_exceptions)
  @show_code_context = (options[:show_code_context].nil? ? true : options[:show_code_context])
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



22
23
24
# File 'lib/bullhorn.rb', line 22

def api_key
  @api_key
end

#filtersObject (readonly)

Returns the value of attribute filters.



21
22
23
# File 'lib/bullhorn.rb', line 21

def filters
  @filters
end

#ignore_exceptionsObject (readonly)

Returns the value of attribute ignore_exceptions.



24
25
26
# File 'lib/bullhorn.rb', line 24

def ignore_exceptions
  @ignore_exceptions
end

#show_code_contextObject (readonly)

Returns the value of attribute show_code_context.



25
26
27
# File 'lib/bullhorn.rb', line 25

def show_code_context
  @show_code_context
end

#urlObject (readonly)

Returns the value of attribute url.



23
24
25
# File 'lib/bullhorn.rb', line 23

def url
  @url
end

Instance Method Details

#call(env) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/bullhorn.rb', line 38

def call(env)
  status, headers, body =
    begin
      @app.call(env)
    rescue Exception => ex
      unless ignore_exceptions.include?(ex.class)
        notify ex, env
      end

      raise ex
    end

  [status, headers, body]
end