pio 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -6
- data/lib/pio/arp/message.rb +1 -1
- data/lib/pio/arp/request.rb +2 -2
- data/lib/pio/mac.rb +119 -44
- data/lib/pio/version.rb +1 -1
- data/pio.org +33 -8
- data/spec/pio/mac_spec.rb +62 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b896a5fa15f8f59ec3e46d6fcb80aacf0dc8d96
|
4
|
+
data.tar.gz: 02c3e94ecc0f3850632d3ce7454a65f78946d231
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dad2f7aa5d1fa30237e1d6ec906cf705c42e446b9fbb3b62e957fedfc984e5f4ab95f8232ee5e96e3e88ba8289f8b896fe91f59c66be5192c7ed26b8f6c722e3
|
7
|
+
data.tar.gz: 6a43c94a49bac807d8f867f88fd5b4005cb8bafa9315f6841e894c15ab24c8876e9d924b2e9160d80efeb0f10318576d0fe06e7a85c870c560b4803782ad6081
|
data/Gemfile
CHANGED
@@ -5,25 +5,25 @@ gemspec
|
|
5
5
|
|
6
6
|
|
7
7
|
group :development, :test do
|
8
|
-
gem "coveralls", "~> 0.
|
8
|
+
gem "coveralls", "~> 0.7.0", :require => false
|
9
9
|
gem "flay", "~> 2.4.0"
|
10
|
-
gem "flog", "~> 4.1.
|
10
|
+
gem "flog", "~> 4.1.2"
|
11
11
|
gem "fuubar", "~> 1.2.1"
|
12
|
-
gem "guard", "~> 1.8
|
12
|
+
gem "guard", "~> 1.8"
|
13
13
|
gem "guard-bundler", "~> 1.0.0"
|
14
|
-
gem "guard-rspec", "~> 3.0
|
14
|
+
gem "guard-rspec", "~> 3.1.0"
|
15
15
|
gem "json", "~> 1.8.0"
|
16
16
|
gem "rake", "~> 10.1.0"
|
17
17
|
gem "rb-fchange", "~> 0.0.6", :require => false
|
18
18
|
gem "rb-fsevent", "~> 0.9.3", :require => false
|
19
|
-
gem "rb-inotify", "~> 0.9.
|
19
|
+
gem "rb-inotify", "~> 0.9.2", :require => false
|
20
20
|
gem "redcarpet", "~> 2.3.0" if RUBY_VERSION < "1.9.0"
|
21
21
|
gem "redcarpet", "~> 3.0.0" if RUBY_VERSION >= "1.9.0"
|
22
22
|
gem "reek", "~> 1.3.3"
|
23
23
|
gem "rspec", "~> 2.14.1"
|
24
24
|
gem "rspec-instafail", "~> 0.2.4"
|
25
25
|
gem "terminal-notifier-guard", "~> 1.5.3"
|
26
|
-
gem "yard", "~> 0.8.7"
|
26
|
+
gem "yard", "~> 0.8.7.2"
|
27
27
|
end
|
28
28
|
|
29
29
|
|
data/lib/pio/arp/message.rb
CHANGED
@@ -46,7 +46,7 @@ module Pio
|
|
46
46
|
def option_hash
|
47
47
|
mandatory_options.inject( {} ) do | opt, each |
|
48
48
|
klass = option_to_klass[ each ]
|
49
|
-
opt_pair = { each => klass.new( user_options[ each ] ).
|
49
|
+
opt_pair = { each => klass.new( user_options[ each ] ).to_a }
|
50
50
|
opt.merge opt_pair
|
51
51
|
end.merge default_options
|
52
52
|
end
|
data/lib/pio/arp/request.rb
CHANGED
@@ -9,8 +9,8 @@ module Pio
|
|
9
9
|
class Request < Message
|
10
10
|
OPERATION = 1
|
11
11
|
|
12
|
-
BROADCAST_MAC_ADDRESS = Mac.new( 0xffffffffffff ).
|
13
|
-
ALL_ZERO_MAC_ADDRESS = Mac.new( 0 ).
|
12
|
+
BROADCAST_MAC_ADDRESS = Mac.new( 0xffffffffffff ).to_a
|
13
|
+
ALL_ZERO_MAC_ADDRESS = Mac.new( 0 ).to_a
|
14
14
|
|
15
15
|
|
16
16
|
########################################################################
|
data/lib/pio/mac.rb
CHANGED
@@ -3,9 +3,13 @@ require "forwardable"
|
|
3
3
|
|
4
4
|
module Pio
|
5
5
|
#
|
6
|
-
# Ethernet address class
|
6
|
+
# Ethernet address (MAC address) class.
|
7
7
|
#
|
8
8
|
class Mac
|
9
|
+
# Raised when Ethernet address is invalid.
|
10
|
+
class InvalidValueError < StandardError; end
|
11
|
+
|
12
|
+
|
9
13
|
extend Forwardable
|
10
14
|
def_delegator :@value, :hash
|
11
15
|
|
@@ -15,50 +19,51 @@ module Pio
|
|
15
19
|
#
|
16
20
|
# @example address as a hexadecimal string
|
17
21
|
# Mac.new("11:22:33:44:55:66")
|
18
|
-
#
|
19
22
|
# @example address as a hexadecimal number
|
20
23
|
# Mac.new(0xffffffffffff)
|
21
24
|
#
|
25
|
+
# @param value [#to_str, #to_int] the value converted to an
|
26
|
+
# Ethernet address.
|
27
|
+
#
|
22
28
|
def initialize value
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
begin
|
30
|
+
if value.respond_to?( :to_str )
|
31
|
+
@value = parse_mac_string( value.to_str )
|
32
|
+
elsif value.respond_to?( :to_int )
|
33
|
+
@value = value.to_int
|
34
|
+
validate_value_range
|
35
|
+
else
|
36
|
+
raise TypeError
|
37
|
+
end
|
38
|
+
rescue ArgumentError, TypeError
|
39
|
+
raise InvalidValueError, "Invalid MAC address: #{ value.inspect }"
|
30
40
|
end
|
31
41
|
end
|
32
42
|
|
33
43
|
|
44
|
+
# @!group Converters
|
45
|
+
|
34
46
|
#
|
35
47
|
# Returns an Ethernet address in its numeric presentation.
|
36
48
|
#
|
37
49
|
# @example
|
38
50
|
# Mac.new("11:22:33:44:55:66").to_i #=> 18838586676582
|
39
51
|
#
|
52
|
+
# @return [Integer]
|
53
|
+
#
|
40
54
|
def to_i
|
41
55
|
@value
|
42
56
|
end
|
43
57
|
|
44
58
|
|
45
|
-
#
|
46
|
-
# @see to_i
|
47
|
-
#
|
48
|
-
# @example
|
49
|
-
# Mac.new("11:22:33:44:55:66").to_int #=> 18838586676582
|
50
|
-
#
|
51
|
-
def to_int
|
52
|
-
to_i
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
59
|
#
|
57
60
|
# Returns the Ethernet address as 6 pairs of hexadecimal digits
|
58
61
|
# delimited by colons.
|
59
62
|
#
|
60
63
|
# @example
|
61
|
-
# Mac.new(
|
64
|
+
# Mac.new(0x112233445566).to_s #=> "11:22:33:44:55:66"
|
65
|
+
#
|
66
|
+
# @return [String]
|
62
67
|
#
|
63
68
|
def to_s
|
64
69
|
sprintf( "%012x", @value ).unpack( "a2" * 6 ).join( ":" )
|
@@ -66,10 +71,15 @@ module Pio
|
|
66
71
|
|
67
72
|
|
68
73
|
#
|
69
|
-
#
|
74
|
+
# Implicitly converts +obj+ to a string.
|
70
75
|
#
|
71
76
|
# @example
|
72
|
-
# Mac.new(
|
77
|
+
# mac = Mac.new("11:22:33:44:55:66")
|
78
|
+
# puts "MAC = " + mac #=> "MAC = 11:22:33:44:55:66"
|
79
|
+
#
|
80
|
+
# @see #to_s
|
81
|
+
#
|
82
|
+
# @return [String]
|
73
83
|
#
|
74
84
|
def to_str
|
75
85
|
to_s
|
@@ -77,11 +87,13 @@ module Pio
|
|
77
87
|
|
78
88
|
|
79
89
|
#
|
80
|
-
# Returns an
|
90
|
+
# Returns an Array of decimal numbers converted from Ethernet's
|
81
91
|
# address string format.
|
82
92
|
#
|
83
93
|
# @example
|
84
|
-
# Mac.new("11:22:33:44:55:66").to_a #=> [
|
94
|
+
# Mac.new("11:22:33:44:55:66").to_a #=> [0x11, 0x22, 0x33, 0x44, 0x55, 0x66]
|
95
|
+
#
|
96
|
+
# @return [Array]
|
85
97
|
#
|
86
98
|
def to_a
|
87
99
|
to_s.split( ":" ).collect do | each |
|
@@ -89,53 +101,116 @@ module Pio
|
|
89
101
|
end
|
90
102
|
end
|
91
103
|
|
104
|
+
# @!endgroup
|
105
|
+
|
106
|
+
|
107
|
+
# @!group Predicates
|
108
|
+
|
109
|
+
#
|
110
|
+
# Returns true if Ethernet address is a multicast address.
|
111
|
+
#
|
112
|
+
# @example
|
113
|
+
# Mac.new("01:00:00:00:00:00").multicast? #=> true
|
114
|
+
# Mac.new("00:00:00:00:00:00").multicast? #=> false
|
115
|
+
#
|
116
|
+
def multicast?
|
117
|
+
to_a[ 0 ] & 1 == 1
|
118
|
+
end
|
119
|
+
|
92
120
|
|
93
121
|
#
|
94
|
-
#
|
122
|
+
# Returns true if Ethernet address is a broadcast address.
|
95
123
|
#
|
96
124
|
# @example
|
97
|
-
# Mac.new("
|
125
|
+
# Mac.new("ff:ff:ff:ff:ff:ff").broadcast? #=> true
|
98
126
|
#
|
99
|
-
def
|
100
|
-
to_a
|
127
|
+
def broadcast?
|
128
|
+
to_a.all? { | each | each == 0xff }
|
101
129
|
end
|
102
130
|
|
103
131
|
|
104
132
|
#
|
105
|
-
#
|
133
|
+
# Returns +true+ if Ethernet address is an IEEE 802.1D or 802.1Q
|
134
|
+
# reserved address. See
|
135
|
+
# http://standards.ieee.org/develop/regauth/grpmac/public.html for
|
136
|
+
# details.
|
137
|
+
#
|
138
|
+
# @example
|
139
|
+
# Mac.new("01:80:c2:00:00:00").reserved? #=> true
|
140
|
+
# Mac.new("11:22:33:44:55:66").reserved? #=> false
|
141
|
+
#
|
142
|
+
def reserved?
|
143
|
+
( to_i >> 8 ) == 0x0180c20000
|
144
|
+
end
|
145
|
+
|
146
|
+
# @!endgroup
|
147
|
+
|
148
|
+
|
149
|
+
# @!group Equality
|
150
|
+
|
151
|
+
#
|
152
|
+
# Returns +true+ if +other+ can be converted to a {Mac}
|
153
|
+
# object and its numeric representation is equal to +obj+'s.
|
154
|
+
#
|
155
|
+
# @example
|
156
|
+
# mac_address = Mac.new("11:22:33:44:55:66")
|
157
|
+
#
|
158
|
+
# mac_address == Mac.new("11:22:33:44:55:66") #=> true
|
159
|
+
# mac_address == "11:22:33:44:55:66" #=> true
|
160
|
+
# mac_address == 0x112233445566 #=> true
|
161
|
+
# mac_address == "INVALID_MAC_ADDRESS" #=> false
|
162
|
+
#
|
163
|
+
# @param other [#to_str, #to_int] a {Mac} object or an object
|
164
|
+
# that can be converted to an Ethernet address.
|
165
|
+
#
|
166
|
+
# @return [Boolean]
|
106
167
|
#
|
107
168
|
def == other
|
108
169
|
begin
|
109
170
|
to_i == Mac.new( other ).to_i
|
110
|
-
rescue
|
171
|
+
rescue InvalidValueError
|
111
172
|
false
|
112
173
|
end
|
113
174
|
end
|
114
|
-
alias :eql? :==
|
115
175
|
|
116
176
|
|
117
177
|
#
|
118
|
-
# Returns true if
|
178
|
+
# Returns +true+ if +obj+ and +other+ refer to the same hash key.
|
179
|
+
# +#==+ is used for the comparison.
|
119
180
|
#
|
120
181
|
# @example
|
121
|
-
#
|
122
|
-
#
|
182
|
+
# fdb = {
|
183
|
+
# Mac.new("11:22:33:44:55:66") => 1,
|
184
|
+
# Mac.new("66:55:44:33:22:11") => 2
|
185
|
+
# }
|
123
186
|
#
|
124
|
-
|
125
|
-
|
187
|
+
# fdb[ Mac.new("11:22:33:44:55:66")] #=> 1
|
188
|
+
# fdb["11:22:33:44:55:66"] #=> 1
|
189
|
+
# fdb[0x112233445566] #=> 1
|
190
|
+
#
|
191
|
+
# @see #==
|
192
|
+
#
|
193
|
+
def eql? other
|
194
|
+
self.== other
|
126
195
|
end
|
127
196
|
|
197
|
+
# @!endgroup
|
198
|
+
|
199
|
+
|
200
|
+
# @!group Debug
|
128
201
|
|
129
202
|
#
|
130
|
-
# Returns
|
203
|
+
# Returns a string containing a human-readable representation of
|
204
|
+
# {Mac} for debugging.
|
131
205
|
#
|
132
|
-
# @
|
133
|
-
# Mac.new("ff:ff:ff:ff:ff:ff").broadcast? #=> true
|
206
|
+
# @return [String]
|
134
207
|
#
|
135
|
-
def
|
136
|
-
|
208
|
+
def inspect
|
209
|
+
%{#<#{ self.class }:#{ __id__ } "#{ to_s }">}
|
137
210
|
end
|
138
211
|
|
212
|
+
# @!endgroup
|
213
|
+
|
139
214
|
|
140
215
|
################################################################################
|
141
216
|
private
|
@@ -147,14 +222,14 @@ module Pio
|
|
147
222
|
if /^(#{ octet_regex }:){5}(#{ octet_regex })$/=~ mac
|
148
223
|
mac.gsub( ":", "" ).hex
|
149
224
|
else
|
150
|
-
raise ArgumentError
|
225
|
+
raise ArgumentError
|
151
226
|
end
|
152
227
|
end
|
153
228
|
|
154
229
|
|
155
230
|
def validate_value_range
|
156
231
|
unless ( @value >= 0 and @value <= 0xffffffffffff )
|
157
|
-
raise ArgumentError
|
232
|
+
raise ArgumentError
|
158
233
|
end
|
159
234
|
end
|
160
235
|
end
|
data/lib/pio/version.rb
CHANGED
data/pio.org
CHANGED
@@ -43,10 +43,16 @@ http:///www.asahi-net.or.jp/~aa4t-nngk/ipttut/output/icmpheaders.html
|
|
43
43
|
BinData での optional TLV の使い方
|
44
44
|
|
45
45
|
** Trema/Pioでパケットを作ろう(1) :NOTE:
|
46
|
+
:PROPERTIES:
|
47
|
+
:ID: BA8B555C-1FBE-4FDD-BFAC-D80EE9366643
|
48
|
+
:END:
|
46
49
|
[2013-10-06 日 15:55]
|
47
50
|
|
48
51
|
http://d.hatena.ne.jp/stereocat/20131005/1380977633
|
49
52
|
** Trema/Pioでパケットを作ろう(2) :NOTE:
|
53
|
+
:PROPERTIES:
|
54
|
+
:ID: 29F0265C-BF73-4749-A93D-20B0BF62C45E
|
55
|
+
:END:
|
50
56
|
[2013-10-06 日 15:55]
|
51
57
|
|
52
58
|
http://d.hatena.ne.jp/stereocat/20131006/1381028321
|
@@ -58,22 +64,20 @@ http://d.hatena.ne.jp/stereocat/20131006/1381028321
|
|
58
64
|
[2013-09-05 木 21:32]
|
59
65
|
** TODO 各 OpenFlow メッセージのパーサを作る
|
60
66
|
[2013-09-06 金 19:27]
|
67
|
+
*** TODO Trema::Hello の spec を見直し
|
61
68
|
** TODO Nick さんに README の英語をチェックしてもらう
|
62
69
|
[2013-09-18 水 12:01]
|
63
70
|
** TODO phost を Pio で書き直す
|
64
71
|
[2013-09-24 火 15:36]
|
72
|
+
|
73
|
+
関連するタスク:
|
74
|
+
- [[*Trema/Pio%E3%81%A7%E3%83%91%E3%82%B1%E3%83%83%E3%83%88%E3%82%92%E4%BD%9C%E3%82%8D%E3%81%86(1)][Trema/Pioでパケットを作ろう(1)]]
|
75
|
+
- [[*Trema/Pio%E3%81%A7%E3%83%91%E3%82%B1%E3%83%83%E3%83%88%E3%82%92%E4%BD%9C%E3%82%8D%E3%81%86(2)][Trema/Pioでパケットを作ろう(2)]]
|
65
76
|
** TODO DHCP パーサを作る
|
66
77
|
[2013-08-02 金 17:17]
|
67
78
|
|
68
79
|
近藤さんがすでにコーディング中。Pull-Request が来たらいっしょにリファ
|
69
80
|
クタリングして取り込む予定。
|
70
|
-
** TODO おかしな MAC アドレスはすべて InvalidMAC 例外にまとめる
|
71
|
-
:LOGBOOK:
|
72
|
-
CLOCK: [2013-10-07 月 10:22]--[2013-10-07 月 10:23] => 0:01
|
73
|
-
:END:
|
74
|
-
[2013-10-07 月 10:22]
|
75
|
-
|
76
|
-
ファイルは lib/pio/mac.rb
|
77
81
|
* Releases
|
78
82
|
** DONE 0.2.2 リリース
|
79
83
|
CLOSED: [2013-09-26 木 15:34]
|
@@ -165,6 +169,27 @@ CLOCK: [2013-10-07 月 10:23]--[2013-10-07 月 10:24] => 0:01
|
|
165
169
|
=#to_a= と =#to_ary= のコメントとか.
|
166
170
|
** TODO 0.2.6 リリース
|
167
171
|
[2013-10-10 木 13:37]
|
172
|
+
*** DONE Pio::Mac のリファクタリング
|
173
|
+
CLOSED: [2013-10-11 金 13:31] SCHEDULED: <2013-10-11 金>
|
174
|
+
:LOGBOOK:
|
175
|
+
CLOCK: [2013-10-11 金 09:39]--[2013-10-11 金 12:16] => 2:37
|
176
|
+
:END:
|
177
|
+
[2013-10-11 金 09:37]
|
178
|
+
|
179
|
+
- YARD コメント
|
180
|
+
- RSpec
|
181
|
+
- いらないメソッドの削除
|
182
|
+
など.
|
183
|
+
*** DONE おかしな MAC アドレスはすべて InvalidMAC 例外にまとめる
|
184
|
+
CLOSED: [2013-10-11 金 13:31]
|
185
|
+
:LOGBOOK:
|
186
|
+
CLOCK: [2013-10-07 月 10:22]--[2013-10-07 月 10:23] => 0:01
|
187
|
+
:END:
|
188
|
+
[2013-10-07 月 10:22]
|
189
|
+
|
190
|
+
ファイルは lib/pio/mac.rb
|
191
|
+
** TODO 0.2.7 リリース
|
192
|
+
[2013-10-11 金 14:32]
|
168
193
|
*** TODO 鈴木さんルータの ARP 部分を Pio で書き直してもらう
|
169
194
|
- State "TODO" from "WAITING" [2013-09-19 木 14:18]
|
170
195
|
- State "WAITING" from "TODO" [2013-09-18 水 12:04] \\
|
@@ -177,7 +202,7 @@ CLOCK: [2013-09-14 土 10:20]--[2013-09-14 土 10:21] => 0:01
|
|
177
202
|
GitHub のチケットはこちら:
|
178
203
|
https://github.com/trema/pio/issues/1
|
179
204
|
**** NEXT 鈴木さんルータの ARP 部分を試しに自分で書き直してみる
|
180
|
-
SCHEDULED: <2013-10-
|
205
|
+
SCHEDULED: <2013-10-10 木>
|
181
206
|
:PROPERTIES:
|
182
207
|
:Effort: 1:00
|
183
208
|
:END:
|
data/spec/pio/mac_spec.rb
CHANGED
@@ -9,65 +9,107 @@ module Pio
|
|
9
9
|
|
10
10
|
context %{with "11:22:33:44:55:66"} do
|
11
11
|
let( :value ) { "11:22:33:44:55:66" }
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
|
13
|
+
describe "#==" do
|
14
|
+
it { should eq Mac.new( "11:22:33:44:55:66" ) }
|
15
|
+
it { should eq "11:22:33:44:55:66" }
|
16
|
+
it { should_not eq Mac.new( "66:55:44:33:22:11" ) }
|
17
|
+
it { should_not eq "66:55:44:33:22:11" }
|
18
|
+
it { should eq 0x112233445566 }
|
19
|
+
it { should_not eq 42 }
|
20
|
+
it { should_not eq "INVALID_MAC_ADDRESS" }
|
21
|
+
end
|
22
|
+
describe "#eql?" do
|
23
|
+
it { expect( subject ).to eql Mac.new( "11:22:33:44:55:66" ) }
|
24
|
+
it { expect( subject ).to eql "11:22:33:44:55:66" }
|
25
|
+
it { expect( subject ).not_to eql Mac.new( "66:55:44:33:22:11" ) }
|
26
|
+
it { expect( subject ).not_to eql "66:55:44:33:22:11" }
|
27
|
+
it { expect( subject ).to eql 0x112233445566 }
|
28
|
+
it { expect( subject ).not_to eql 42 }
|
29
|
+
it { expect( subject ).not_to eql "INVALID_MAC_ADDRESS" }
|
30
|
+
end
|
31
|
+
|
32
|
+
its( :hash ) { should eq Mac.new( "11:22:33:44:55:66" ).hash }
|
33
|
+
|
34
|
+
its( :to_i ) { should eq 0x112233445566 }
|
35
|
+
its( :to_a ) { should eq [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 ] }
|
36
|
+
its( :to_s ) { should eq "11:22:33:44:55:66" }
|
37
|
+
describe "#to_str" do
|
38
|
+
context %{when "MAC = " + subject} do
|
39
|
+
it { expect( "MAC = " + subject ).to eq "MAC = 11:22:33:44:55:66" }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
16
43
|
its( :multicast? ){ should be_true }
|
17
44
|
its( :broadcast? ){ should be_false }
|
45
|
+
its( :reserved? ){ should be_false }
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
context "with reserved address" do
|
50
|
+
( 0x0..0xf ).each do | each |
|
51
|
+
octet = "%02x" % each
|
52
|
+
reserved_address = "01:80:c2:00:00:#{ octet }"
|
53
|
+
|
54
|
+
context "when #{ reserved_address }" do
|
55
|
+
let( :value ) { reserved_address }
|
56
|
+
its( :reserved? ) { should be_true }
|
57
|
+
end
|
58
|
+
end
|
18
59
|
end
|
19
60
|
|
20
61
|
|
21
62
|
context "with 0" do
|
22
63
|
let( :value ) { 0 }
|
64
|
+
|
23
65
|
it { should eq Mac.new( 0 ) }
|
24
|
-
its( :
|
25
|
-
its( :
|
26
|
-
its( :
|
66
|
+
its( :to_i ) { should eq 0 }
|
67
|
+
its( :to_a ) { should eq [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ] }
|
68
|
+
its( :to_s ) { should eq "00:00:00:00:00:00" }
|
27
69
|
its( :multicast? ){ should be_false }
|
28
70
|
its( :broadcast? ){ should be_false }
|
71
|
+
its( :reserved? ){ should be_false }
|
29
72
|
end
|
30
73
|
|
31
74
|
|
32
75
|
context "with 0xffffffffffff" do
|
33
76
|
let( :value ) { 0xffffffffffff }
|
77
|
+
|
34
78
|
it { should eq Mac.new( 0xffffffffffff ) }
|
35
|
-
its( :
|
36
|
-
its( :
|
37
|
-
its( :
|
79
|
+
its( :to_i ) { should eq 0xffffffffffff }
|
80
|
+
its( :to_a ) { should eq [ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff ] }
|
81
|
+
its( :to_s ) { should eq "ff:ff:ff:ff:ff:ff" }
|
38
82
|
its( :multicast? ){ should be_true }
|
39
83
|
its( :broadcast? ){ should be_true }
|
84
|
+
its( :reserved? ){ should be_false }
|
40
85
|
end
|
41
86
|
|
42
87
|
|
43
88
|
context %{with "INVALID MAC ADDRESS"} do
|
44
89
|
let( :value ) { "INVALID MAC ADDRESS" }
|
45
|
-
|
90
|
+
|
91
|
+
it { expect { subject }.to raise_error( Mac::InvalidValueError ) }
|
46
92
|
end
|
47
93
|
|
48
94
|
|
49
95
|
context "with -1" do
|
50
96
|
let( :value ) { -1 }
|
51
|
-
|
97
|
+
|
98
|
+
it { expect { subject }.to raise_error( Mac::InvalidValueError ) }
|
52
99
|
end
|
53
100
|
|
54
101
|
|
55
102
|
context "with 0x1000000000000" do
|
56
103
|
let( :value ) { 0x1000000000000 }
|
57
|
-
|
104
|
+
|
105
|
+
it { expect { subject }.to raise_error( Mac::InvalidValueError ) }
|
58
106
|
end
|
59
107
|
|
60
108
|
|
61
109
|
context "with [ 1, 2, 3 ]" do
|
62
110
|
let( :value ) { [ 1, 2, 3 ] }
|
63
|
-
it { expect { subject }.to raise_error( TypeError ) }
|
64
|
-
end
|
65
|
-
|
66
111
|
|
67
|
-
|
68
|
-
let( :value ) { "00:00:00:00:00:01" }
|
69
|
-
it { expect( subject ).to eql Mac.new( "00:00:00:00:00:01" ) }
|
70
|
-
its( :hash ) { should eq Mac.new( "00:00:00:00:00:01" ).hash }
|
112
|
+
it { expect { subject }.to raise_error( Mac::InvalidValueError ) }
|
71
113
|
end
|
72
114
|
end
|
73
115
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yasuhito Takamiya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bindata
|