http_router 0.7.9 → 0.7.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_runtime_dependency 'url_mount', '~> 0.2.1'
25
25
  s.add_development_dependency 'minitest', '~> 2.0.0'
26
26
  s.add_development_dependency 'code_stats'
27
- s.add_development_dependency 'rake'
27
+ s.add_development_dependency 'rake', '~> 0.8.7'
28
28
  s.add_development_dependency 'rbench'
29
29
  s.add_development_dependency 'phocus'
30
30
  s.add_development_dependency 'bundler', '~> 1.0.0'
@@ -54,8 +54,7 @@ class HttpRouter
54
54
  end
55
55
 
56
56
  def add_lookup(part)
57
- add(Lookup.new(@router))
58
- @matchers.last.add(part)
57
+ add(Lookup.new(@router)).add(part)
59
58
  end
60
59
 
61
60
  def usable?(other)
@@ -8,7 +8,7 @@ class HttpRouter
8
8
 
9
9
  def [](request)
10
10
  if request.path.empty? or (request.path.size == 1 and request.path[0] == '') or @allow_partial
11
- catch(:pass) do
11
+ request.passed_with = catch(:pass) do
12
12
  request = request.clone
13
13
  request.continue = proc { |state| destination(request) if state }
14
14
  params = @param_names.nil? ? {} : Hash[@param_names.zip(request.params)]
@@ -1,3 +1,4 @@
1
+ require 'uri'
1
2
  class HttpRouter
2
3
  class Path
3
4
  attr_reader :route, :param_names
@@ -41,8 +42,7 @@ class HttpRouter
41
42
  path = raw_url(args, options)
42
43
  raise InvalidRouteException if path !~ @path_validation_regex
43
44
  raise TooManyParametersException unless args.empty?
44
- uri_escape!(path)
45
- [path, options]
45
+ [URI.escape(path), options]
46
46
  end
47
47
 
48
48
  def original_path
@@ -53,9 +53,5 @@ class HttpRouter
53
53
  def raw_url(args, options)
54
54
  raise UngeneratableRouteException
55
55
  end
