Class: E2db

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/e2db.rb

Instance Method Summary collapse

Instance Method Details

#actionObject



40
41
42
# File 'app/models/e2db.rb', line 40

def action
  REXML::XPath.first(document, '//notice/request/action/text()').to_s
end

#cgi_dataObject



14
15
16
# File 'app/models/e2db.rb', line 14

def cgi_data
  {}.tap { |e| REXML::XPath.each(document, '//notice/request/cgi-data/var') { |node| e.store(node.attributes['key'].to_s, node.text) } }
end

#controllerObject



36
37
38
# File 'app/models/e2db.rb', line 36

def controller
  REXML::XPath.first(document, '//notice/request/component/text()').to_s
end

#documentObject



6
7
8
# File 'app/models/e2db.rb', line 6

def document
  @document ||= REXML::Document.new(self.exception)
end

#environmentObject



48
49
50
# File 'app/models/e2db.rb', line 48

def environment
  REXML::XPath.first(document, '//notice/server-environment/environment-name/text()').to_s
end

#error_messageObject



10
11
12
# File 'app/models/e2db.rb', line 10

def error_message
  REXML::XPath.first(document, '//notice/error/message/text()').to_s
end

#formatted_backtraceObject



57
58
59
60
61
62
63
64
65
66
67
# File 'app/models/e2db.rb', line 57

def formatted_backtrace
  REXML::XPath.match(document, '//notice/error/backtrace/line').inject('') do |sum, elem|
    sum << '<p>'
    sum << elem.attributes['file']
    sum << ':'
    sum << elem.attributes['number']
    sum << ':in '
    sum << elem.attributes['method']
    sum << '</p>'
  end
end

#parametersObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/e2db.rb', line 23

def parameters
  output = [].tap{ |e|
    REXML::XPath.each(document, '//notice/request/params/var') do |node|
      item = ':' + node.attributes['key'].to_s
      item << ' => '
      item << (node.text || '')
      e << item
    end
  }.join(' , ')

  '{ ' + output + ' }'
end

#top_file_and_line_numberObject



52
53
54
55
# File 'app/models/e2db.rb', line 52

def top_file_and_line_number
  top_file = REXML::XPath.match(document, '//notice/error/backtrace/line').first
  "#{top_file.attributes['file']}:#{top_file.attributes['number']}"
end

#urlObject



44
45
46
# File 'app/models/e2db.rb', line 44

def url
  REXML::XPath.first(document, '//notice/request/url/text()').to_s
end

#user_agentObject



18
19
20
21
# File 'app/models/e2db.rb', line 18

def user_agent
  node = REXML::XPath.first(document, '//notice/request/cgi-data/var[@key="HTTP_USER_AGENT"]')
  node.blank? ? "N/A" : node.text
end