http_router 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -6,8 +6,8 @@ desc "Run tests"
6
6
  task :test do
7
7
  $: << 'lib'
8
8
  require 'http_router'
9
- require 'test/helper'
10
- Dir['test/**/test_*.rb'].each { |test| require test }
9
+ require './test/helper'
10
+ Dir['./test/**/test_*.rb'].each { |test| require test }
11
11
  end
12
12
 
13
13
  require 'rake/rdoctask'
@@ -11,6 +11,7 @@ class HttpRouter
11
11
  if match = @matcher.match(whole_path)
12
12
  request = request.clone
13
13
  request.extra_env['router.regex_match'] = match
14
+ match.names.size.times{|i| request.params << match[i + 1]} if match.respond_to?(:names) && match.names
14
15
  super
15
16
  end
16
17
  end
@@ -5,7 +5,8 @@ class HttpRouter
5
5
  end
6
6
 
7
7
  def compile
8
- add_non_path_to_tree(@router.root.add_free_match(@original_path), path, [])
8
+ @param_names = @original_path.respond_to?(:names) ? @original_path.names.map(&:to_sym) : []
9
+ add_non_path_to_tree(@router.root.add_free_match(@original_path), path, @param_names)
9
10
  @compiled = true
10
11
  end
11
12
 
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  class HttpRouter #:nodoc
3
- VERSION = '0.6.3'
3
+ VERSION = '0.6.4'
4
4
  end
@@ -110,4 +110,12 @@ class TestVariable < MiniTest::Unit::TestCase
110
110
  assert_route with_regex, '/common/123', {:common_variable => 'common', :matched => '123'}
111
111
  assert_route without_regex, '/common/other', {:common_variable => 'common', :unmatched => 'other'}
112
112
  end
113
+
114
+ if //.respond_to?(:names)
115
+ eval "
116
+ def test_match_path_with_groups
117
+ r = router { add(%r{/(?<year>\\d{4})/(?<month>\\d{2})/(?<day>\\d{2})/?}) }
118
+ assert_route r, '/1234/23/56', {:year => '1234', :month => '23', :day => '56'}
119
+ end"
120
+ end
113
121
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_router
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 6
9
- - 3
10
- version: 0.6.3
8
+ - 4
9
+ version: 0.6.4
11
10
  platform: ruby
12
11
  authors:
13
12
  - Joshua Hull
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 23
30
28
  segments:
31
29
  - 1
32
30
  - 0
@@ -42,7 +40,6 @@ dependencies:
42
40
  requirements:
43
41
  - - ~>
44
42
  - !ruby/object:Gem::Version
45
- hash: 21
46
43
  segments:
47
44
  - 0
48
45
  - 2
@@ -58,7 +55,6 @@ dependencies:
58
55
  requirements:
59
56
  - - ~>
60
57
  - !ruby/object:Gem::Version
61
- hash: 15
62
58
  segments:
63
59
  - 2
64
60
  - 0
@@ -74,7 +70,6 @@ dependencies:
74
70
  requirements:
75
71
  - - ">="
76
72
  - !ruby/object:Gem::Version
77
- hash: 3
78
73
  segments:
79
74
  - 0
80
75
  version: "0"
@@ -88,7 +83,6 @@ dependencies:
88
83
  requirements:
89
84
  - - ">="
90
85
  - !ruby/object:Gem::Version
91
- hash: 3
92
86
  segments:
93
87
  - 0
94
88
  version: "0"
@@ -102,7 +96,6 @@ dependencies:
102
96
  requirements:
103
97
  - - ">="
104
98
  - !ruby/object:Gem::Version
105
- hash: 3
106
99
  segments:
107
100
  - 0
108
101
  version: "0"
@@ -116,7 +109,6 @@ dependencies:
116
109
  requirements:
117
110
  - - ">="
118
111
  - !ruby/object:Gem::Version
119
- hash: 3
120
112
  segments:
121
113
  - 0
122
114
  version: "0"
@@ -130,7 +122,6 @@ dependencies:
130
122
  requirements:
131
123
  - - ~>
132
124
  - !ruby/object:Gem::Version
133
- hash: 23
134
125
  segments:
135
126
  - 1
136
127
  - 0
@@ -217,7 +208,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
208
  requirements:
218
209
  - - ">="
219
210
  - !ruby/object:Gem::Version
220
- hash: 3
221
211
  segments:
222
212
  - 0
223
213
  version: "0"
@@ -226,7 +216,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
216
  requirements:
227
217
  - - ">="
228
218
  - !ruby/object:Gem::Version
229
- hash: 3
230
219
  segments:
231
220
  - 0
232
221
  version: "0"