hwaddr 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,7 +15,7 @@ until io.eof?
15
15
  buf = ''
16
16
  buf += io.readline while !io.eof? and buf !~ /\n{2}$/
17
17
 
18
- if buf =~ /^([0-9a-fA-F]{2})-([0-9a-fA-F]{2})-([0-9a-fA-F]{2})\s+\(hex\)\s+(.+?)\n\1\2\3\s+\(base 16\)\s+\4\n(.*)$/m
18
+ if buf =~ /^(\h\h)-(\h\h)-(\h\h)\s+\(hex\)\s+(.+?)\n\1\2\3\s+\(base 16\)\s+\4\n(.*)$/m
19
19
  cid, org, addr = "#$1:#$2:#$3", $4, $5.split(/\n/).map(&:strip).join("\n")
20
20
 
21
21
  puts "HWAddr::Database.add(#{org.inspect}, #{cid.inspect}, #{addr.inspect})"
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new {|s|
2
2
  s.name = 'hwaddr'
3
- s.version = '0.0.3'
3
+ s.version = '0.0.4'
4
4
  s.author = 'meh.'
5
5
  s.email = 'meh@paranoici.org'
6
6
  s.homepage = 'http://github.com/meh/ruby-hwaddr'
@@ -12,7 +12,7 @@ class HWAddr
12
12
  autoload :Database, 'hwaddr/database'
13
13
 
14
14
  def self.valid? (text)
15
- text =~ /^\w\w:\w\w:\w\w(?::\w\w:\w\w:\w\w)?$/
15
+ text =~ /^\h\h:\h\h:\h\h(?::\h\h:\h\h:\h\h)?$/
16
16
  end
17
17
 
18
18
  def initialize (value)
@@ -44,6 +44,16 @@ class HWAddr
44
44
  @string.downcase!
45
45
  end
46
46
 
47
+ def hash
48
+ to_s.hash
49
+ end
50
+
51
+ def == (other)
52
+ to_s == other.to_s
53
+ end
54
+
55
+ alias eql? ==
56
+
47
57
  def =~ (other)
48
58
  if group?
49
59
  to_s == other.to_s[0, 8]
@@ -67,4 +77,8 @@ class HWAddr
67
77
  def to_s
68
78
  @string
69
79
  end
80
+
81
+ def inspect
82
+ "#<HWAddr: #{to_s}>"
83
+ end
70
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hwaddr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-17 00:00:00.000000000 Z
12
+ date: 2012-07-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: meh@paranoici.org