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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffde8b15ff26955c6cb9bb0351d5dccd1eae1c00
4
- data.tar.gz: 5bdb5cf6cba9138b660b72f856058cca8b813a45
3
+ metadata.gz: 816bf0b85b7f5e9caf3f8ca48d3999ed7d527d0a
4
+ data.tar.gz: f10c68b32919477b6ec261ef9fecfd3301cfff15
5
5
  SHA512:
6
- metadata.gz: 13f6c6425349b174caf3b3b0d9b799bd94d115a7f099d53ae026da3541af39c5e5f2d6168ff27a1dc1eda99e140207f42f5d3ba67a137c30af49f06098b8fe93
7
- data.tar.gz: b63d0743cec0bf45b016c963b74d95105858383e8b01601915df9eeb803d6c5906148e2f419a71d5957305617d8e80dfd495fe7170213cc582eb37bccaf39c3f
6
+ metadata.gz: 39eaa53aed3cdb6faaadd90d75b30f0b69b274a5d5809e4acb65291e1ffd79f7c608f77ffc1b1b2ec27b05cf54e2802bf8b31c5431de38cbff8ab512214e386b
7
+ data.tar.gz: c5565b02e2cc265897dd79c5a91d665c406070cd68a1a4361dbb3982d1684147e3361ee9dfbfd64bec49b577c1852bf51518c9403f3753e1ba4aa0dfc7e57ec1
@@ -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
- return self
90
+ self
74
91
  end
75
92
  alias :prefix! :mask!
76
93
 
data/lib/pio/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # Base module.
2
2
  module Pio
3
3
  # gem version.
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
6
6
 
7
7
 
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
- ** TODO 0.2.2 リリース
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
- ** TODO 0.2.3 リリース
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yasuhito Takamiya