class Bugno::Event

Attributes

data[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/bugno/event.rb, line 13
def initialize(options = {})
  @env = options[:env]
  @job = options[:job]
  @exception = options[:exception]
  build_data
end

Private Instance Methods

build_data() click to toggle source
# File lib/bugno/event.rb, line 22
def build_data
  @data = {
    title: truncate(@exception.class.inspect),
    message: truncate(@exception.message),
    server_data: server_data,
    created_at: Time.now.to_i,
    framework: Bugno.configuration.framework,
    environment: Bugno.configuration.environment
  }
  merge_extra_data
end
merge_extra_data() click to toggle source
# File lib/bugno/event.rb, line 34
def merge_extra_data
  @data.merge!(backtrace: Backtrace.new(@exception.backtrace).parse_backtrace) if @exception.backtrace
  @data.merge!(extract_request_data_from_rack(@env)) if @env
  @data.merge!(background_data: @job) if @job
end
server_data() click to toggle source

TODO: refactor

# File lib/bugno/event.rb, line 46
def server_data
  data = { host: Socket.gethostname }
  data[:root] = Rails.root.to_s if defined?(Rails)
  data
end
truncate(string) click to toggle source

TODO: move to utility module

# File lib/bugno/event.rb, line 41
def truncate(string)
  string.is_a?(String) ? string[0...3000] : ''
end