Module: Ribbit

Defined in:
lib/ribbit.rb,
lib/ribbit/notice.rb,
lib/ribbit/sender.rb,
lib/ribbit/adapters.rb,
lib/ribbit/backtrace.rb,
lib/ribbit/adapters/merb.rb,
lib/ribbit/adapters/none.rb,
lib/ribbit/configuration.rb,
lib/ribbit/adapters/adapter.rb

Defined Under Namespace

Modules: Adapters Classes: Backtrace, Configuration, Notice, Sender

Constant Summary collapse

CLIENT_NAME =
"Ribbit"
VERSION =
"0.1.0.dev"
API_VERSION =
"2.0"
LOG_PREFIX =
"** [Ribbit] "

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.adapterObject

The adapter allows different things to happen on different environments Basicially we proxy some methods through to subclasses of Ribbit::Adapters::Adapter



26
27
28
# File 'lib/ribbit.rb', line 26

def adapter
  @adapter
end

.configurationObject

A Hoptoad configuration object. Must act like a hash and return sensible values for all Hoptoad configuration options. See Ribbit::Configuration.



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

def configuration
  @configuration
end

.senderObject

The sender object is responsible for delivering formatted data to the Hoptoad server. Must respond to #send_to_hoptoad. See Ribbit::Sender.



17
18
19
# File 'lib/ribbit.rb', line 17

def sender
  @sender
end

Class Method Details

.adaptersObject

Collection of all existing adapters



29
30
31
# File 'lib/ribbit.rb', line 29

def adapters
  Ribbit::Adapters.adapters
end

.configure(silent = false) {|configuration| ... } ⇒ Object

Call this method to modify defaults in your initializers.

Examples:

Ribbit.configure do |config|
  config.api_key = '1234567890abcdef'
  config.secure = false
end

Yields:



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ribbit.rb', line 45

def configure(silent = false)
  self.configuration ||= Configuration.new
  yield(configuration)
  self.sender = Sender.new(configuration)
  # Attempt to attach an adapter, either by class or name
  if adapters.include? configuration.adapter
    self.adapter = configuration.adapter.new(configuration)
  elsif configuration.adapter
    adapter_class = Ribbit::Adapters.load_adapter configuration.adapter
    self.adapter = adapter_class.new(configuration) rescue nil
  end
  self.adapter.activate! if self.adapter
end

.loggerObject

Proxy logger onto the adapter



34
35
36
# File 'lib/ribbit.rb', line 34

def logger
  adapter.logger if adapter
end

.notify(exception, opts = {}) ⇒ Object

Sends an exception manually using this method, even when you are not in a controller.

Parameters:

  • exception (Exception)

    The exception you want to notify Hoptoad about.

  • opts (Hash) (defaults to: {})

    Data that will be sent to Hoptoad.

Options Hash (opts):

  • :api_key (String)

    The API key for this project. The API key is a unique identifier that Hoptoad uses for identification.

  • :error_message (String)

    The error returned by the exception (or the message you want to log).

  • :backtrace (String)

    A backtrace, usually obtained with caller.

  • :request (String)

    The controller’s request object.

  • :session (String)

    The contents of the user’s session.

  • :environment (String)

    ENV merged with the contents of the request’s environment.



70
71
72
# File 'lib/ribbit.rb', line 70

def notify(exception, opts = {})
  send_notice(build_notice_for(exception, opts))
end

.notify_or_ignore(exception, opts = {}) ⇒ Object

Sends the notice unless it is one of the default ignored exceptions

See Also:



76
77
78
79
# File 'lib/ribbit.rb', line 76

def notify_or_ignore(exception, opts = {})
  notice = build_notice_for(exception, opts)
  send_notice(notice) unless notice.ignore?
end