macaddr 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/lib/macaddr.rb +21 -7
  3. data/macaddr.gemspec +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjkzYjEyMDE0ZTU3YzI2MmRlNDFiOWRmNzMwOGE2YWNmY2JhMTVhZg==
4
+ NjZlZWVhMzVkOWY2YzdiMWJjZDNhNzRmYmMxOWFhYzMxODkyY2RiYg==
5
5
  data.tar.gz: !binary |-
6
- NDY2ZTVhMmI5MWI0NzRhYzUyNGY1MTRiODA2MTI3ZWJlMzY5NjQ1Yg==
6
+ M2E5ODVkNDgwNWMyMzM4Zjc2MTA5OTI5OGI4NTgyYWZiZDdiYjk2Yg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MTEzMTNhMjViOWRhYjQ0ZDBjNDI5N2ZhNDM5NmQ3NmFmNDg1YTcyOWFmYjIy
10
- ZTc0YmFhYTU5MjIyNGI1NjIyOWRjOTdkNmY3ODlhOGFiNWRmYzcyZjJlNWEw
11
- MDI5MGRhZGRhYjhhYzU3OTY3ODI3NTljOGE5Zjk5YTkxYmRiYjY=
9
+ Y2VjYzUxZmQ1NGI0ZDc2MzA3ZGZkNDYyNDcxMmUxMDM1ZDU2NDYwN2JmMjli
10
+ ZmI0ODFhMDFjMmRhOGU2OWFjMjdmNmM1YWJmOGUzZjBjM2MwMzdlZGE1MDEw
11
+ YzczY2FkZmU3MTk5ZDg5OTgyNzJjOTZhYzVhMjEzMDA2OTI5MjU=
12
12
  data.tar.gz: !binary |-
13
- NmM4YjBjOGI0ZmJiMGUwNjI2ZDA2YThmYWVkZDZmMjI0ZmRjZTMxMDM4MmVm
14
- MTM2YmM1NjQ3ZjdlYmE5NjM2ZDI3ZjUwYWM1YWY1NDVjN2Y3NzUwMzA3YmY2
15
- MDdjMjRmYzVmY2QzOTk1ZTYyNjA0Mzc1MDI3MmFlOWI5OWE5MzM=
13
+ Y2ZkOGEzZTYyZTRjMzg2Y2IxM2IxYTcyNGY3OTNjNmQ4MmE1NmY3NDkwZjk4
14
+ ODAwYWE4MTgwZWU4ZDk3NmViMzhjMjVjMGIwYzA3Y2ZiZjE4ZmNkMGIwMzFj
15
+ YjBlMzFhMWRiNzA4ZDYwMDQ4MTIxNGZjZjU4NzRjODhkMjhhNzg=
@@ -24,7 +24,7 @@ require 'systemu'
24
24
  require 'socket'
25
25
 
26
26
  module Mac
27
- VERSION = '1.7.0'
27
+ VERSION = '1.7.1'
28
28
 
29
29
  def Mac.version
30
30
  ::Mac::VERSION
@@ -75,16 +75,30 @@ module Mac
75
75
  @mac_address = parse(output)
76
76
  end
77
77
 
78
+ link = Socket::PF_LINK if Socket.const_defined? :PF_LINK
79
+ packet = Socket::PF_PACKET if Socket.const_defined? :PF_PACKET
80
+ INTERFACE_PACKET_FAMILY = link || packet # :nodoc:
81
+
78
82
  def from_getifaddrs
79
83
  return unless Socket.respond_to? :getifaddrs
80
84
 
85
+ interfaces = Socket.getifaddrs.select do |addr|
86
+ addr.addr.pfamily == INTERFACE_PACKET_FAMILY
87
+ end
88
+
81
89
  mac, =
82
- Socket.getifaddrs.select do |addr|
83
- addr.addr.pfamily == Socket::PF_LINK
84
- end.map do |addr|
85
- addr.addr.getnameinfo
86
- end.find do |m,|
87
- !m.empty?
90
+ if Socket.const_defined? :PF_LINK then
91
+ interfaces.map do |addr|
92
+ addr.addr.getnameinfo
93
+ end.find do |m,|
94
+ !m.empty?
95
+ end
96
+ elsif Socket.const_defined? :PF_PACKET then
97
+ interfaces.map do |addr|
98
+ addr.addr.inspect_sockaddr[/hwaddr=([\h:]+)/, 1]
99
+ end.find do |mac_addr|
100
+ mac_addr != '00:00:00:00:00:00'
101
+ end
88
102
  end
89
103
 
90
104
  @mac_address = mac if mac
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "macaddr"
6
- spec.version = "1.7.0"
6
+ spec.version = "1.7.1"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "macaddr"
9
9
  spec.description = "cross platform mac address determination for ruby"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: macaddr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ara T. Howard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-03 00:00:00.000000000 Z
11
+ date: 2014-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu