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.
@@ -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.process_destination(#{path_ivar}.route.dest, env)
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
- remaining_parts = request.path.dup
12
- until remaining_parts.empty?
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] = request.params.pop"
15
+ request.path[0,0] = globbed_params#{depth}"
18
16
  end
19
17
  end
20
18
  end
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  class HttpRouter #:nodoc
3
- VERSION = '0.8.3'
3
+ VERSION = '0.8.4'
4
4
  end
data/lib/http_router.rb CHANGED
@@ -161,8 +161,8 @@ class HttpRouter
161
161
  end
162
162
  end
163
163
 
164
- def process_destination(destination, env)
165
- destination.call(env)
164
+ def process_destination_path(path, env)
165
+ path.route.dest.call(env)
166
166
  end
167
167
 
168
168
  def pass_on_response(response)
@@ -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
- version: 0.8.3
6
+ segments:
7
+ - 0
8
+ - 8
9
+ - 4
10
+ version: 0.8.4
6
11
  platform: ruby
7
12
  authors:
8
- - Joshua Hull
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
- - !ruby/object:Gem::Dependency
17
- name: rack
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
20
- none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: 1.0.0
25
- type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: url_mount
29
- prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
31
- none: false
32
- requirements:
33
- - - ~>
34
- - !ruby/object:Gem::Version
35
- version: 0.2.1
36
- type: :runtime
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: minitest
40
- prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ~>
45
- - !ruby/object:Gem::Version
46
- version: 2.0.0
47
- type: :development
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: code_stats
51
- prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0"
58
- type: :development
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: rake
62
- prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
64
- none: false
65
- requirements:
66
- - - ~>
67
- - !ruby/object:Gem::Version
68
- version: 0.8.7
69
- type: :development
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
72
- name: rbench
73
- prerelease: false
74
- requirement: &id006 !ruby/object:Gem::Requirement
75
- none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: "0"
80
- type: :development
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: phocus
84
- prerelease: false
85
- requirement: &id007 !ruby/object:Gem::Requirement
86
- none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: "0"
91
- type: :development
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
94
- name: bundler
95
- prerelease: false
96
- requirement: &id008 !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ~>
100
- - !ruby/object:Gem::Version
101
- version: 1.0.0
102
- type: :development
103
- version_requirements: *id008
104
- - !ruby/object:Gem::Dependency
105
- name: thin
106
- prerelease: false
107
- requirement: &id009 !ruby/object:Gem::Requirement
108
- none: false
109
- requirements:
110
- - - "="
111
- - !ruby/object:Gem::Version
112
- version: 1.2.8
113
- type: :development
114
- version_requirements: *id009
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
- - README.md
123
- - LICENSE
166
+ - README.md
167
+ - LICENSE
124
168
  files:
125
- - .gitignore
126
- - .rspec
127
- - Gemfile
128
- - LICENSE
129
- - README.md
130
- - Rakefile
131
- - benchmarks/gen2.rb
132
- - benchmarks/generation_bm.rb
133
- - benchmarks/rack_mount.rb
134
- - benchmarks/rack_recognition_bm.rb
135
- - benchmarks/rec2.rb
136
- - benchmarks/recognition_bm.rb
137
- - examples/glob.ru
138
- - examples/rack_mapper.ru
139
- - examples/simple.ru
140
- - examples/static/config.ru
141
- - examples/static/favicon.ico
142
- - examples/static/images/cat1.jpg
143
- - examples/static/images/cat2.jpg
144
- - examples/static/images/cat3.jpg
145
- - examples/variable.ru
146
- - examples/variable_with_regex.ru
147
- - http_router.gemspec
148
- - lib/http_router.rb
149
- - lib/http_router/node.rb
150
- - lib/http_router/node/arbitrary.rb
151
- - lib/http_router/node/destination.rb
152
- - lib/http_router/node/free_regex.rb
153
- - lib/http_router/node/glob.rb
154
- - lib/http_router/node/glob_regex.rb
155
- - lib/http_router/node/lookup.rb
156
- - lib/http_router/node/regex.rb
157
- - lib/http_router/node/request.rb
158
- - lib/http_router/node/root.rb
159
- - lib/http_router/node/spanning_regex.rb
160
- - lib/http_router/node/variable.rb
161
- - lib/http_router/optional_compiler.rb
162
- - lib/http_router/path.rb
163
- - lib/http_router/rack.rb
164
- - lib/http_router/rack/builder.rb
165
- - lib/http_router/rack/url_map.rb
166
- - lib/http_router/regex_route.rb
167
- - lib/http_router/request.rb
168
- - lib/http_router/response.rb
169
- - lib/http_router/route.rb
170
- - lib/http_router/version.rb
171
- - test/helper.rb
172
- - test/rack/test_dispatch.rb
173
- - test/rack/test_route.rb
174
- - test/rack/test_urlmap.rb
175
- - test/test_arbitrary.rb
176
- - test/test_generate.rb
177
- - test/test_greedy.rb
178
- - test/test_interstitial.rb
179
- - test/test_misc.rb
180
- - test/test_mounting.rb
181
- - test/test_recognize.rb
182
- - test/test_request.rb
183
- - test/test_trailing_slash.rb
184
- - test/test_variable.rb
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
- - --charset=UTF-8
235
+ - --charset=UTF-8
192
236
  require_paths:
193
- - lib
237
+ - lib
194
238
  required_ruby_version: !ruby/object:Gem::Requirement
195
239
  none: false
196
240
  requirements:
197
- - - ">="
198
- - !ruby/object:Gem::Version
199
- version: "0"
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
- - !ruby/object:Gem::Version
205
- version: "0"
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.5.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