webmachine 0.1.0 → 0.2.0
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/Gemfile +11 -3
- data/README.md +55 -27
- data/lib/webmachine/adapters/mongrel.rb +84 -0
- data/lib/webmachine/adapters/webrick.rb +12 -3
- data/lib/webmachine/adapters.rb +1 -7
- data/lib/webmachine/configuration.rb +30 -0
- data/lib/webmachine/decision/conneg.rb +7 -72
- data/lib/webmachine/decision/flow.rb +13 -11
- data/lib/webmachine/decision/fsm.rb +1 -9
- data/lib/webmachine/decision/helpers.rb +27 -7
- data/lib/webmachine/errors.rb +1 -0
- data/lib/webmachine/headers.rb +12 -3
- data/lib/webmachine/locale/en.yml +2 -2
- data/lib/webmachine/media_type.rb +117 -0
- data/lib/webmachine/resource/callbacks.rb +9 -0
- data/lib/webmachine/streaming.rb +3 -3
- data/lib/webmachine/version.rb +1 -1
- data/lib/webmachine.rb +3 -1
- data/pkg/webmachine-0.1.0/Gemfile +16 -0
- data/pkg/webmachine-0.1.0/Guardfile +11 -0
- data/pkg/webmachine-0.1.0/README.md +90 -0
- data/pkg/webmachine-0.1.0/Rakefile +31 -0
- data/pkg/webmachine-0.1.0/examples/webrick.rb +19 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/adapters/webrick.rb +74 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/adapters.rb +15 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/decision/conneg.rb +304 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/decision/flow.rb +502 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/decision/fsm.rb +79 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/decision/helpers.rb +80 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/decision.rb +12 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/dispatcher/route.rb +85 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/dispatcher.rb +40 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/errors.rb +37 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/headers.rb +16 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/locale/en.yml +28 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/request.rb +56 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/resource/callbacks.rb +362 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/resource/encodings.rb +36 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/resource.rb +48 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/response.rb +49 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/streaming.rb +27 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/translation.rb +11 -0
- data/pkg/webmachine-0.1.0/lib/webmachine/version.rb +4 -0
- data/pkg/webmachine-0.1.0/lib/webmachine.rb +19 -0
- data/pkg/webmachine-0.1.0/spec/spec_helper.rb +13 -0
- data/pkg/webmachine-0.1.0/spec/tests.org +57 -0
- data/pkg/webmachine-0.1.0/spec/webmachine/decision/conneg_spec.rb +152 -0
- data/pkg/webmachine-0.1.0/spec/webmachine/decision/flow_spec.rb +1030 -0
- data/pkg/webmachine-0.1.0/spec/webmachine/dispatcher/route_spec.rb +109 -0
- data/pkg/webmachine-0.1.0/spec/webmachine/dispatcher_spec.rb +34 -0
- data/pkg/webmachine-0.1.0/spec/webmachine/headers_spec.rb +19 -0
- data/pkg/webmachine-0.1.0/spec/webmachine/request_spec.rb +24 -0
- data/pkg/webmachine-0.1.0/webmachine.gemspec +44 -0
- data/pkg/webmachine-0.1.0.gem +0 -0
- data/spec/webmachine/configuration_spec.rb +27 -0
- data/spec/webmachine/decision/conneg_spec.rb +18 -11
- data/spec/webmachine/decision/flow_spec.rb +2 -0
- data/spec/webmachine/decision/helpers_spec.rb +105 -0
- data/spec/webmachine/errors_spec.rb +13 -0
- data/spec/webmachine/headers_spec.rb +2 -1
- data/spec/webmachine/media_type_spec.rb +78 -0
- data/webmachine.gemspec +4 -1
- metadata +69 -11
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Webmachine errors" do
|
4
|
+
describe ".render_error" do
|
5
|
+
it "sets the given response code on the response object" do
|
6
|
+
req = double('request', :method => 'GET').as_null_object
|
7
|
+
res = Webmachine::Response.new
|
8
|
+
|
9
|
+
Webmachine.render_error(404, req, res)
|
10
|
+
res.code.should be(404)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -4,8 +4,9 @@ describe Webmachine::Headers do
|
|
4
4
|
it "should set and access values insensitive to case" do
|
5
5
|
subject['Content-TYPE'] = "text/plain"
|
6
6
|
subject['CONTENT-TYPE'].should == 'text/plain'
|
7
|
+
subject.delete('CoNtEnT-tYpE').should == 'text/plain'
|
7
8
|
end
|
8
|
-
|
9
|
+
|
9
10
|
context "filtering with #grep" do
|
10
11
|
subject { described_class["content-type" => "text/plain", "etag" => '"abcdef1234567890"'] }
|
11
12
|
it "should filter keys by the given pattern" do
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Webmachine::MediaType do
|
4
|
+
let(:raw_type){ "application/xml;charset=UTF-8" }
|
5
|
+
subject { described_class.new("application/xml", {"charset" => "UTF-8"}) }
|
6
|
+
|
7
|
+
context "equivalence" do
|
8
|
+
it { should == raw_type }
|
9
|
+
it { should == described_class.parse(raw_type) }
|
10
|
+
end
|
11
|
+
|
12
|
+
context "when it is the wildcard type" do
|
13
|
+
subject { described_class.new("*/*") }
|
14
|
+
it { should be_matches_all }
|
15
|
+
end
|
16
|
+
|
17
|
+
context "parsing a type" do
|
18
|
+
it "should return MediaTypes untouched" do
|
19
|
+
described_class.parse(subject).should equal(subject)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should parse a String" do
|
23
|
+
type = described_class.parse(raw_type)
|
24
|
+
type.should be_kind_of(described_class)
|
25
|
+
type.type.should == "application/xml"
|
26
|
+
type.params.should == {"charset" => "UTF-8"}
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should parse a type/params pair" do
|
30
|
+
type = described_class.parse(["application/xml", {"charset" => "UTF-8"}])
|
31
|
+
type.should be_kind_of(described_class)
|
32
|
+
type.type.should == "application/xml"
|
33
|
+
type.params.should == {"charset" => "UTF-8"}
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should parse a type/params pair where the type has some params in the string" do
|
37
|
+
type = described_class.parse(["application/xml;version=1", {"charset" => "UTF-8"}])
|
38
|
+
type.should be_kind_of(described_class)
|
39
|
+
type.type.should == "application/xml"
|
40
|
+
type.params.should == {"charset" => "UTF-8", "version" => "1"}
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should parse a type/params pair with params and whitespace in the string" do
|
44
|
+
type = described_class.parse(["multipart/form-data; boundary=----------------------------2c46a7bec2b9", {"charset" => "UTF-8"}])
|
45
|
+
type.should be_kind_of(described_class)
|
46
|
+
type.type.should == "multipart/form-data"
|
47
|
+
type.params.should == {"boundary" => "----------------------------2c46a7bec2b9", "charset" => "UTF-8"}
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should raise an error when given an invalid type/params pair" do
|
51
|
+
expect {
|
52
|
+
described_class.parse([false, "blah"])
|
53
|
+
}.to raise_error(ArgumentError)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "matching a requested type" do
|
58
|
+
it { should be_exact_match("application/xml;charset=UTF-8") }
|
59
|
+
it { should be_exact_match("application/*;charset=UTF-8") }
|
60
|
+
it { should be_exact_match("*/*;charset=UTF-8") }
|
61
|
+
it { should be_exact_match("*;charset=UTF-8") }
|
62
|
+
it { should_not be_exact_match("text/xml") }
|
63
|
+
it { should_not be_exact_match("application/xml") }
|
64
|
+
it { should_not be_exact_match("application/xml;version=1") }
|
65
|
+
|
66
|
+
it { should be_type_matches("application/xml") }
|
67
|
+
it { should be_type_matches("application/*") }
|
68
|
+
it { should be_type_matches("*/*") }
|
69
|
+
it { should be_type_matches("*") }
|
70
|
+
it { should_not be_type_matches("text/xml") }
|
71
|
+
it { should_not be_type_matches("text/*") }
|
72
|
+
|
73
|
+
it { should be_params_match({}) }
|
74
|
+
it { should be_params_match({"charset" => "UTF-8"}) }
|
75
|
+
it { should_not be_params_match({"charset" => "Windows-1252"}) }
|
76
|
+
it { should_not be_params_match({"version" => "3"}) }
|
77
|
+
end
|
78
|
+
end
|
data/webmachine.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
the confusion of going through a CGI-style interface like Rack. It is strongly influenced
|
12
12
|
by the original Erlang project of the same name and shares its opinionated nature about HTTP.
|
13
13
|
DESC
|
14
|
-
gem.homepage = "http://
|
14
|
+
gem.homepage = "http://github.com/seancribbs/webmachine-ruby"
|
15
15
|
gem.authors = ["Sean Cribbs"]
|
16
16
|
gem.email = ["sean@basho.com"]
|
17
17
|
|
@@ -23,17 +23,20 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
|
24
24
|
gem.add_development_dependency(%q<yard>, ["~> 0.6.7"])
|
25
25
|
gem.add_development_dependency(%q<rake>)
|
26
|
+
gem.add_development_dependency(%q<mongrel>, ['~>1.2.beta'])
|
26
27
|
else
|
27
28
|
gem.add_dependency(%q<i18n>, [">= 0.4.0"])
|
28
29
|
gem.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
29
30
|
gem.add_dependency(%q<yard>, ["~> 0.6.7"])
|
30
31
|
gem.add_dependency(%q<rake>)
|
32
|
+
gem.add_dependency(%q<mongrel>, ['~>1.2.beta'])
|
31
33
|
end
|
32
34
|
else
|
33
35
|
gem.add_dependency(%q<i18n>, [">= 0.4.0"])
|
34
36
|
gem.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
35
37
|
gem.add_dependency(%q<yard>, ["~> 0.6.7"])
|
36
38
|
gem.add_dependency(%q<rake>)
|
39
|
+
gem.add_dependency(%q<mongrel>, ['~>1.2.beta'])
|
37
40
|
end
|
38
41
|
|
39
42
|
ignores = File.read(".gitignore").split(/\r?\n/).reject{ |f| f =~ /^(#.+|\s*)$/ }.map {|f| Dir[f] }.flatten
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webmachine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-09-11 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
16
|
-
requirement: &
|
16
|
+
requirement: &2160756300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.4.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2160756300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &2160755360 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.6.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2160755360
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: yard
|
38
|
-
requirement: &
|
38
|
+
requirement: &2160754640 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.6.7
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2160754640
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &2160754100 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,18 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2160754100
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: mongrel
|
60
|
+
requirement: &2160752320 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.2.beta
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2160752320
|
58
69
|
description: ! ' webmachine is a toolkit for building HTTP applications in a declarative
|
59
70
|
fashion, that avoids the confusion of going through a CGI-style interface like Rack.
|
60
71
|
It is strongly influenced by the original Erlang project of the same name and shares
|
@@ -68,8 +79,10 @@ files:
|
|
68
79
|
- examples/webrick.rb
|
69
80
|
- Gemfile
|
70
81
|
- Guardfile
|
82
|
+
- lib/webmachine/adapters/mongrel.rb
|
71
83
|
- lib/webmachine/adapters/webrick.rb
|
72
84
|
- lib/webmachine/adapters.rb
|
85
|
+
- lib/webmachine/configuration.rb
|
73
86
|
- lib/webmachine/decision/conneg.rb
|
74
87
|
- lib/webmachine/decision/flow.rb
|
75
88
|
- lib/webmachine/decision/fsm.rb
|
@@ -80,6 +93,7 @@ files:
|
|
80
93
|
- lib/webmachine/errors.rb
|
81
94
|
- lib/webmachine/headers.rb
|
82
95
|
- lib/webmachine/locale/en.yml
|
96
|
+
- lib/webmachine/media_type.rb
|
83
97
|
- lib/webmachine/request.rb
|
84
98
|
- lib/webmachine/resource/callbacks.rb
|
85
99
|
- lib/webmachine/resource/encodings.rb
|
@@ -89,19 +103,59 @@ files:
|
|
89
103
|
- lib/webmachine/translation.rb
|
90
104
|
- lib/webmachine/version.rb
|
91
105
|
- lib/webmachine.rb
|
106
|
+
- pkg/webmachine-0.1.0/examples/webrick.rb
|
107
|
+
- pkg/webmachine-0.1.0/Gemfile
|
108
|
+
- pkg/webmachine-0.1.0/Guardfile
|
109
|
+
- pkg/webmachine-0.1.0/lib/webmachine/adapters/webrick.rb
|
110
|
+
- pkg/webmachine-0.1.0/lib/webmachine/adapters.rb
|
111
|
+
- pkg/webmachine-0.1.0/lib/webmachine/decision/conneg.rb
|
112
|
+
- pkg/webmachine-0.1.0/lib/webmachine/decision/flow.rb
|
113
|
+
- pkg/webmachine-0.1.0/lib/webmachine/decision/fsm.rb
|
114
|
+
- pkg/webmachine-0.1.0/lib/webmachine/decision/helpers.rb
|
115
|
+
- pkg/webmachine-0.1.0/lib/webmachine/decision.rb
|
116
|
+
- pkg/webmachine-0.1.0/lib/webmachine/dispatcher/route.rb
|
117
|
+
- pkg/webmachine-0.1.0/lib/webmachine/dispatcher.rb
|
118
|
+
- pkg/webmachine-0.1.0/lib/webmachine/errors.rb
|
119
|
+
- pkg/webmachine-0.1.0/lib/webmachine/headers.rb
|
120
|
+
- pkg/webmachine-0.1.0/lib/webmachine/locale/en.yml
|
121
|
+
- pkg/webmachine-0.1.0/lib/webmachine/request.rb
|
122
|
+
- pkg/webmachine-0.1.0/lib/webmachine/resource/callbacks.rb
|
123
|
+
- pkg/webmachine-0.1.0/lib/webmachine/resource/encodings.rb
|
124
|
+
- pkg/webmachine-0.1.0/lib/webmachine/resource.rb
|
125
|
+
- pkg/webmachine-0.1.0/lib/webmachine/response.rb
|
126
|
+
- pkg/webmachine-0.1.0/lib/webmachine/streaming.rb
|
127
|
+
- pkg/webmachine-0.1.0/lib/webmachine/translation.rb
|
128
|
+
- pkg/webmachine-0.1.0/lib/webmachine/version.rb
|
129
|
+
- pkg/webmachine-0.1.0/lib/webmachine.rb
|
130
|
+
- pkg/webmachine-0.1.0/Rakefile
|
131
|
+
- pkg/webmachine-0.1.0/README.md
|
132
|
+
- pkg/webmachine-0.1.0/spec/spec_helper.rb
|
133
|
+
- pkg/webmachine-0.1.0/spec/tests.org
|
134
|
+
- pkg/webmachine-0.1.0/spec/webmachine/decision/conneg_spec.rb
|
135
|
+
- pkg/webmachine-0.1.0/spec/webmachine/decision/flow_spec.rb
|
136
|
+
- pkg/webmachine-0.1.0/spec/webmachine/dispatcher/route_spec.rb
|
137
|
+
- pkg/webmachine-0.1.0/spec/webmachine/dispatcher_spec.rb
|
138
|
+
- pkg/webmachine-0.1.0/spec/webmachine/headers_spec.rb
|
139
|
+
- pkg/webmachine-0.1.0/spec/webmachine/request_spec.rb
|
140
|
+
- pkg/webmachine-0.1.0/webmachine.gemspec
|
141
|
+
- pkg/webmachine-0.1.0.gem
|
92
142
|
- Rakefile
|
93
143
|
- README.md
|
94
144
|
- spec/spec_helper.rb
|
95
145
|
- spec/tests.org
|
146
|
+
- spec/webmachine/configuration_spec.rb
|
96
147
|
- spec/webmachine/decision/conneg_spec.rb
|
97
148
|
- spec/webmachine/decision/flow_spec.rb
|
149
|
+
- spec/webmachine/decision/helpers_spec.rb
|
98
150
|
- spec/webmachine/dispatcher/route_spec.rb
|
99
151
|
- spec/webmachine/dispatcher_spec.rb
|
152
|
+
- spec/webmachine/errors_spec.rb
|
100
153
|
- spec/webmachine/headers_spec.rb
|
154
|
+
- spec/webmachine/media_type_spec.rb
|
101
155
|
- spec/webmachine/request_spec.rb
|
102
156
|
- webmachine.gemspec
|
103
157
|
- .gitignore
|
104
|
-
homepage: http://
|
158
|
+
homepage: http://github.com/seancribbs/webmachine-ruby
|
105
159
|
licenses: []
|
106
160
|
post_install_message:
|
107
161
|
rdoc_options: []
|
@@ -128,10 +182,14 @@ summary: webmachine is a toolkit for building HTTP applications,
|
|
128
182
|
test_files:
|
129
183
|
- spec/spec_helper.rb
|
130
184
|
- spec/tests.org
|
185
|
+
- spec/webmachine/configuration_spec.rb
|
131
186
|
- spec/webmachine/decision/conneg_spec.rb
|
132
187
|
- spec/webmachine/decision/flow_spec.rb
|
188
|
+
- spec/webmachine/decision/helpers_spec.rb
|
133
189
|
- spec/webmachine/dispatcher/route_spec.rb
|
134
190
|
- spec/webmachine/dispatcher_spec.rb
|
191
|
+
- spec/webmachine/errors_spec.rb
|
135
192
|
- spec/webmachine/headers_spec.rb
|
193
|
+
- spec/webmachine/media_type_spec.rb
|
136
194
|
- spec/webmachine/request_spec.rb
|
137
195
|
- .gitignore
|