rack-mount 0.6.3 → 0.6.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/README.rdoc +12 -4
- data/lib/rack/mount/regexp_with_named_groups.rb +1 -1
- data/lib/rack/mount/utils.rb +4 -2
- data/lib/rack/mount/version.rb +1 -1
- metadata +9 -4
data/README.rdoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
A stackable dynamic tree based Rack router.
|
4
4
|
|
5
|
-
Rack::Mount supports Rack's Cascade
|
5
|
+
Rack::Mount supports Rack's +X-Cascade+ convention to continue trying routes if the response returns +pass+. This allows multiple routes to be nested or stacked on top of each other. Since the application endpoint can trigger the router to continue matching, middleware can be used to add arbitrary conditions to any route. This allows you to route based on other request attributes, session information, or even data dynamically pulled from a database.
|
6
6
|
|
7
7
|
=== Usage
|
8
8
|
|
@@ -12,17 +12,25 @@ The API is extremely minimal and only 3 methods are exposed as the public API.
|
|
12
12
|
|
13
13
|
<tt>Rack::Mount::RouteSet#add_route</tt>:: builder method for adding routes to the set
|
14
14
|
<tt>Rack::Mount::RouteSet#call</tt>:: Rack compatible recognition and dispatching method
|
15
|
-
<tt>Rack::Mount::RouteSet#
|
15
|
+
<tt>Rack::Mount::RouteSet#generate</tt>:: generates a route condition from identifiers or significant keys
|
16
16
|
|
17
17
|
=== Example
|
18
18
|
|
19
19
|
require 'rack/mount'
|
20
|
+
|
20
21
|
Routes = Rack::Mount::RouteSet.new do |set|
|
21
22
|
# add_route takes a rack application and conditions to match with
|
22
|
-
#
|
23
|
+
#
|
24
|
+
# valid conditions methods are any method on Rack::Request
|
25
|
+
# the values to match against may be strings or regexps
|
26
|
+
#
|
23
27
|
# See Rack::Mount::RouteSet#add_route for more options.
|
24
|
-
set.add_route FooApp, :
|
28
|
+
set.add_route FooApp, { :request_method => 'GET', :path_info => %r{^/foo$} }, {}, :foo
|
25
29
|
end
|
26
30
|
|
27
31
|
# The route set itself is a simple rack app you mount
|
28
32
|
run Routes
|
33
|
+
|
34
|
+
|
35
|
+
# generate path for route named "foo"
|
36
|
+
Routes.generate(:path_info, :foo) #=> "/foo"
|
data/lib/rack/mount/utils.rb
CHANGED
@@ -52,14 +52,16 @@ module Rack::Mount
|
|
52
52
|
UNSAFE_PCHAR = Regexp.new("[^#{SAFE_PCHAR}]", false, 'N').freeze
|
53
53
|
end
|
54
54
|
|
55
|
+
Parser = URI.const_defined?(:Parser) ? URI::Parser.new : URI
|
56
|
+
|
55
57
|
def escape_uri(uri)
|
56
|
-
|
58
|
+
Parser.escape(uri.to_s, UNSAFE_PCHAR)
|
57
59
|
end
|
58
60
|
module_function :escape_uri
|
59
61
|
|
60
62
|
if ''.respond_to?(:force_encoding)
|
61
63
|
def unescape_uri(uri)
|
62
|
-
|
64
|
+
Parser.unescape(uri).force_encoding('utf-8')
|
63
65
|
end
|
64
66
|
else
|
65
67
|
def unescape_uri(uri)
|
data/lib/rack/mount/version.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-mount
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
9
|
+
- 4
|
10
|
+
version: 0.6.4
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Joshua Peek
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-06-11 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies: []
|
20
21
|
|
@@ -72,23 +73,27 @@ rdoc_options: []
|
|
72
73
|
require_paths:
|
73
74
|
- lib
|
74
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
75
77
|
requirements:
|
76
78
|
- - ">="
|
77
79
|
- !ruby/object:Gem::Version
|
80
|
+
hash: 3
|
78
81
|
segments:
|
79
82
|
- 0
|
80
83
|
version: "0"
|
81
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
82
86
|
requirements:
|
83
87
|
- - ">="
|
84
88
|
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
85
90
|
segments:
|
86
91
|
- 0
|
87
92
|
version: "0"
|
88
93
|
requirements: []
|
89
94
|
|
90
95
|
rubyforge_project:
|
91
|
-
rubygems_version: 1.3.
|
96
|
+
rubygems_version: 1.3.7
|
92
97
|
signing_key:
|
93
98
|
specification_version: 3
|
94
99
|
summary: Stackable dynamic tree based Rack router
|