56
-
57
- def uri_escape!(s)
58
- s.to_s.gsub!(/([^:\/?\[\]\-_~\.!\$&'\(\)\*\+,;=@a-zA-Z0-9]+)/n) { "%#{$1.unpack('H2'*$1.size).join('%').upcase}" }
59
- end
60
56
  end
61
57
  end
@@ -1,7 +1,7 @@
1
1
  class HttpRouter
2
2
  class Request
3
3
  attr_reader :acceptance_test
4
- attr_accessor :path, :params, :rack_request, :extra_env, :continue
4
+ attr_accessor :path, :params, :rack_request, :extra_env, :continue, :passed_with
5
5
  alias_method :rack, :rack_request
6
6
  def initialize(path, rack_request, perform_call, &acceptance_test)
7
7
  @rack_request, @perform_call, @acceptance_test = rack_request, perform_call, acceptance_test
@@ -120,6 +120,7 @@ class HttpRouter
120
120
  def delete; request_method('DELETE'); end
121
121
  def head; request_method('HEAD'); end
122
122
  def options; request_method('OPTIONS'); end
123
+ def patch; request_method('PATCH'); end
123
124
 
124
125
  def arbitrary(blk = nil, &blk2)
125
126
  arbitrary_with_continue { |req, params|
@@ -273,7 +274,7 @@ class HttpRouter
273
274
  router.pass_on_response(response) ? throw(:pass) : throw(:success, response)
274
275
  elsif req.acceptance_test
275
276
  response = Response.new(req, path_obj)
276
- catch(:pass) { req.acceptance_test[response] }
277
+ req.passed_with = catch(:pass) { req.acceptance_test[response] }
277
278
  throw :success, response if response.acceptance_response
278
279
  else
279
280
  throw :success, Response.new(req, path_obj)
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  class HttpRouter #:nodoc
3
- VERSION = '0.7.9'
3
+ VERSION = '0.7.10'
4
4
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'minitest/autorun'
2
3
  require 'phocus'
3
4
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class TestGenerate < MiniTest::Unit::TestCase
2
3
 
3
4
  def test_static
@@ -86,6 +87,10 @@ class TestGenerate < MiniTest::Unit::TestCase
86
87
  assert_generate '/url', "/url(/:var)", :var => nil
87
88
  end
88
89
 
90
+ def test_unicode
91
+ assert_generate '/%C3%A4', "/:var", :var => 'ä'
92
+ end
93
+
89
94
  def test_raise
90
95
  r = router { add(':var').matching(:var => /\d+/) }
91
96
  assert_raises(HttpRouter::InvalidRouteException) { router.url(r, 'asd') }
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  class TestRecognition < MiniTest::Unit::TestCase
2
3
  def test_empty
3
4
  assert_route router.add(''), '/'
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_router
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 9
10
- version: 0.7.9
5
+ version: 0.7.10
11
6
  platform: ruby
12
7
  authors:
13
8
  - Joshua Hull
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-05-13 00:00:00 -07:00
13
+ date: 2011-05-30 00:00:00 -07:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,11 +21,6 @@ dependencies:
26
21
  requirements:
27
22
  - - ">="
28
23
  - !ruby/object:Gem::Version
29
- hash: 23
30
- segments:
31
- - 1
32
- - 0
33
- - 0
34
24
  version: 1.0.0
35
25
  type: :runtime
36
26
  version_requirements: *id001
@@ -42,11 +32,6 @@ dependencies:
42
32
  requirements:
43
33
  - - ~>
44
34
  - !ruby/object:Gem::Version
45
- hash: 21
46
- segments:
47
- - 0
48
- - 2
49
- - 1
50
35
  version: 0.2.1
51
36
  type: :runtime
52
37
  version_requirements: *id002
@@ -58,11 +43,6 @@ dependencies:
58
43
  requirements:
59
44
  - - ~>
60
45
  - !ruby/object:Gem::Version
61
- hash: 15
62
- segments:
63
- - 2
64
- - 0
65
- - 0
66
46
  version: 2.0.0
67
47
  type: :development
68
48
  version_requirements: *id003
@@ -74,9 +54,6 @@ dependencies:
74
54
  requirements:
75
55
  - - ">="
76
56
  - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
57
  version: "0"
81
58
  type: :development
82
59
  version_requirements: *id004
@@ -86,12 +63,9 @@ dependencies:
86
63
  requirement: &id005 !ruby/object:Gem::Requirement
87
64
  none: false
88
65
  requirements:
89
- - - ">="
66
+ - - ~>
90
67
  - !ruby/object:Gem::Version
91
- hash: 3
92
- segments:
93
- - 0
94
- version: "0"
68
+ version: 0.8.7
95
69
  type: :development
96
70
  version_requirements: *id005
97
71
  - !ruby/object:Gem::Dependency
@@ -102,9 +76,6 @@ dependencies:
102
76
  requirements:
103
77
  - - ">="
104
78
  - !ruby/object:Gem::Version
105
- hash: 3
106
- segments:
107
- - 0
108
79
  version: "0"
109
80
  type: :development
110
81
  version_requirements: *id006
@@ -116,9 +87,6 @@ dependencies:
116
87
  requirements:
117
88
  - - ">="
118
89
  - !ruby/object:Gem::Version
119
- hash: 3
120
- segments:
121
- - 0
122
90
  version: "0"
123
91
  type: :development
124
92
  version_requirements: *id007
@@ -130,11 +98,6 @@ dependencies:
130
98
  requirements:
131
99
  - - ~>
132
100
  - !ruby/object:Gem::Version
133
- hash: 23
134
- segments:
135
- - 1
136
- - 0
137
- - 0
138
101
  version: 1.0.0
139
102
  type: :development
140
103
  version_requirements: *id008
@@ -146,11 +109,6 @@ dependencies:
146
109
  requirements:
147
110
  - - "="
148
111
  - !ruby/object:Gem::Version
149
- hash: 15
150
- segments:
151
- - 1
152
- - 2
153
- - 8
154
112
  version: 1.2.8
155
113
  type: :development
156
114
  version_requirements: *id009
@@ -237,18 +195,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
237
195
  requirements:
238
196
  - - ">="
239
197
  - !ruby/object:Gem::Version
240
- hash: 3
241
- segments:
242
- - 0
243
198
  version: "0"
244
199
  required_rubygems_version: !ruby/object:Gem::Requirement
245
200
  none: false
246
201
  requirements:
247
202
  - - ">="
248
203
  - !ruby/object:Gem::Version
249
- hash: 3
250
- segments:
251
- - 0
252
204
  version: "0"
253
205
  requirements: []
254
206