Class: Lilypad::Hoptoad::XML

Inherits:
Object
  • Object
show all
Extended by:
Config::Methods
Defined in:
lib/lilypad/hoptoad/xml.rb

Class Method Summary collapse

Methods included from Config::Methods

api_key

Class Method Details

.build(backtrace, env, exception, params, request_path) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/lilypad/hoptoad/xml.rb', line 8

def build(backtrace, env, exception, params, request_path)
  @@last_request = nil
  xml = ::Builder::XmlMarkup.new
  xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
  xml.notice :version => '2.0.0' do |n|
    n.tag! 'api-key', api_key(env, exception)
    n.notifier do |n|
      n.name 'Lilypad'
      n.url 'http://github.com/winton/lilypad'
      n.version '0.3.0'
    end
    n.error do |e|
      e.tag! 'class', exception.class.name
      e.message exception.message
      e.backtrace do |b|
        backtrace.each do |line|
          b.line :method => line.method, :file => line.file, :number => line.number
        end
      end
    end
    n.request do |r|
      r.action Config::Request.action
      r.component Config::Request.component || request_path
      r.url request_path
      if params.any?
        r.params do |p|
          params.each do |key, value|
            p.var value.to_s, :key => key
          end
        end
      end
      if env && env.any?
        r.tag! 'cgi-data' do |c|
          env.each do |key, value|
            c.var value.to_s, :key => key
          end
        end
      end
    end
    n.tag! 'server-environment' do |s|
      s.tag! 'project-root', Dir.pwd
      s.tag! 'environment-name', ENV['RACK_ENV'] || 'development'
    end
  end
  @@last_request = xml.target!
end

.last_requestObject



55
56
57
# File 'lib/lilypad/hoptoad/xml.rb', line 55

def last_request
  defined?(@@last_request) ? @@last_request : nil
end