lilypad 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -14,7 +14,6 @@ Use it
14
14
  ------
15
15
 
16
16
  <pre>
17
- require 'rubygems'
18
17
  require 'rack/lilypad'
19
18
 
20
19
  use Rack::Lilypad, 'fd48c7d26f724503a0280f808f44b339fc65fab8'
@@ -24,6 +23,11 @@ To specify environment filters:
24
23
 
25
24
  <pre>
26
25
  use Rack::Lilypad, 'fd48c7d26f724503a0280f808f44b339fc65fab8' do |hoptoad|
27
- hoptoad.filters << %w(AWS_ACCESS_KEY AWS_SECRET_ACCESS_KEY AWS_ACCOUNT SSH_AUTH_SOCK)
26
+ hoptoad.filters << %w(AWS_ACCESS_KEY AWS_SECRET_ACCESS_KEY AWS_ACCOUNT SSH_AUTH_SOCK)
28
27
  end
29
- </pre>
28
+ </pre>
29
+
30
+ Thanks
31
+ ------
32
+
33
+ Lilypad wouldn't have happened without [rack_hoptoad](http://github.com/atmos/rack_hoptoad), [toadhopper](http://github.com/toolmantim/toadhopper), [Builder](http://builder.rubyforge.org), and [Nokogiri](http://nokogiri.org).
data/gemspec.rb CHANGED
@@ -13,5 +13,5 @@ GEM_SPEC = Gem::Specification.new do |s|
13
13
  s.name = GEM_NAME
14
14
  s.platform = Gem::Platform::RUBY
15
15
  s.require_path = "lib"
16
- s.version = "0.1.0"
16
+ s.version = "0.1.1"
17
17
  end
data/lib/rack/lilypad.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'builder'
2
2
  require 'net/http'
3
3
  require 'rack'
4
- require 'yaml'
5
4
 
6
5
  module Rack
7
6
  class Lilypad
@@ -77,8 +76,9 @@ module Rack
77
76
  request_path = request.script_name + request.path_info
78
77
 
79
78
  xml = ::Builder::XmlMarkup.new
80
- xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
81
- xml.notice do |n|
79
+ xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
80
+ xml.notice(:version => '2.0.0') do |n|
81
+ n.tag! 'api-key', @api_key
82
82
  n.notifier do |n|
83
83
  n.name 'Lilypad'
84
84
  n.url 'http://github.com/winton/lilypad'
@@ -99,14 +99,14 @@ module Rack
99
99
  if request.params.any?
100
100
  r.params do |p|
101
101
  request.params.each do |key, value|
102
- p.var(:key => key, :value => value)
102
+ p.var(value, :key => key)
103
103
  end
104
104
  end
105
105
  end
106
106
  if environment.any?
107
107
  r.tag!('cgi-data') do |c|
108
108
  environment.each do |key, value|
109
- c.var(:key => key, :value => value)
109
+ c.var(value, :key => key)
110
110
  end
111
111
  end
112
112
  end
@@ -116,7 +116,13 @@ module Rack
116
116
  s.tag! 'environment-name', ENV['RACK_ENV'] || 'development'
117
117
  end
118
118
  end
119
- xml.target!
119
+ @@last_response = xml.target!
120
+ end
121
+
122
+ class <<self
123
+ def last_response
124
+ @@last_response
125
+ end
120
126
  end
121
127
 
122
128
  class Backtrace < Struct.new(:file, :number, :method)
