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 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
@@ -25,7 +25,7 @@ puts Benchmark.measure {
25
25
  puts "u.routes.size: #{u.routes.size}"
26
26
  }
27
27
  #
28
- TIMES = 10_000
28
+ TIMES = 50_000
29
29
 
30
30
  #simple_env =
31
31
  #simple2_env =
@@ -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
@@ -16,6 +16,10 @@ class HttpRouter
16
16
  end
17
17
  end
18
18
  end
19
+
20
+ def usuable?(other)
21
+ other.class == self.class && other.allow_partial == allow_partial && other.blk == blk
22
+ end
19
23
  end
20
24
  end
21
25
  end
@@ -17,6 +17,10 @@ class HttpRouter
17
17
  super
18
18
  end
19
19
  end
20
+
21
+ def usuable?(other)
22
+ other.class == self.class && other.matcher == matcher
23
+ end
20
24
  end
21
25
  end
22
26
  end
@@ -11,6 +11,10 @@ class HttpRouter
11
11
  super(request)
12
12
  end
13
13
  end
14
+
15
+ def usuable?(other)
16
+ other.class == self.class
17
+ end
14
18
  end
15
19
  end
16
20
  end
@@ -16,6 +16,10 @@ class HttpRouter
16
16
  def add(part)
17
17
  Node.new(@router, @map[part] ||= [])
18
18
  end
19
+
20
+ def usuable?(other)
21
+ other.class == self.class
22
+ end
19
23
  end
20
24
  end
21
25
  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
@@ -8,6 +8,10 @@ class HttpRouter
8
8
  super(request)
9
9
  end
10
10
  end
11
+
12
+ def usuable?(other)
13
+ other.class == self.class
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -54,13 +54,17 @@ class HttpRouter
54
54
  end
55
55
 
56
56
  def add_lookup(part)
57
- add(Lookup.new(@router)) unless @matchers.last.is_a?(Lookup)
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
 
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  class HttpRouter #:nodoc
3
- VERSION = '0.7.5'
3
+ VERSION = '0.7.6'
4
4
  end
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: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 5
10
- version: 0.7.5
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-04-28 00:00:00 -07:00
18
+ date: 2011-05-10 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency