http_router 0.7.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/http_router.rb +5 -7
- data/lib/http_router/route.rb +1 -0
- data/lib/http_router/version.rb +1 -1
- data/test/test_variable.rb +5 -0
- metadata +3 -3
data/lib/http_router.rb
CHANGED
@@ -71,7 +71,7 @@ class HttpRouter
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def set_pass_on_response(&blk)
|
74
|
-
extend(Module.new{define_method(:pass_on_response, &blk)})
|
74
|
+
extend(Module.new { define_method(:pass_on_response, &blk) })
|
75
75
|
end
|
76
76
|
|
77
77
|
# Adds a path that only responds to the request method +GET+.
|
@@ -120,10 +120,10 @@ class HttpRouter
|
|
120
120
|
else
|
121
121
|
request = Request.new(rack_request.path_info, rack_request, perform_call)
|
122
122
|
response = catch(:success) { @root[request] }
|
123
|
-
if response
|
124
|
-
no_response(env, perform_call)
|
125
|
-
elsif response
|
123
|
+
if response
|
126
124
|
response
|
125
|
+
elsif response.nil?
|
126
|
+
no_response(env, perform_call)
|
127
127
|
elsif perform_call
|
128
128
|
@default_app.call(env)
|
129
129
|
else
|
@@ -134,10 +134,8 @@ class HttpRouter
|
|
134
134
|
|
135
135
|
# Resets the router to a clean state.
|
136
136
|
def reset!
|
137
|
-
@root = Node.new(self)
|
137
|
+
@routes, @named_routes, @root = [], {}, Node.new(self)
|
138
138
|
@default_app = Proc.new{ |env| ::Rack::Response.new("Your request couldn't be found", 404).finish }
|
139
|
-
@routes = []
|
140
|
-
@named_routes = {}
|
141
139
|
end
|
142
140
|
|
143
141
|
# Assigns the default application.
|
data/lib/http_router/route.rb
CHANGED
data/lib/http_router/version.rb
CHANGED
data/test/test_variable.rb
CHANGED
@@ -76,6 +76,11 @@ class TestVariable < MiniTest::Unit::TestCase
|
|
76
76
|
assert_route r, '/foo', {:test => 'foo'}
|
77
77
|
end
|
78
78
|
|
79
|
+
def test_var_with_optional_format_and_regex
|
80
|
+
r = router { add('/:test(.:format)', :format => /[^\.]+/) }
|
81
|
+
assert_route r, '/asd@asd.com.json', {:test => 'asd@asd.com', :format => 'json'}
|
82
|
+
end
|
83
|
+
|
79
84
|
def test_glob
|
80
85
|
assert_route '/test/*variable', 'test/one/two/three', {:variable => ['one', 'two', 'three']}
|
81
86
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_router
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 4
|
10
|
+
version: 0.7.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joshua Hull
|