Class: E2db
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- E2db
- Defined in:
- app/models/e2db.rb
Instance Method Summary collapse
- #action ⇒ Object
- #cgi_data ⇒ Object
- #controller ⇒ Object
- #document ⇒ Object
- #environment ⇒ Object
- #error_message ⇒ Object
- #formatted_backtrace ⇒ Object
- #parameters ⇒ Object
- #top_file_and_line_number ⇒ Object
- #url ⇒ Object
- #user_agent ⇒ Object
Instance Method Details
#action ⇒ Object
40 41 42 |
# File 'app/models/e2db.rb', line 40 def action REXML::XPath.first(document, '//notice/request/action/text()').to_s end |
#cgi_data ⇒ Object
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 |
#controller ⇒ Object
36 37 38 |
# File 'app/models/e2db.rb', line 36 def controller REXML::XPath.first(document, '//notice/request/component/text()').to_s end |
#document ⇒ Object
6 7 8 |
# File 'app/models/e2db.rb', line 6 def document @document ||= REXML::Document.new(self.exception) end |
#environment ⇒ Object
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_message ⇒ Object
10 11 12 |
# File 'app/models/e2db.rb', line 10 def REXML::XPath.first(document, '//notice/error/message/text()').to_s end |
#formatted_backtrace ⇒ Object
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 |
#parameters ⇒ Object
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_number ⇒ Object
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 |
#url ⇒ Object
44 45 46 |
# File 'app/models/e2db.rb', line 44 def url REXML::XPath.first(document, '//notice/request/url/text()').to_s end |
#user_agent ⇒ Object
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 |