rack-router 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rack/route.rb +3 -3
- data/lib/rack/router.rb +1 -2
- data/rack-router.gemspec +1 -1
- data/test/route_test.rb +4 -3
- data/test/router_test.rb +2 -3
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4cdf3fc0c4f10427a17e1af387de613c507f691
|
4
|
+
data.tar.gz: 06f319847932ae6af0b6e6418dbd68699423ae82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 505582df598d172c41686b8f30e6cfc5f3409e9d5608d91ba54363d90dab3e546d386df05949a13afd5b4c2dcbaa94d1dac73e91d75fa6e613a4018207f0667b
|
7
|
+
data.tar.gz: 33e5e88e820c45f5b4433c1b57ae8e63ce3e3a2e05d2d974b3ca65d430d6d640b80b1983acd3b7524dd2e60ed463ad29fbe7dc78d9ca826f5a8e6aca54a03ce6
|
data/lib/rack/route.rb
CHANGED
@@ -5,8 +5,7 @@ module Rack
|
|
5
5
|
PATH_INFO = 'PATH_INFO'.freeze
|
6
6
|
DEFAULT_WILDCARD_NAME = :paths
|
7
7
|
WILDCARD_PATTERN = /\/\*(.*)/.freeze
|
8
|
-
NAMED_SEGMENTS_PATTERN =
|
9
|
-
NAMED_SEGMENTS_REPLACEMENT_PATTERN = /\/:([^$\/]+)/.freeze
|
8
|
+
NAMED_SEGMENTS_PATTERN = /\/([^\/]*):([^:$\/]+)/.freeze
|
10
9
|
DOT = '.'.freeze
|
11
10
|
|
12
11
|
def initialize(request_method, pattern, app, options={})
|
@@ -39,12 +38,13 @@ module Rack
|
|
39
38
|
pattern.gsub(WILDCARD_PATTERN,'(?:/(.*)|)')
|
40
39
|
else
|
41
40
|
p = if pattern_match = pattern.match(NAMED_SEGMENTS_PATTERN)
|
42
|
-
pattern.gsub(
|
41
|
+
pattern.gsub(NAMED_SEGMENTS_PATTERN, '/\1(?<\2>[^.$/]+)')
|
43
42
|
else
|
44
43
|
pattern
|
45
44
|
end
|
46
45
|
p + '(?:\.(?<format>.*))?'
|
47
46
|
end
|
47
|
+
#puts "pattern: #{pattern}, src: #{src}"
|
48
48
|
Regexp.new("\\A#{src}\\Z")
|
49
49
|
end
|
50
50
|
|
data/lib/rack/router.rb
CHANGED
data/rack-router.gemspec
CHANGED
data/test/route_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require "
|
1
|
+
require "minitest/autorun"
|
2
2
|
require "rack/route"
|
3
3
|
|
4
|
-
class RouteTest < Test
|
4
|
+
class RouteTest < Minitest::Test
|
5
5
|
|
6
6
|
def test_match
|
7
7
|
match "/*" , "/" , :paths => []
|
@@ -27,6 +27,8 @@ class RouteTest < Test::Unit::TestCase
|
|
27
27
|
match "/:x/:y" , "/a/b" , { :x => "a" , :y => "b" }
|
28
28
|
match "/posts" , "/posts.json" , { :format => "json" }
|
29
29
|
match "/posts/:id" , "/posts/42.json", { :id => "42", :format => "json" }
|
30
|
+
match "/api/v:version" , "/api/v2", :version => "2"
|
31
|
+
match "/api/v:version/things" , "/api/v2/things" , :version => "2"
|
30
32
|
end
|
31
33
|
|
32
34
|
def test_match_with_constraints
|
@@ -70,4 +72,3 @@ class RouteTest < Test::Unit::TestCase
|
|
70
72
|
assert_equal(params, route('GET', pattern).match('GET', path), msg)
|
71
73
|
end
|
72
74
|
end
|
73
|
-
|
data/test/router_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "minitest/autorun"
|
2
2
|
require 'rack/router'
|
3
3
|
|
4
|
-
class RouterTest < Test
|
4
|
+
class RouterTest < Minitest::Test
|
5
5
|
def test_call
|
6
6
|
app1 = lambda{|env| [200, {}, [env["rack.route_params"][:id]]] }
|
7
7
|
app2 = lambda{|env| [200, {}, ["2"]] }
|
@@ -26,4 +26,3 @@ class RouterTest < Test::Unit::TestCase
|
|
26
26
|
assert_equal "/it", router[:it]
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-router
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple router for Rack apps
|
14
14
|
email:
|
@@ -17,8 +17,8 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- .gitignore
|
21
|
-
- .rvmrc
|
20
|
+
- ".gitignore"
|
21
|
+
- ".rvmrc"
|
22
22
|
- Gemfile
|
23
23
|
- LICENSE
|
24
24
|
- README.md
|
@@ -40,21 +40,20 @@ require_paths:
|
|
40
40
|
- lib
|
41
41
|
required_ruby_version: !ruby/object:Gem::Requirement
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
|
-
- -
|
48
|
+
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
52
|
rubyforge_project:
|
53
|
-
rubygems_version: 2.
|
53
|
+
rubygems_version: 2.4.5
|
54
54
|
signing_key:
|
55
55
|
specification_version: 4
|
56
56
|
summary: A simple router for Rack apps
|
57
57
|
test_files:
|
58
58
|
- test/route_test.rb
|
59
59
|
- test/router_test.rb
|
60
|
-
has_rdoc:
|