ipaddress 0.8.0 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rock.yml +5 -0
- data/CHANGELOG.rdoc +15 -0
- data/Gemfile +3 -0
- data/{LICENSE → LICENSE.txt} +1 -1
- data/README.rdoc +106 -69
- data/Rakefile +2 -19
- data/ipaddress.gemspec +20 -49
- data/lib/ipaddress.rb +36 -11
- data/lib/ipaddress/ipv4.rb +124 -14
- data/lib/ipaddress/ipv6.rb +9 -0
- data/lib/ipaddress/mongoid.rb +75 -0
- data/lib/ipaddress/prefix.rb +2 -2
- data/lib/ipaddress/version.rb +3 -0
- data/test/ipaddress/ipv4_test.rb +91 -23
- data/test/ipaddress/ipv6_test.rb +27 -23
- data/test/ipaddress/mongoid_test.rb +70 -0
- data/test/ipaddress/prefix_test.rb +4 -10
- data/test/ipaddress_test.rb +34 -7
- data/test/test_helper.rb +10 -3
- metadata +63 -28
- data/VERSION +0 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class Prefix32Test < Test
|
3
|
+
class Prefix32Test < Minitest::Test
|
4
4
|
|
5
5
|
def setup
|
6
6
|
@netmask0 = "0.0.0.0"
|
@@ -89,12 +89,9 @@ class Prefix32Test < Test::Unit::TestCase
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def test_initialize
|
92
|
-
|
92
|
+
assert_raises (ArgumentError) do
|
93
93
|
@klass.new 33
|
94
94
|
end
|
95
|
-
assert_nothing_raised do
|
96
|
-
@klass.new 8
|
97
|
-
end
|
98
95
|
assert_instance_of @klass, @klass.new(8)
|
99
96
|
end
|
100
97
|
|
@@ -122,7 +119,7 @@ class Prefix32Test < Test::Unit::TestCase
|
|
122
119
|
end # class Prefix32Test
|
123
120
|
|
124
121
|
|
125
|
-
class Prefix128Test < Test
|
122
|
+
class Prefix128Test < Minitest::Test
|
126
123
|
|
127
124
|
def setup
|
128
125
|
@u128_hash = {
|
@@ -135,12 +132,9 @@ class Prefix128Test < Test::Unit::TestCase
|
|
135
132
|
end
|
136
133
|
|
137
134
|
def test_initialize
|
138
|
-
|
135
|
+
assert_raises (ArgumentError) do
|
139
136
|
@klass.new 129
|
140
137
|
end
|
141
|
-
assert_nothing_raised do
|
142
|
-
@klass.new 64
|
143
|
-
end
|
144
138
|
assert_instance_of @klass, @klass.new(64)
|
145
139
|
end
|
146
140
|
|
data/test/ipaddress_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class IPAddressTest < Test
|
3
|
+
class IPAddressTest < Minitest::Test
|
4
4
|
|
5
5
|
def setup
|
6
6
|
@valid_ipv4 = "172.16.10.1/24"
|
@@ -11,25 +11,50 @@ class IPAddressTest < Test::Unit::TestCase
|
|
11
11
|
@invalid_ipv6 = ":1:2:3:4:5:6:7"
|
12
12
|
@invalid_mapped = "::1:2.3.4"
|
13
13
|
|
14
|
+
@valid_ipv4_uint32 = [4294967295, # 255.255.255.255
|
15
|
+
167772160, # 10.0.0.0
|
16
|
+
3232235520, # 192.168.0.0
|
17
|
+
0]
|
18
|
+
|
19
|
+
@invalid_ipv4_uint32 = [4294967296, # 256.0.0.0
|
20
|
+
"A294967295", # Invalid uINT
|
21
|
+
-1] # Invalid
|
22
|
+
|
23
|
+
|
14
24
|
@ipv4class = IPAddress::IPv4
|
15
25
|
@ipv6class = IPAddress::IPv6
|
16
26
|
@mappedclass = IPAddress::IPv6::Mapped
|
27
|
+
|
28
|
+
@invalid_ipv4 = ["10.0.0.256",
|
29
|
+
"10.0.0.0.0",
|
30
|
+
"10.0.0",
|
31
|
+
"10.0"]
|
32
|
+
|
33
|
+
@valid_ipv4_range = ["10.0.0.1-254",
|
34
|
+
"10.0.1-254.0",
|
35
|
+
"10.1-254.0.0"]
|
17
36
|
|
18
37
|
@method = Module.method("IPAddress")
|
19
38
|
end
|
20
39
|
|
21
40
|
def test_method_IPAddress
|
22
|
-
assert_nothing_raised {@method.call(@valid_ipv4)}
|
23
|
-
assert_nothing_raised {@method.call(@valid_ipv6)}
|
24
|
-
assert_nothing_raised {@method.call(@valid_mapped)}
|
25
41
|
|
26
42
|
assert_instance_of @ipv4class, @method.call(@valid_ipv4)
|
27
43
|
assert_instance_of @ipv6class, @method.call(@valid_ipv6)
|
28
44
|
assert_instance_of @mappedclass, @method.call(@valid_mapped)
|
29
45
|
|
30
|
-
|
31
|
-
|
32
|
-
|
46
|
+
assert_raises(ArgumentError) {@method.call(@invalid_ipv4)}
|
47
|
+
assert_raises(ArgumentError) {@method.call(@invalid_ipv6)}
|
48
|
+
assert_raises(ArgumentError) {@method.call(@invalid_mapped)}
|
49
|
+
|
50
|
+
assert_instance_of @ipv4class, @method.call(@valid_ipv4_uint32[0])
|
51
|
+
assert_instance_of @ipv4class, @method.call(@valid_ipv4_uint32[1])
|
52
|
+
assert_instance_of @ipv4class, @method.call(@valid_ipv4_uint32[2])
|
53
|
+
assert_instance_of @ipv4class, @method.call(@valid_ipv4_uint32[3])
|
54
|
+
|
55
|
+
assert_raises(ArgumentError) {@method.call(@invalid_ipv4_uint32[0])}
|
56
|
+
assert_raises(ArgumentError) {@method.call(@invalid_ipv4_uint32[1])}
|
57
|
+
assert_raises(ArgumentError) {@method.call(@invalid_ipv4_uint32[2])}
|
33
58
|
|
34
59
|
end
|
35
60
|
|
@@ -43,6 +68,8 @@ class IPAddressTest < Test::Unit::TestCase
|
|
43
68
|
assert_equal false, IPAddress::valid?("10.0.0")
|
44
69
|
assert_equal false, IPAddress::valid?("10.0")
|
45
70
|
assert_equal false, IPAddress::valid?("2002:::1")
|
71
|
+
assert_equal false, IPAddress::valid?("2002:516:2:200")
|
72
|
+
|
46
73
|
end
|
47
74
|
|
48
75
|
def test_module_method_valid_ipv4_netmark?
|
data/test/test_helper.rb
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require '
|
2
|
+
require 'minitest/autorun'
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
5
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
6
|
require 'ipaddress'
|
7
7
|
|
8
|
-
|
8
|
+
if Minitest.const_defined?('Test')
|
9
|
+
# We're on Minitest 5+. Nothing to do here.
|
10
|
+
else
|
11
|
+
# Minitest 4 doesn't have Minitest::Test yet.
|
12
|
+
Minitest::Test = MiniTest::Unit::TestCase
|
13
|
+
end
|
14
|
+
|
15
|
+
module Minitest
|
9
16
|
|
10
|
-
class
|
17
|
+
class Test
|
11
18
|
|
12
19
|
def self.must(name, &block)
|
13
20
|
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
|
metadata
CHANGED
@@ -1,67 +1,102 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ipaddress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
5
|
-
prerelease:
|
4
|
+
version: 0.8.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
|
-
-
|
7
|
+
- bluemonk
|
8
|
+
- mikemackintosh
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
description: "IPAddress is a Ruby library designed to make manipulation \n of
|
43
|
+
IPv4 and IPv6 addresses both powerful and simple. It mantains\n a layer of
|
44
|
+
compatibility with Ruby's own IPAddr, while \n addressing many of its issues."
|
45
|
+
email:
|
46
|
+
- ceresa@gmail.com
|
20
47
|
executables: []
|
21
48
|
extensions: []
|
22
|
-
extra_rdoc_files:
|
23
|
-
- LICENSE
|
24
|
-
- README.rdoc
|
49
|
+
extra_rdoc_files: []
|
25
50
|
files:
|
26
|
-
- .document
|
51
|
+
- ".document"
|
52
|
+
- ".gitignore"
|
53
|
+
- ".rock.yml"
|
27
54
|
- CHANGELOG.rdoc
|
28
|
-
-
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE.txt
|
29
57
|
- README.rdoc
|
30
58
|
- Rakefile
|
31
|
-
- VERSION
|
32
59
|
- ipaddress.gemspec
|
33
60
|
- lib/ipaddress.rb
|
34
61
|
- lib/ipaddress/ipv4.rb
|
35
62
|
- lib/ipaddress/ipv6.rb
|
63
|
+
- lib/ipaddress/mongoid.rb
|
36
64
|
- lib/ipaddress/prefix.rb
|
65
|
+
- lib/ipaddress/version.rb
|
37
66
|
- test/ipaddress/ipv4_test.rb
|
38
67
|
- test/ipaddress/ipv6_test.rb
|
68
|
+
- test/ipaddress/mongoid_test.rb
|
39
69
|
- test/ipaddress/prefix_test.rb
|
40
70
|
- test/ipaddress_test.rb
|
41
71
|
- test/test_helper.rb
|
42
|
-
|
43
|
-
|
44
|
-
|
72
|
+
homepage: https://github.com/bluemonk/ipaddress
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
45
76
|
post_install_message:
|
46
77
|
rdoc_options: []
|
47
78
|
require_paths:
|
48
79
|
- lib
|
49
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
81
|
requirements:
|
52
|
-
- -
|
82
|
+
- - ">="
|
53
83
|
- !ruby/object:Gem::Version
|
54
84
|
version: '0'
|
55
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
86
|
requirements:
|
58
|
-
- -
|
87
|
+
- - ">="
|
59
88
|
- !ruby/object:Gem::Version
|
60
89
|
version: '0'
|
61
90
|
requirements: []
|
62
91
|
rubyforge_project:
|
63
|
-
rubygems_version:
|
92
|
+
rubygems_version: 2.5.1
|
64
93
|
signing_key:
|
65
|
-
specification_version:
|
66
|
-
summary: IPv4/IPv6
|
67
|
-
test_files:
|
94
|
+
specification_version: 4
|
95
|
+
summary: IPv4/IPv6 address manipulation library
|
96
|
+
test_files:
|
97
|
+
- test/ipaddress/ipv4_test.rb
|
98
|
+
- test/ipaddress/ipv6_test.rb
|
99
|
+
- test/ipaddress/mongoid_test.rb
|
100
|
+
- test/ipaddress/prefix_test.rb
|
101
|
+
- test/ipaddress_test.rb
|
102
|
+
- test/test_helper.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.8.0
|