journey 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +10 -0
- data/journey.gemspec +3 -3
- data/lib/journey/formatter.rb +2 -0
- data/lib/journey/router.rb +3 -3
- data/test/test_router.rb +28 -14
- metadata +106 -66
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
Thu Jun 14 14:03:22 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
2
|
+
|
3
|
+
* lib/journey/formatter.rb: when generating routes, skip route
|
4
|
+
literals (routes that do not have replacement values like
|
5
|
+
"/:controller") when matching unnamed routes.
|
6
|
+
|
7
|
+
https://github.com/rails/rails/issues/6459
|
8
|
+
|
9
|
+
* test/test_router.rb: corresponding test
|
10
|
+
|
1
11
|
Wed Feb 15 11:49:41 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
2
12
|
|
3
13
|
* lib/journey/formatter.rb: reject non-truthy parameters parts.
|
data/journey.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "journey"
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.4.20120614141756"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Aaron Patterson"]
|
9
|
-
s.date = "2012-
|
9
|
+
s.date = "2012-06-14"
|
10
10
|
s.description = "Journey is a router. It routes requests."
|
11
11
|
s.email = ["aaron@tenderlovemaking.com"]
|
12
12
|
s.extra_rdoc_files = ["Manifest.txt", "CHANGELOG.rdoc", "README.rdoc"]
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rdoc_options = ["--main", "README.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
s.rubyforge_project = "journey"
|
18
|
-
s.rubygems_version = "1.8.
|
18
|
+
s.rubygems_version = "1.8.22"
|
19
19
|
s.summary = "Journey is a router"
|
20
20
|
s.test_files = ["test/gtg/test_builder.rb", "test/gtg/test_transition_table.rb", "test/nfa/test_simulator.rb", "test/nfa/test_transition_table.rb", "test/nodes/test_symbol.rb", "test/path/test_pattern.rb", "test/route/definition/test_parser.rb", "test/route/definition/test_scanner.rb", "test/router/test_strexp.rb", "test/router/test_utils.rb", "test/test_route.rb", "test/test_router.rb", "test/test_routes.rb"]
|
21
21
|
|
data/lib/journey/formatter.rb
CHANGED
@@ -34,6 +34,8 @@ module Journey
|
|
34
34
|
|
35
35
|
parameterized_parts.keep_if { |_,v| v }
|
36
36
|
|
37
|
+
next if !name && route.requirements.empty? && route.parts.empty?
|
38
|
+
|
37
39
|
next unless verify_required_parts!(route, parameterized_parts)
|
38
40
|
|
39
41
|
z = Hash[options.to_a - data.to_a - route.defaults.to_a]
|
data/lib/journey/router.rb
CHANGED
@@ -17,7 +17,7 @@ module Journey
|
|
17
17
|
class RoutingError < ::StandardError
|
18
18
|
end
|
19
19
|
|
20
|
-
VERSION = '1.0.
|
20
|
+
VERSION = '1.0.4'
|
21
21
|
|
22
22
|
class NullReq # :nodoc:
|
23
23
|
attr_reader :env
|
@@ -59,8 +59,8 @@ module Journey
|
|
59
59
|
@params_key)
|
60
60
|
|
61
61
|
unless route.path.anchored
|
62
|
-
env['SCRIPT_NAME'] = script_name.to_s + match.to_s
|
63
|
-
env['PATH_INFO'] = match.post_match
|
62
|
+
env['SCRIPT_NAME'] = (script_name.to_s + match.to_s).chomp('/')
|
63
|
+
env['PATH_INFO'] = Utils.normalize_path(match.post_match)
|
64
64
|
end
|
65
65
|
|
66
66
|
env[@params_key] = (set_params || {}).merge parameters
|
data/test/test_router.rb
CHANGED
@@ -53,9 +53,9 @@ module Journey
|
|
53
53
|
def test_unicode
|
54
54
|
klass = FakeRequestFeeler.new nil
|
55
55
|
router = Router.new(routes, {})
|
56
|
-
|
56
|
+
|
57
57
|
#match the escaped version of /ほげ
|
58
|
-
exp = Router::Strexp.new '/%E3%81%BB%E3%81%92', {}, ['/.?']
|
58
|
+
exp = Router::Strexp.new '/%E3%81%BB%E3%81%92', {}, ['/.?']
|
59
59
|
path = Path::Pattern.new exp
|
60
60
|
|
61
61
|
routes.add_route nil, path, {}, {:id => nil}, {}
|
@@ -197,6 +197,19 @@ module Journey
|
|
197
197
|
assert_equal 404, resp.first
|
198
198
|
end
|
199
199
|
|
200
|
+
def test_clear_trailing_slash_from_script_name_on_root_unanchored_routes
|
201
|
+
strexp = Router::Strexp.new("/", {}, ['/', '.', '?'], false)
|
202
|
+
path = Path::Pattern.new strexp
|
203
|
+
app = lambda { |env| [200, {}, ['success!']] }
|
204
|
+
@router.routes.add_route(app, path, {}, {}, {})
|
205
|
+
|
206
|
+
env = rack_env('SCRIPT_NAME' => '', 'PATH_INFO' => '/weblog')
|
207
|
+
resp = @router.call(env)
|
208
|
+
assert_equal ['success!'], resp.last
|
209
|
+
assert_equal '', env['SCRIPT_NAME']
|
210
|
+
assert_equal '/weblog', env['PATH_INFO']
|
211
|
+
end
|
212
|
+
|
200
213
|
def test_defaults_merge_correctly
|
201
214
|
path = Path::Pattern.new '/foo(/:id)'
|
202
215
|
@router.routes.add_route nil, path, {}, {:id => nil}, {}
|
@@ -247,11 +260,11 @@ module Journey
|
|
247
260
|
"/messages/:id/edit(.:format)",
|
248
261
|
"/messages/:id(.:format)"
|
249
262
|
]
|
250
|
-
env = rails_env 'PATH_INFO' => '/messages/
|
263
|
+
env = rails_env 'PATH_INFO' => '/messages/unknown/path'
|
251
264
|
yielded = false
|
252
265
|
|
253
266
|
@router.recognize(env) do |*whatever|
|
254
|
-
yielded =
|
267
|
+
yielded = true
|
255
268
|
end
|
256
269
|
refute yielded
|
257
270
|
end
|
@@ -280,13 +293,6 @@ module Journey
|
|
280
293
|
assert_equal "/messages/index/10", path
|
281
294
|
end
|
282
295
|
|
283
|
-
def add_routes router, paths
|
284
|
-
paths.each do |path|
|
285
|
-
path = Path::Pattern.new path
|
286
|
-
router.routes.add_route nil, path, {}, {}, {}
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
296
|
def test_nil_path_parts_are_ignored
|
291
297
|
path = Path::Pattern.new "/:controller(/:action(.:format))"
|
292
298
|
@router.routes.add_route nil, path, {}, {}, {}
|
@@ -299,11 +305,12 @@ module Journey
|
|
299
305
|
end
|
300
306
|
|
301
307
|
def test_generate_slash
|
302
|
-
path = Path::Pattern.new '/'
|
303
|
-
@router.routes.add_route nil, path, {}, {}, {}
|
304
|
-
|
305
308
|
params = [ [:controller, "tasks"],
|
306
309
|
[:action, "show"] ]
|
310
|
+
str = Router::Strexp.new("/", Hash[params], ['/', '.', '?'], true)
|
311
|
+
path = Path::Pattern.new str
|
312
|
+
|
313
|
+
@router.routes.add_route nil, path, {}, {}, {}
|
307
314
|
|
308
315
|
path, _ = @formatter.generate(:path_info, nil, Hash[params], {})
|
309
316
|
assert_equal '/', path
|
@@ -501,6 +508,13 @@ module Journey
|
|
501
508
|
|
502
509
|
private
|
503
510
|
|
511
|
+
def add_routes router, paths
|
512
|
+
paths.each do |path|
|
513
|
+
path = Path::Pattern.new path
|
514
|
+
router.routes.add_route nil, path, {}, {}, {}
|
515
|
+
end
|
516
|
+
end
|
517
|
+
|
504
518
|
RailsEnv = Struct.new(:env)
|
505
519
|
|
506
520
|
def rails_env env
|
metadata
CHANGED
@@ -1,92 +1,124 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: journey
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 4
|
10
|
+
version: 1.0.4
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Aaron Patterson
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-06-14 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: minitest
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
25
|
+
requirements:
|
19
26
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 21
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 11
|
32
|
+
version: "2.11"
|
22
33
|
type: :development
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
26
36
|
name: racc
|
27
|
-
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 11
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 4
|
47
|
+
- 6
|
32
48
|
version: 1.4.6
|
33
49
|
type: :development
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
37
52
|
name: rdoc
|
38
|
-
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
55
|
none: false
|
40
|
-
requirements:
|
56
|
+
requirements:
|
41
57
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 17
|
60
|
+
segments:
|
61
|
+
- 3
|
62
|
+
- 11
|
63
|
+
version: "3.11"
|
44
64
|
type: :development
|
45
|
-
|
46
|
-
|
47
|
-
- !ruby/object:Gem::Dependency
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
48
67
|
name: json
|
49
|
-
|
68
|
+
prerelease: false
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
70
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
55
78
|
type: :development
|
56
|
-
|
57
|
-
|
58
|
-
- !ruby/object:Gem::Dependency
|
79
|
+
version_requirements: *id004
|
80
|
+
- !ruby/object:Gem::Dependency
|
59
81
|
name: rdoc
|
60
|
-
|
82
|
+
prerelease: false
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
61
84
|
none: false
|
62
|
-
requirements:
|
85
|
+
requirements:
|
63
86
|
- - ~>
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 19
|
89
|
+
segments:
|
90
|
+
- 3
|
91
|
+
- 10
|
92
|
+
version: "3.10"
|
66
93
|
type: :development
|
67
|
-
|
68
|
-
|
69
|
-
- !ruby/object:Gem::Dependency
|
94
|
+
version_requirements: *id005
|
95
|
+
- !ruby/object:Gem::Dependency
|
70
96
|
name: hoe
|
71
|
-
|
97
|
+
prerelease: false
|
98
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
72
99
|
none: false
|
73
|
-
requirements:
|
100
|
+
requirements:
|
74
101
|
- - ~>
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 25
|
104
|
+
segments:
|
105
|
+
- 2
|
106
|
+
- 13
|
107
|
+
version: "2.13"
|
77
108
|
type: :development
|
78
|
-
|
79
|
-
version_requirements: *70295885779180
|
109
|
+
version_requirements: *id006
|
80
110
|
description: Journey is a router. It routes requests.
|
81
|
-
email:
|
111
|
+
email:
|
82
112
|
- aaron@tenderlovemaking.com
|
83
113
|
executables: []
|
114
|
+
|
84
115
|
extensions: []
|
85
|
-
|
116
|
+
|
117
|
+
extra_rdoc_files:
|
86
118
|
- Manifest.txt
|
87
119
|
- CHANGELOG.rdoc
|
88
120
|
- README.rdoc
|
89
|
-
files:
|
121
|
+
files:
|
90
122
|
- .autotest
|
91
123
|
- .gemtest
|
92
124
|
- .travis.yml
|
@@ -138,31 +170,39 @@ files:
|
|
138
170
|
- test/test_routes.rb
|
139
171
|
homepage: http://github.com/rails/journey
|
140
172
|
licenses: []
|
173
|
+
|
141
174
|
post_install_message:
|
142
|
-
rdoc_options:
|
175
|
+
rdoc_options:
|
143
176
|
- --main
|
144
177
|
- README.rdoc
|
145
|
-
require_paths:
|
178
|
+
require_paths:
|
146
179
|
- lib
|
147
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
180
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
181
|
none: false
|
149
|
-
requirements:
|
150
|
-
- -
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
|
153
|
-
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
hash: 3
|
186
|
+
segments:
|
187
|
+
- 0
|
188
|
+
version: "0"
|
189
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
190
|
none: false
|
155
|
-
requirements:
|
156
|
-
- -
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
hash: 3
|
195
|
+
segments:
|
196
|
+
- 0
|
197
|
+
version: "0"
|
159
198
|
requirements: []
|
199
|
+
|
160
200
|
rubyforge_project: journey
|
161
|
-
rubygems_version: 1.8.
|
201
|
+
rubygems_version: 1.8.22
|
162
202
|
signing_key:
|
163
203
|
specification_version: 3
|
164
204
|
summary: Journey is a router
|
165
|
-
test_files:
|
205
|
+
test_files:
|
166
206
|
- test/gtg/test_builder.rb
|
167
207
|
- test/gtg/test_transition_table.rb
|
168
208
|
- test/nfa/test_simulator.rb
|