http_router 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/http_router/node/destination.rb +2 -1
- data/lib/http_router/node/glob.rb +3 -5
- data/lib/http_router/version.rb +1 -1
- data/lib/http_router.rb +2 -2
- data/test/test_variable.rb +4 -0
- metadata +222 -172
@@ -21,6 +21,7 @@ class HttpRouter
|
|
21
21
|
#{"if request.path.empty?#{" or (request.path.size == 1 and request.path.first == '')" if @router.ignore_trailing_slash?}" unless @allow_partial}
|
22
22
|
if request.perform_call
|
23
23
|
env = request.rack_request.dup.env
|
24
|
+
env['router.request'] = request
|
24
25
|
env['router.params'] ||= {}
|
25
26
|
#{"env['router.params'].merge!(Hash[#{path.param_names.inspect}.zip(request.params)])" if path.dynamic?}
|
26
27
|
#{@allow_partial ? "
|
@@ -29,7 +30,7 @@ class HttpRouter
|
|
29
30
|
"env['PATH_INFO'] = ''
|
30
31
|
env['SCRIPT_NAME'] += request.rack_request.path_info"
|
31
32
|
}
|
32
|
-
response = @router.
|
33
|
+
response = @router.process_destination_path(#{path_ivar}, env)
|
33
34
|
router.pass_on_response(response) ? throw(:pass) : throw(:success, response)
|
34
35
|
else
|
35
36
|
throw :success, Response.new(request, #{path_ivar})
|
@@ -8,13 +8,11 @@ class HttpRouter
|
|
8
8
|
|
9
9
|
def to_code
|
10
10
|
"request.params << (globbed_params#{depth} = [])
|
11
|
-
|
12
|
-
|
13
|
-
globbed_params#{depth} << remaining_parts.shift
|
14
|
-
request.path = remaining_parts
|
11
|
+
until request.path.empty?
|
12
|
+
globbed_params#{depth} << request.path.shift
|
15
13
|
#{super}
|
16
14
|
end
|
17
|
-
request.path[0,0] =
|
15
|
+
request.path[0,0] = globbed_params#{depth}"
|
18
16
|
end
|
19
17
|
end
|
20
18
|
end
|
data/lib/http_router/version.rb
CHANGED
data/lib/http_router.rb
CHANGED
data/test/test_variable.rb
CHANGED
@@ -90,6 +90,10 @@ class TestVariable < MiniTest::Unit::TestCase
|
|
90
90
|
assert_route '/test/*variable/test', '/test/one/two/three/test', {:variable => ['one', 'two', 'three']}
|
91
91
|
end
|
92
92
|
|
93
|
+
def test_double_glob_all_the_way
|
94
|
+
assert_route '/test/*variable/test/*variable2', '/test/one/two/three/test/four/five/six', {:variable => ['one', 'two', 'three'], :variable2 => ['four', 'five', 'six']}
|
95
|
+
end
|
96
|
+
|
93
97
|
def test_glob_with_regexp
|
94
98
|
r = router { add('/test/*variable', :variable => /[a-z]+/) }
|
95
99
|
assert_route nil, '/test/asd/123'
|
metadata
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_router
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 55
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 8
|
9
|
+
- 4
|
10
|
+
version: 0.8.4
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
|
-
|
13
|
+
- Joshua Hull
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
@@ -13,105 +18,144 @@ cert_chain: []
|
|
13
18
|
date: 2011-06-02 00:00:00 -07:00
|
14
19
|
default_executable:
|
15
20
|
dependencies:
|
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
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 23
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
version: 1.0.0
|
33
|
+
requirement: *id001
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
name: rack
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 21
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
- 2
|
47
|
+
- 1
|
48
|
+
version: 0.2.1
|
49
|
+
requirement: *id002
|
50
|
+
prerelease: false
|
51
|
+
type: :runtime
|
52
|
+
name: url_mount
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 15
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 0
|
63
|
+
- 0
|
64
|
+
version: 2.0.0
|
65
|
+
requirement: *id003
|
66
|
+
prerelease: false
|
67
|
+
type: :development
|
68
|
+
name: minitest
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
requirement: *id004
|
80
|
+
prerelease: false
|
81
|
+
type: :development
|
82
|
+
name: code_stats
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 49
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
- 8
|
93
|
+
- 7
|
94
|
+
version: 0.8.7
|
95
|
+
requirement: *id005
|
96
|
+
prerelease: false
|
97
|
+
type: :development
|
98
|
+
name: rake
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
hash: 3
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
version: "0"
|
109
|
+
requirement: *id006
|
110
|
+
prerelease: false
|
111
|
+
type: :development
|
112
|
+
name: rbench
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
requirement: *id007
|
124
|
+
prerelease: false
|
125
|
+
type: :development
|
126
|
+
name: phocus
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
hash: 23
|
134
|
+
segments:
|
135
|
+
- 1
|
136
|
+
- 0
|
137
|
+
- 0
|
138
|
+
version: 1.0.0
|
139
|
+
requirement: *id008
|
140
|
+
prerelease: false
|
141
|
+
type: :development
|
142
|
+
name: bundler
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - "="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
hash: 15
|
150
|
+
segments:
|
151
|
+
- 1
|
152
|
+
- 2
|
153
|
+
- 8
|
154
|
+
version: 1.2.8
|
155
|
+
requirement: *id009
|
156
|
+
prerelease: false
|
157
|
+
type: :development
|
158
|
+
name: thin
|
115
159
|
description: This library allows you to recognize and build URLs in a Rack application.
|
116
160
|
email: joshbuddy@gmail.com
|
117
161
|
executables: []
|
@@ -119,94 +163,100 @@ executables: []
|
|
119
163
|
extensions: []
|
120
164
|
|
121
165
|
extra_rdoc_files:
|
122
|
-
|
123
|
-
|
166
|
+
- README.md
|
167
|
+
- LICENSE
|
124
168
|
files:
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
169
|
+
- .gitignore
|
170
|
+
- .rspec
|
171
|
+
- Gemfile
|
172
|
+
- LICENSE
|
173
|
+
- README.md
|
174
|
+
- Rakefile
|
175
|
+
- benchmarks/gen2.rb
|
176
|
+
- benchmarks/generation_bm.rb
|
177
|
+
- benchmarks/rack_mount.rb
|
178
|
+
- benchmarks/rack_recognition_bm.rb
|
179
|
+
- benchmarks/rec2.rb
|
180
|
+
- benchmarks/recognition_bm.rb
|
181
|
+
- examples/glob.ru
|
182
|
+
- examples/rack_mapper.ru
|
183
|
+
- examples/simple.ru
|
184
|
+
- examples/static/config.ru
|
185
|
+
- examples/static/favicon.ico
|
186
|
+
- examples/static/images/cat1.jpg
|
187
|
+
- examples/static/images/cat2.jpg
|
188
|
+
- examples/static/images/cat3.jpg
|
189
|
+
- examples/variable.ru
|
190
|
+
- examples/variable_with_regex.ru
|
191
|
+
- http_router.gemspec
|
192
|
+
- lib/http_router.rb
|
193
|
+
- lib/http_router/node.rb
|
194
|
+
- lib/http_router/node/arbitrary.rb
|
195
|
+
- lib/http_router/node/destination.rb
|
196
|
+
- lib/http_router/node/free_regex.rb
|
197
|
+
- lib/http_router/node/glob.rb
|
198
|
+
- lib/http_router/node/glob_regex.rb
|
199
|
+
- lib/http_router/node/lookup.rb
|
200
|
+
- lib/http_router/node/regex.rb
|
201
|
+
- lib/http_router/node/request.rb
|
202
|
+
- lib/http_router/node/root.rb
|
203
|
+
- lib/http_router/node/spanning_regex.rb
|
204
|
+
- lib/http_router/node/variable.rb
|
205
|
+
- lib/http_router/optional_compiler.rb
|
206
|
+
- lib/http_router/path.rb
|
207
|
+
- lib/http_router/rack.rb
|
208
|
+
- lib/http_router/rack/builder.rb
|
209
|
+
- lib/http_router/rack/url_map.rb
|
210
|
+
- lib/http_router/regex_route.rb
|
211
|
+
- lib/http_router/request.rb
|
212
|
+
- lib/http_router/response.rb
|
213
|
+
- lib/http_router/route.rb
|
214
|
+
- lib/http_router/version.rb
|
215
|
+
- test/helper.rb
|
216
|
+
- test/rack/test_dispatch.rb
|
217
|
+
- test/rack/test_route.rb
|
218
|
+
- test/rack/test_urlmap.rb
|
219
|
+
- test/test_arbitrary.rb
|
220
|
+
- test/test_generate.rb
|
221
|
+
- test/test_greedy.rb
|
222
|
+
- test/test_interstitial.rb
|
223
|
+
- test/test_misc.rb
|
224
|
+
- test/test_mounting.rb
|
225
|
+
- test/test_recognize.rb
|
226
|
+
- test/test_request.rb
|
227
|
+
- test/test_trailing_slash.rb
|
228
|
+
- test/test_variable.rb
|
185
229
|
has_rdoc: true
|
186
230
|
homepage: http://github.com/joshbuddy/http_router
|
187
231
|
licenses: []
|
188
232
|
|
189
233
|
post_install_message:
|
190
234
|
rdoc_options:
|
191
|
-
|
235
|
+
- --charset=UTF-8
|
192
236
|
require_paths:
|
193
|
-
|
237
|
+
- lib
|
194
238
|
required_ruby_version: !ruby/object:Gem::Requirement
|
195
239
|
none: false
|
196
240
|
requirements:
|
197
|
-
|
198
|
-
|
199
|
-
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
hash: 3
|
244
|
+
segments:
|
245
|
+
- 0
|
246
|
+
version: "0"
|
200
247
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
248
|
none: false
|
202
249
|
requirements:
|
203
|
-
|
204
|
-
|
205
|
-
|
250
|
+
- - ">="
|
251
|
+
- !ruby/object:Gem::Version
|
252
|
+
hash: 3
|
253
|
+
segments:
|
254
|
+
- 0
|
255
|
+
version: "0"
|
206
256
|
requirements: []
|
207
257
|
|
208
258
|
rubyforge_project: http_router
|
209
|
-
rubygems_version: 1.
|
259
|
+
rubygems_version: 1.6.2
|
210
260
|
signing_key:
|
211
261
|
specification_version: 3
|
212
262
|
summary: A kick-ass HTTP router for use in Rack
|