@@ -0,0 +1,76 @@
1
+ <?xml version="1.0"?>
2
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3
+
4
+ <xs:element name="notice">
5
+ <xs:complexType>
6
+ <xs:all>
7
+ <xs:element name="api-key" type="xs:string"/>
8
+ <xs:element name="notifier" type="notifier"/>
9
+ <xs:element name="error" type="error"/>
10
+ <xs:element name="request" type="request" minOccurs="0"/>
11
+ <xs:element name="server-environment" type="serverEnvironment"/>
12
+ </xs:all>
13
+ <xs:attribute name="version" type="xs:string" use="required"/>
14
+ </xs:complexType>
15
+ </xs:element>
16
+
17
+ <xs:complexType name="notifier">
18
+ <xs:all>
19
+ <xs:element name="name" type="xs:string"/>
20
+ <xs:element name="version" type="xs:string"/>
21
+ <xs:element name="url" type="xs:string"/>
22
+ </xs:all>
23
+ </xs:complexType>
24
+
25
+ <xs:complexType name="error">
26
+ <xs:all>
27
+ <xs:element name="class" type="xs:string"/>
28
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
29
+ <xs:element name="backtrace" type="backtrace"/>
30
+ </xs:all>
31
+ </xs:complexType>
32
+
33
+ <xs:complexType name="backtrace">
34
+ <xs:sequence>
35
+ <xs:element name="line" maxOccurs="unbounded">
36
+ <xs:complexType>
37
+ <xs:attribute name="file" type="xs:string" use="required"/>
38
+ <xs:attribute name="number" type="xs:string" use="required"/>
39
+ <xs:attribute name="method" type="xs:string" use="optional"/>
40
+ </xs:complexType>
41
+ </xs:element>
42
+ </xs:sequence>
43
+ </xs:complexType>
44
+
45
+ <xs:complexType name="request">
46
+ <xs:all>
47
+ <xs:element name="url" type="xs:string"/>
48
+ <xs:element name="component" type="xs:string"/>
49
+ <xs:element name="action" type="xs:string" minOccurs="0"/>
50
+ <xs:element name="params" type="varList" minOccurs="0"/>
51
+ <xs:element name="session" type="varList" minOccurs="0"/>
52
+ <xs:element name="cgi-data" type="varList" minOccurs="0"/>
53
+ </xs:all>
54
+ </xs:complexType>
55
+
56
+ <xs:complexType name="varList">
57
+ <xs:sequence>
58
+ <xs:element name="var" type="var" maxOccurs="unbounded"/>
59
+ </xs:sequence>
60
+ </xs:complexType>
61
+
62
+ <xs:complexType name="var" mixed="true">
63
+ <xs:sequence>
64
+ <xs:element name="var" type="var" minOccurs="0" maxOccurs="unbounded"/>
65
+ </xs:sequence>
66
+ <xs:attribute name="key" type="xs:string" use="required"/>
67
+ </xs:complexType>
68
+
69
+ <xs:complexType name="serverEnvironment">
70
+ <xs:sequence>
71
+ <xs:element name="project-root" type="xs:string" minOccurs="0"/>
72
+ <xs:element name="environment-name" type="xs:string"/>
73
+ </xs:sequence>
74
+ </xs:complexType>
75
+
76
+ </xs:schema>
@@ -8,7 +8,30 @@ describe Rack::Lilypad do
8
8
  SinatraApp.new
9
9
  end
10
10
 
11
- # it "should do something" do
12
- # get "/raise"
13
- # end
11
+ before(:each) do
12
+ ENV['RACK_ENV'] = 'production'
13
+ @http = mock(:http)
14
+ @http.stub!(:read_timeout=)
15
+ @http.stub!(:open_timeout=)
16
+ @http.stub!(:post)
17
+ Net::HTTP.stub!(:start).and_yield(@http)
18
+ end
19
+
20
+ it "should post an error to Hoptoad" do
21
+ @http.should_receive(:post)
22
+ get "/raise" rescue nil
23
+ end
24
+
25
+ it "should transfer valid XML to Hoptoad" do
26
+ get "/raise" rescue nil
27
+
28
+ xsd = Nokogiri::XML::Schema(File.read(SPEC + '/fixtures/hoptoad_2_0.xsd'))
29
+ doc = Nokogiri::XML(Rack::Lilypad::Hoptoad.last_response)
30
+
31
+ errors = xsd.validate(doc)
32
+ errors.each do |error|
33
+ puts error.message
34
+ end
35
+ errors.length.should == 0
36
+ end
14
37
  end
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,7 @@ require 'rack/lilypad'
6
6
  require 'pp'
7
7
 
8
8
  require 'rubygems'
9
+ require 'nokogiri'
9
10
  require 'rack/test'
10
11
  require 'sinatra/base'
11
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lilypad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Winton Welsh
@@ -27,11 +27,11 @@ files:
27
27
  - MIT-LICENSE
28
28
  - Rakefile
29
29
  - README.markdown
30
+ - spec/fixtures/hoptoad_2_0.xsd
30
31
  - spec/fixtures/sinatra.rb
31
32
  - spec/rack/lilypad_spec.rb
32
33
  - spec/spec.opts
33
34
  - spec/spec_helper.rb
34
- - tmp/toadhopper.git.tgz
35
35
  has_rdoc: true
36
36
  homepage: http://github.com/winton/lilypad
37
37
  licenses: []
Binary file