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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c67f53c99d9372515a3c78af3d35750437ce2464
4
- data.tar.gz: 568d4a2e57f583839652a74e7c8978243764b930
3
+ metadata.gz: e4cdf3fc0c4f10427a17e1af387de613c507f691
4
+ data.tar.gz: 06f319847932ae6af0b6e6418dbd68699423ae82
5
5
  SHA512:
6
- metadata.gz: a311a6448794f53522e8c0fc4858414277c18a07cb3b27c3e716d9c32c2c91f6852561b4bff724bed6121eae5da2af65d1ec6b450d3f3c8eb138d54a3d8cd655
7
- data.tar.gz: be6af03eb657e91d2e7b4c2a633eb95eea3463c07c356fd0f6d3c46ca5c626f61eabd9bd41e7d8cc4d1c4386f5a0138e386e235f133dd189e9b8bbc6effb7e48
6
+ metadata.gz: 505582df598d172c41686b8f30e6cfc5f3409e9d5608d91ba54363d90dab3e546d386df05949a13afd5b4c2dcbaa94d1dac73e91d75fa6e613a4018207f0667b
7
+ data.tar.gz: 33e5e88e820c45f5b4433c1b57ae8e63ce3e3a2e05d2d974b3ca65d430d6d640b80b1983acd3b7524dd2e60ed463ad29fbe7dc78d9ca826f5a8e6aca54a03ce6
@@ -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 = /\/:([^$\/]+)/.freeze
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(NAMED_SEGMENTS_REPLACEMENT_PATTERN, '/(?<\1>[^.$/]+)')
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
 
@@ -3,7 +3,7 @@ require 'rack/route'
3
3
  module Rack
4
4
 
5
5
  class Router
6
- VERSION = "0.4.0"
6
+ VERSION = "0.5.0"
7
7
 
8
8
  HEAD = 'HEAD'.freeze
9
9
  GET = 'GET'.freeze
@@ -88,4 +88,3 @@ module Rack
88
88
  end
89
89
  end
90
90
  end
91
-
@@ -11,5 +11,5 @@ Gem::Specification.new do |gem|
11
11
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
12
12
  gem.name = "rack-router"
13
13
  gem.require_paths = ["lib"]
14
- gem.version = "0.4.0"
14
+ gem.version = "0.5.0"
15
15
  end
@@ -1,7 +1,7 @@
1
- require "test/unit"
1
+ require "minitest/autorun"
2
2
  require "rack/route"
3
3
 
4
- class RouteTest < Test::Unit::TestCase
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
-
@@ -1,7 +1,7 @@
1
- require 'test/unit'
1
+ require "minitest/autorun"
2
2
  require 'rack/router'
3
3
 
4
- class RouterTest < Test::Unit::TestCase
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.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: 2013-05-16 00:00:00.000000000 Z
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.0.0
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: