rack-multiplexer 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/rack/multiplexer.rb +1 -1
- data/lib/rack/multiplexer/version.rb +1 -1
- data/scripts/benchmark.rb +13 -16
- data/spec/rack/multiplexer_spec.rb +8 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56192c72de737b0bf6d3f134b3de57774be7613e
|
4
|
+
data.tar.gz: d27bf614ecef2456e7f2e3970e1d7b3a7190efde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: accd2f8899fb5d0cd0921c727980eeb6f4f2eca86f9865c830b613f08848bb9a4ca0afe268243a43ff5083cad64e17c5e89700e1bb710ed58432361e40e5cb9a
|
7
|
+
data.tar.gz: f382488b74aaba47a00b802ed3ef4c072f6424b23ae551b127cf2f357c07efd231a825463883e7eee741e0ebde8b9486a5fee0f9c2c2f3366c97e0164d2b0d43
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Rack::Multiplexer
|
2
2
|
Provides a simple router & dispatcher for Rack applications as a Rack application.
|
3
|
-
The routing algorithm has only O(1) time complexity because all routes are compiled into one Regexp.
|
3
|
+
The routing algorithm has only O(1) time complexity in Ruby level because all routes are compiled into one Regexp.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
```
|
data/lib/rack/multiplexer.rb
CHANGED
data/scripts/benchmark.rb
CHANGED
@@ -1,28 +1,25 @@
|
|
1
|
-
# Benchmark script for comparison of the routing algorithm between v0.0.2 and v0.0.3.
|
2
|
-
# In my laptop environment, v0.0.3 is 17x faster than 0.0.2 with 676 routes & 100,000 tries.
|
3
|
-
|
4
1
|
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
5
2
|
require "rack/multiplexer"
|
6
3
|
require "benchmark"
|
7
4
|
|
8
|
-
|
9
|
-
(?a..?z).each do |head|
|
10
|
-
(?a..?z).each do |tail|
|
11
|
-
multiplexer.get("/#{head}{tail}") do
|
12
|
-
[200, {}, ["OK"]]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
5
|
+
characters = (?a..?z).to_a
|
17
6
|
env = {
|
18
7
|
"PATH_INFO" => "/mm",
|
19
8
|
"REQUEST_METHOD" => "GET",
|
20
9
|
}
|
21
|
-
|
22
10
|
n = 100_000
|
23
|
-
|
24
|
-
|
11
|
+
|
12
|
+
26.times do |i|
|
13
|
+
multiplexer = Rack::Multiplexer.new
|
14
|
+
characters[0, i + 1].each do |character|
|
15
|
+
multiplexer.get("/#{character}") do
|
16
|
+
[200, {}, ["OK"]]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
before = Time.now
|
25
21
|
n.times do
|
26
22
|
multiplexer.call(env)
|
27
23
|
end
|
28
|
-
|
24
|
+
puts Time.now - before
|
25
|
+
end
|
@@ -120,5 +120,13 @@ describe Rack::Multiplexer do
|
|
120
120
|
multiplexer.call(env.merge("REQUEST_METHOD" => "GET", "PATH_INFO" => "/abc"))[0].should == 404
|
121
121
|
end
|
122
122
|
end
|
123
|
+
|
124
|
+
context "with root path" do
|
125
|
+
it "delegates to registered application" do
|
126
|
+
multiplexer = described_class.new
|
127
|
+
multiplexer.get("/", application)
|
128
|
+
multiplexer.call(env.merge("REQUEST_METHOD" => "GET", "PATH_INFO" => "/"))[0].should == 200
|
129
|
+
end
|
130
|
+
end
|
123
131
|
end
|
124
132
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-multiplexer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -140,3 +140,4 @@ summary: Provides a simple router & dispatcher for Rack.
|
|
140
140
|
test_files:
|
141
141
|
- spec/rack/multiplexer_spec.rb
|
142
142
|
- spec/spec_helper.rb
|
143
|
+
has_rdoc:
|