pio 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pio/ipv4_address.rb +18 -1
- data/lib/pio/version.rb +1 -1
- data/pio.org +9 -2
- data/spec/pio/ipv4_address_spec.rb +14 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 816bf0b85b7f5e9caf3f8ca48d3999ed7d527d0a
|
4
|
+
data.tar.gz: f10c68b32919477b6ec261ef9fecfd3301cfff15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39eaa53aed3cdb6faaadd90d75b30f0b69b274a5d5809e4acb65291e1ffd79f7c608f77ffc1b1b2ec27b05cf54e2802bf8b31c5431de38cbff8ab512214e386b
|
7
|
+
data.tar.gz: c5565b02e2cc265897dd79c5a91d665c406070cd68a1a4361dbb3982d1684147e3361ee9dfbfd64bec49b577c1852bf51518c9403f3753e1ba4aa0dfc7e57ec1
|
data/lib/pio/ipv4_address.rb
CHANGED
@@ -35,6 +35,8 @@ module Pio
|
|
35
35
|
@value = IPAddr.new( addr, Socket::AF_INET )
|
36
36
|
when String
|
37
37
|
@value = IPAddr.new( addr )
|
38
|
+
when IPv4Address
|
39
|
+
@value = addr.value
|
38
40
|
else
|
39
41
|
raise TypeError, "Invalid IPv4 address: #{ addr.inspect }"
|
40
42
|
end
|
@@ -53,6 +55,21 @@ module Pio
|
|
53
55
|
def_delegator :value, :to_i
|
54
56
|
|
55
57
|
|
58
|
+
#
|
59
|
+
# @return [Range] Creates a Range object for the network address.
|
60
|
+
#
|
61
|
+
def_delegator :value, :to_range
|
62
|
+
|
63
|
+
|
64
|
+
#
|
65
|
+
# @return [Number] prefix length of IPv4 address.
|
66
|
+
#
|
67
|
+
def prefixlen
|
68
|
+
netmask = to_range.first.to_i ^ to_range.last.to_i
|
69
|
+
32 - ( "%b" % netmask ).length
|
70
|
+
end
|
71
|
+
|
72
|
+
|
56
73
|
#
|
57
74
|
# @return [Array]
|
58
75
|
# an array of decimal numbers converted from IPv4 address.
|
@@ -70,7 +87,7 @@ module Pio
|
|
70
87
|
#
|
71
88
|
def mask! masklen
|
72
89
|
@value = @value.mask( masklen )
|
73
|
-
|
90
|
+
self
|
74
91
|
end
|
75
92
|
alias :prefix! :mask!
|
76
93
|
|
data/lib/pio/version.rb
CHANGED
data/pio.org
CHANGED
@@ -49,7 +49,8 @@ http:///www.asahi-net.or.jp/~aa4t-nngk/ipttut/output/icmpheaders.html
|
|
49
49
|
** TODO phost を Pio で書き直す
|
50
50
|
[2013-09-24 火 15:36]
|
51
51
|
* Releases
|
52
|
-
**
|
52
|
+
** DONE 0.2.2 リリース
|
53
|
+
CLOSED: [2013-09-26 木 15:34]
|
53
54
|
:LOGBOOK:
|
54
55
|
CLOCK: [2013-09-19 木 14:29]--[2013-09-19 木 16:39] => 2:10
|
55
56
|
:END:
|
@@ -78,7 +79,13 @@ CLOSED: [2013-09-24 火 20:57] SCHEDULED: <2013-09-24 火 13:45>
|
|
78
79
|
:Effort: 0:05
|
79
80
|
:END:
|
80
81
|
[2013-09-20 金 09:26]
|
81
|
-
**
|
82
|
+
** DONE 0.2.3 リリース
|
83
|
+
CLOSED: [2013-09-26 木 15:35]
|
84
|
+
[2013-09-26 木 15:34]
|
85
|
+
*** DONE Trema への組込み
|
86
|
+
CLOSED: [2013-09-26 木 15:35]
|
87
|
+
[2013-09-26 木 15:35]
|
88
|
+
** TODO 0.2.4 リリース
|
82
89
|
:LOGBOOK:
|
83
90
|
CLOCK: [2013-09-26 木 13:31]--[2013-09-26 木 13:32] => 0:01
|
84
91
|
:END:
|
@@ -87,6 +87,20 @@ module Pio
|
|
87
87
|
its( :unicast? ) { should be_false }
|
88
88
|
its( :multicast? ) { should be_true }
|
89
89
|
end
|
90
|
+
|
91
|
+
|
92
|
+
context "with 192.168.0.1/16" do
|
93
|
+
let( :ip_address ) { "192.168.0.1/16" }
|
94
|
+
|
95
|
+
its( :prefixlen ) { should eq 16 }
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
context "with 192.168.0.1/255.255.255.0" do
|
100
|
+
let( :ip_address ) { "192.168.0.1/255.255.255.0" }
|
101
|
+
|
102
|
+
its( :prefixlen ) { should eq 24 }
|
103
|
+
end
|
90
104
|
end
|
91
105
|
end
|
92
106
|
end
|