joshbuddy-usher 0.4.10 → 0.4.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -0
- data/VERSION.yml +1 -1
- data/lib/usher.rb +9 -0
- data/spec/private/recognize_spec.rb +8 -0
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -57,6 +57,15 @@ But not
|
|
57
57
|
As well, the same logic applies for * variables as well, where only parts matchable by the supplied regex will
|
58
58
|
actually be bound to the variable
|
59
59
|
|
60
|
+
Variables can also have a greedy regex matcher. These matchers ignore all delimiters, and continue matching for as long as much as their
|
61
|
+
regex allows.
|
62
|
+
|
63
|
+
<b>Example:</b>
|
64
|
+
<tt>/product/{!id,hello/world|hello}</tt> would match
|
65
|
+
|
66
|
+
* <tt>/product/hello/world</tt>
|
67
|
+
* <tt>/product/hello</tt>
|
68
|
+
|
60
69
|
==== Static
|
61
70
|
|
62
71
|
Static parts of literal character sequences. For instance, <tt>/path/something.html</tt> would match only the same path.
|
data/VERSION.yml
CHANGED
data/lib/usher.rb
CHANGED
@@ -125,6 +125,15 @@ class Usher
|
|
125
125
|
# As well, the same logic applies for * variables as well, where only parts matchable by the supplied regex will
|
126
126
|
# actually be bound to the variable
|
127
127
|
#
|
128
|
+
# Variables can also have a greedy regex matcher. These matchers ignore all delimiters, and continue matching for as long as much as their
|
129
|
+
# regex allows.
|
130
|
+
#
|
131
|
+
# <b>Example:</b>
|
132
|
+
# <tt>/product/{!id,hello/world|hello}</tt> would match
|
133
|
+
#
|
134
|
+
# * <tt>/product/hello/world</tt>
|
135
|
+
# * <tt>/product/hello</tt>
|
136
|
+
#
|
128
137
|
# ==== Static
|
129
138
|
#
|
130
139
|
# Static parts of literal character sequences. For instance, <tt>/path/something.html</tt> would match only the same path.
|
@@ -99,6 +99,14 @@ describe "Usher route recognition" do
|
|
99
99
|
route_set.recognize(build_request({:method => 'get', :path => '/test/part/one/more/time'})).params.should == [[:test, 'one/more/time']]
|
100
100
|
end
|
101
101
|
|
102
|
+
it "should recgonize a greedy regex that matches across / and not" do
|
103
|
+
target_route = route_set.add_route('/test/part/{!test,one/more|one}')
|
104
|
+
route_set.recognize(build_request({:method => 'get', :path => '/test/part/one/more'})).path.route.should == target_route
|
105
|
+
route_set.recognize(build_request({:method => 'get', :path => '/test/part/one/more'})).params.should == [[:test, 'one/more']]
|
106
|
+
route_set.recognize(build_request({:method => 'get', :path => '/test/part/one'})).path.route.should == target_route
|
107
|
+
route_set.recognize(build_request({:method => 'get', :path => '/test/part/one'})).params.should == [[:test, 'one']]
|
108
|
+
end
|
109
|
+
|
102
110
|
it "should recgonize a greedy regex single variable with static parts after" do
|
103
111
|
target_route = route_set.add_route('/test/part/{!test,one/more/time}/help')
|
104
112
|
route_set.recognize(build_request({:method => 'get', :path => '/test/part/one/more/time/help'})).path.route.should == target_route
|