http_router 0.7.5 → 0.7.6
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/Rakefile +6 -0
- data/benchmarks/rec2.rb +1 -1
- data/lib/http_router/node/arbitrary.rb +5 -0
- data/lib/http_router/node/destination.rb +4 -0
- data/lib/http_router/node/free_regex.rb +4 -0
- data/lib/http_router/node/glob.rb +4 -0
- data/lib/http_router/node/lookup.rb +4 -0
- data/lib/http_router/node/regex.rb +5 -1
- data/lib/http_router/node/request.rb +5 -1
- data/lib/http_router/node/variable.rb +4 -0
- data/lib/http_router/node.rb +6 -2
- data/lib/http_router/version.rb +1 -1
- metadata +4 -4
data/Rakefile
CHANGED
@@ -7,6 +7,12 @@ task :test => ['test:integration', 'test:examples', 'test:rdoc_examples']
|
|
7
7
|
|
8
8
|
require 'pp'
|
9
9
|
|
10
|
+
desc "Clean things"
|
11
|
+
task :clean do
|
12
|
+
sh 'find . -name "*.rbc" | xargs rm'
|
13
|
+
sh 'rm -rf pkg'
|
14
|
+
end
|
15
|
+
|
10
16
|
namespace :test do
|
11
17
|
desc "Run integration tests"
|
12
18
|
task :integration do
|
data/benchmarks/rec2.rb
CHANGED
@@ -2,6 +2,7 @@ class HttpRouter
|
|
2
2
|
class Node
|
3
3
|
class Arbitrary < Node
|
4
4
|
alias_method :node_lookup, :[]
|
5
|
+
attr_reader :allow_partial, :blk, :param_names
|
5
6
|
|
6
7
|
def initialize(router, allow_partial, blk, param_names)
|
7
8
|
@allow_partial, @blk, @param_names = allow_partial, blk, param_names
|
@@ -18,6 +19,10 @@ class HttpRouter
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
22
|
+
|
23
|
+
def usuable?(other)
|
24
|
+
other.class == self.class && other.allow_partial == allow_partial && other.blk == blk && other.param_names == param_names
|
25
|
+
end
|
21
26
|
end
|
22
27
|
end
|
23
28
|
end
|
@@ -2,7 +2,7 @@ class HttpRouter
|
|
2
2
|
class Node
|
3
3
|
class Regex < Node
|
4
4
|
alias_method :node_lookup, :[]
|
5
|
-
attr_reader :matcher, :splitting_indicies
|
5
|
+
attr_reader :matcher, :splitting_indicies, :capturing_indicies
|
6
6
|
|
7
7
|
def initialize(router, matcher, capturing_indicies, splitting_indicies = nil)
|
8
8
|
@matcher, @capturing_indicies, @splitting_indicies = matcher, capturing_indicies, splitting_indicies
|
@@ -22,6 +22,10 @@ class HttpRouter
|
|
22
22
|
@splitting_indicies.each { |idx| request.params << unescape(match[idx]).split(/\//) } if @splitting_indicies
|
23
23
|
@capturing_indicies.each { |idx| request.params << unescape(match[idx]) }
|
24
24
|
end
|
25
|
+
|
26
|
+
def usuable?(other)
|
27
|
+
other.class == self.class && other.matcher == matcher && other.splitting_indicies == splitting_indicies && other.capturing_indicies == capturing_indicies
|
28
|
+
end
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class HttpRouter
|
2
2
|
class Node
|
3
3
|
class Request < Node
|
4
|
-
attr_reader :request_method
|
4
|
+
attr_reader :request_method, :opts
|
5
5
|
|
6
6
|
def initialize(router, opts)
|
7
7
|
@opts = opts
|
@@ -19,6 +19,10 @@ class HttpRouter
|
|
19
19
|
}
|
20
20
|
super(request)
|
21
21
|
end
|
22
|
+
|
23
|
+
def usuable?(other)
|
24
|
+
other.class == self.class && other.opts == opts
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
data/lib/http_router/node.rb
CHANGED
@@ -54,13 +54,17 @@ class HttpRouter
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def add_lookup(part)
|
57
|
-
add(Lookup.new(@router))
|
57
|
+
add(Lookup.new(@router))
|
58
58
|
@matchers.last.add(part)
|
59
59
|
end
|
60
60
|
|
61
|
+
def usable?(other)
|
62
|
+
false
|
63
|
+
end
|
64
|
+
|
61
65
|
private
|
62
66
|
def add(matcher)
|
63
|
-
@matchers << matcher
|
67
|
+
@matchers << matcher unless matcher.usable?(@matchers.last)
|
64
68
|
@matchers.last
|
65
69
|
end
|
66
70
|
|
data/lib/http_router/version.rb
CHANGED
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: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 6
|
10
|
+
version: 0.7.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joshua Hull
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-05-10 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|