rpatricia 0.04 → 0.05
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/Changes +4 -0
- data/{extconf.rb → ext/rpatricia/extconf.rb} +0 -0
- data/{patricia.c → ext/rpatricia/patricia.c} +0 -0
- data/{patricia.h → ext/rpatricia/patricia.h} +0 -0
- data/{rpatricia.c → ext/rpatricia/rpatricia.c} +0 -0
- data/rpatricia.gemspec +43 -0
- data/test.rb +63 -0
- metadata +10 -8
data/Changes
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/rpatricia.gemspec
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# to build a gem:
|
|
2
|
+
# gem build rpatricia.gemspec
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |s|
|
|
5
|
+
s.name = %q{rpatricia}
|
|
6
|
+
s.version = %q{0.05} # remember to update Changes if this is changed
|
|
7
|
+
|
|
8
|
+
s.homepage = "http://www.goto.info.waseda.ac.jp/~tatsuya/rpatricia/"
|
|
9
|
+
|
|
10
|
+
# Tatsuya wrote the extension, Eric gemified this
|
|
11
|
+
s.authors = [ "Tatsuya Mori", "Eric Wong" ]
|
|
12
|
+
|
|
13
|
+
s.date = Time.now.utc.strftime('%Y-%m-%d')
|
|
14
|
+
s.summary = %q{module for fast IP address/prefix lookups}
|
|
15
|
+
s.description = %q{
|
|
16
|
+
This is a ruby wrapper of Net::Patricia, which has been developed by
|
|
17
|
+
Dave Plonka. The original Net::Patricia and its C API are available
|
|
18
|
+
from:
|
|
19
|
+
http://net.doit.wisc.edu/~plonka/Net-Patricia/
|
|
20
|
+
|
|
21
|
+
Net::Patricia is a module for fast IP address/prefix lookups.
|
|
22
|
+
I have modified some interfaces for the Ruby wrapper version.
|
|
23
|
+
}.strip
|
|
24
|
+
|
|
25
|
+
# bother Eric for all gem issues
|
|
26
|
+
s.email = %q{normalperson@yhbt.net}
|
|
27
|
+
|
|
28
|
+
# generated using "git ls-files" from Eric's git repo
|
|
29
|
+
s.files = %w(
|
|
30
|
+
Changes
|
|
31
|
+
README
|
|
32
|
+
TODO
|
|
33
|
+
copyright
|
|
34
|
+
credits.txt
|
|
35
|
+
ext/rpatricia/extconf.rb
|
|
36
|
+
ext/rpatricia/patricia.c
|
|
37
|
+
ext/rpatricia/patricia.h
|
|
38
|
+
ext/rpatricia/rpatricia.c
|
|
39
|
+
rpatricia.gemspec
|
|
40
|
+
test.rb
|
|
41
|
+
)
|
|
42
|
+
s.extensions = %w(ext/rpatricia/extconf.rb)
|
|
43
|
+
end
|
data/test.rb
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require 'rpatricia'
|
|
2
|
+
|
|
3
|
+
def my_test condition
|
|
4
|
+
puts (condition)? "ok!" : "error!"
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
puts "test: creating Patricia object"
|
|
8
|
+
my_test(t = Patricia.new)
|
|
9
|
+
|
|
10
|
+
puts "test: adding 127.0.0.0/24"
|
|
11
|
+
my_test(n = t.add("127.0.0.0/24"))
|
|
12
|
+
|
|
13
|
+
puts " data of added node = #{n.data}"
|
|
14
|
+
puts " prefix of added node = #{n.prefix}"
|
|
15
|
+
puts " network of added node = #{n.network}"
|
|
16
|
+
puts " prefixlen of added node = #{n.prefixlen}"
|
|
17
|
+
|
|
18
|
+
puts "adding 192.168.1.0/24, 192.168.2.0/24, 192.168.3.100"
|
|
19
|
+
t.add("192.168.1.0/24")
|
|
20
|
+
t.add("192.168.2.0/24")
|
|
21
|
+
t.add("192.168.3.100")
|
|
22
|
+
|
|
23
|
+
puts "test: match_best 127.0.0.1"
|
|
24
|
+
my_test(n = t.match_best("127.0.0.1"))
|
|
25
|
+
|
|
26
|
+
puts "test: match_exact 192.168.3.100"
|
|
27
|
+
my_test(n = t.match_best("192.168.3.100"))
|
|
28
|
+
|
|
29
|
+
puts " data of matched node = #{n.data}"
|
|
30
|
+
puts " prefix of matched node = #{n.prefix}"
|
|
31
|
+
puts " network of matched node = #{n.network}"
|
|
32
|
+
puts " prefixlen of matched node = #{n.prefixlen}"
|
|
33
|
+
|
|
34
|
+
puts "test: adding prefix 10.0.0.0/8 with user data of 'pref_10.0.0.0/8'"
|
|
35
|
+
my_test(n = t.add("10.0.0.0/8", "pref_10"))
|
|
36
|
+
|
|
37
|
+
puts " data of added node = #{n.data}"
|
|
38
|
+
puts " prefix of added node = #{n.prefix}"
|
|
39
|
+
puts " network of added node = #{n.network}"
|
|
40
|
+
puts " prefixlen of added node = #{n.prefixlen}"
|
|
41
|
+
|
|
42
|
+
puts "test: match string 10.0.0.1"
|
|
43
|
+
my_test(n = t.match_best("10.0.0.1"))
|
|
44
|
+
|
|
45
|
+
puts " data of matched node = #{n.data}"
|
|
46
|
+
puts " prefix of matched node = #{n.prefix}"
|
|
47
|
+
puts " network of matched node = #{n.network}"
|
|
48
|
+
puts " prefixlen of matched node = #{n.prefixlen}"
|
|
49
|
+
|
|
50
|
+
puts "test: remove '42.0.0.0/8'; should return nil"
|
|
51
|
+
my_test(!t.remove("42.0.0.0/8"))
|
|
52
|
+
|
|
53
|
+
puts "test: remove '10.0.0.0/8'"
|
|
54
|
+
my_test(n= t.remove("10.0.0.0/8"))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
puts "test: number of nodes in the tree should be '4'"
|
|
58
|
+
my_test(4 == t.num_nodes)
|
|
59
|
+
|
|
60
|
+
puts "test: showing all nodes"
|
|
61
|
+
t.show_nodes
|
|
62
|
+
|
|
63
|
+
t.destroy
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rpatricia
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: "0.
|
|
4
|
+
version: "0.05"
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tatsuya Mori
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2010-03-
|
|
13
|
+
date: 2010-03-15 00:00:00 +00:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies: []
|
|
16
16
|
|
|
@@ -26,7 +26,7 @@ email: normalperson@yhbt.net
|
|
|
26
26
|
executables: []
|
|
27
27
|
|
|
28
28
|
extensions:
|
|
29
|
-
- extconf.rb
|
|
29
|
+
- ext/rpatricia/extconf.rb
|
|
30
30
|
extra_rdoc_files: []
|
|
31
31
|
|
|
32
32
|
files:
|
|
@@ -35,10 +35,12 @@ files:
|
|
|
35
35
|
- TODO
|
|
36
36
|
- copyright
|
|
37
37
|
- credits.txt
|
|
38
|
-
- extconf.rb
|
|
39
|
-
- patricia.c
|
|
40
|
-
- patricia.h
|
|
41
|
-
- rpatricia.c
|
|
38
|
+
- ext/rpatricia/extconf.rb
|
|
39
|
+
- ext/rpatricia/patricia.c
|
|
40
|
+
- ext/rpatricia/patricia.h
|
|
41
|
+
- ext/rpatricia/rpatricia.c
|
|
42
|
+
- rpatricia.gemspec
|
|
43
|
+
- test.rb
|
|
42
44
|
has_rdoc: true
|
|
43
45
|
homepage: http://www.goto.info.waseda.ac.jp/~tatsuya/rpatricia/
|
|
44
46
|
licenses: []
|
|
@@ -47,7 +49,7 @@ post_install_message:
|
|
|
47
49
|
rdoc_options: []
|
|
48
50
|
|
|
49
51
|
require_paths:
|
|
50
|
-
-
|
|
52
|
+
- lib
|
|
51
53
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
54
|
requirements:
|
|
53
55
|
- - ">="
|