Module: BugBot

Extended by:
BugBot
Included in:
BugBot
Defined in:
lib/bug_bot.rb,
lib/bug_bot/adapter.rb,
lib/bug_bot/identity.rb,
lib/bug_bot/adapters/bugsnag.rb,
lib/bug_bot/adapters/airbrake.rb

Defined Under Namespace

Modules: Adapters, Identity Classes: Adapter

Constant Summary collapse

SUPPORTED_ADAPTERS =
{ airbrake: 'airbrake-ruby', bugsnag: 'bugsnag' }.freeze

Instance Method Summary collapse

Instance Method Details

#adapterObject



19
20
21
22
23
24
# File 'lib/bug_bot.rb', line 19

def adapter
  return @adapter if defined?(@adapter)

  # TODO: Add adapter from config here
  load_adapter(default_adapter)
end

#default_adapterObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/bug_bot.rb', line 32

def default_adapter
  return :airbrake if defined?(::Airbrake)
  return :bugsnag if defined?(::Bugsnag)

  SUPPORTED_ADAPTERS.each do |adapter, gem_name|
    require gem_name
    return adapter
  end

  # TODO: Return default adapter here
end

#notify(exception, options = {}) ⇒ Object



28
29
30
# File 'lib/bug_bot.rb', line 28

def notify(exception, options = {})
  adapter.notify(exception, options)
end

#use_adapter(adapter) ⇒ Object Also known as: adapter=



8
9
10
11
12
13
14
15
16
17
# File 'lib/bug_bot.rb', line 8

def use_adapter(adapter)
  @adapter = case adapter
             when String, Symbol
               load_adapter(adapter.to_s)
             when Class, Module
               adapter
             else
               load_adapter(default_adapter)
             end
end