http_router 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/http_router.rb +9 -17
- data/lib/http_router/route.rb +1 -6
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/http_router.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
$LOAD_PATH << File.dirname(__FILE__)
|
2
2
|
require 'rack'
|
3
3
|
require 'ext/rack/uri_escape'
|
4
|
+
require 'http_router/node'
|
5
|
+
require 'http_router/root'
|
6
|
+
require 'http_router/variable'
|
7
|
+
require 'http_router/glob'
|
8
|
+
require 'http_router/route'
|
9
|
+
require 'http_router/response'
|
10
|
+
require 'http_router/path'
|
11
|
+
require 'http_router/optional_compiler'
|
4
12
|
|
5
13
|
class HttpRouter
|
6
|
-
autoload :Node, 'http_router/node'
|
7
|
-
autoload :Root, 'http_router/root'
|
8
|
-
autoload :Variable, 'http_router/variable'
|
9
|
-
autoload :Glob, 'http_router/glob'
|
10
|
-
autoload :Route, 'http_router/route'
|
11
|
-
autoload :Response, 'http_router/response'
|
12
|
-
autoload :Path, 'http_router/path'
|
13
|
-
autoload :OptionalCompiler, 'http_router/optional_compiler'
|
14
|
-
|
15
14
|
# Raised when a Route is not able to be generated.
|
16
15
|
UngeneratableRouteException = Class.new(RuntimeError)
|
17
16
|
# Raised when a Route is not able to be generated due to a missing parameter.
|
@@ -110,7 +109,7 @@ class HttpRouter
|
|
110
109
|
route
|
111
110
|
end
|
112
111
|
|
113
|
-
# Adds a path that only responds to the request
|
112
|
+
# Adds a path that only responds to the request method +GET+.
|
114
113
|
#
|
115
114
|
# Returns the route object.
|
116
115
|
def get(path, options = nil)
|
@@ -138,13 +137,6 @@ class HttpRouter
|
|
138
137
|
add(path, options).delete
|
139
138
|
end
|
140
139
|
|
141
|
-
# Adds a path that only responds to the request method +GET+.
|
142
|
-
#
|
143
|
-
# Returns the route object.
|
144
|
-
def only_get(path, options = nil)
|
145
|
-
add(path, options).only_get
|
146
|
-
end
|
147
|
-
|
148
140
|
# Returns the HttpRouter::Response object if the env is matched, otherwise, returns +nil+.
|
149
141
|
def recognize(env)
|
150
142
|
response = @root.find(env.is_a?(Hash) ? Rack::Request.new(env) : env)
|
data/lib/http_router/route.rb
CHANGED
@@ -71,7 +71,7 @@ class HttpRouter
|
|
71
71
|
self
|
72
72
|
end
|
73
73
|
|
74
|
-
# Causes this route to recognize the GET
|
74
|
+
# Causes this route to recognize the GET request method. Returns +self+.
|
75
75
|
def get
|
76
76
|
request_method('GET', 'HEAD')
|
77
77
|
end
|
@@ -96,11 +96,6 @@ class HttpRouter
|
|
96
96
|
request_method('DELETE')
|
97
97
|
end
|
98
98
|
|
99
|
-
# Causes this route to recognize the GET request method. Returns +self+.
|
100
|
-
def only_get
|
101
|
-
request_method('GET')
|
102
|
-
end
|
103
|
-
|
104
99
|
# Sets a request condition for the route
|
105
100
|
# Returns +self+.
|
106
101
|
#
|
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: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joshua Hull
|