macaddr 1.6.7 → 1.7.0

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 -1
  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
- ZmNhMTdlYWU3ZGFhNmVlNDQ4Y2IzMDU2NjFhODY4YTZjNWIyMWE4ZA==
4
+ ZjkzYjEyMDE0ZTU3YzI2MmRlNDFiOWRmNzMwOGE2YWNmY2JhMTVhZg==
5
5
  data.tar.gz: !binary |-
6
- ODljYjgwOGFlOWU5Y2FiZjk4MzA4ZWUzYjhlMGI2OTU5ZGMwMDczYw==
6
+ NDY2ZTVhMmI5MWI0NzRhYzUyNGY1MTRiODA2MTI3ZWJlMzY5NjQ1Yg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZWJhYTZiMjYxZTE5ZWZlNzUyOWVjZTFjZjRkMWZmNDEyODU0NDNkZTRmODY5
10
- MDgzZDk1NTVkODIwOTE2YzllZTYxMDI2ZjQzMmU0Nzc2NDMyYzJlN2I2Mjk0
11
- OTMyYTE4ZTljOGUxNGNhYTQyNDhkNzQwYmI5ZWIwNWYzYWMxNTg=
9
+ MTEzMTNhMjViOWRhYjQ0ZDBjNDI5N2ZhNDM5NmQ3NmFmNDg1YTcyOWFmYjIy
10
+ ZTc0YmFhYTU5MjIyNGI1NjIyOWRjOTdkNmY3ODlhOGFiNWRmYzcyZjJlNWEw
11
+ MDI5MGRhZGRhYjhhYzU3OTY3ODI3NTljOGE5Zjk5YTkxYmRiYjY=
12
12
  data.tar.gz: !binary |-
13
- NmY1NjlmYTBmYTYyMDJiYWQ0NTczMzZlZmVjNmE3ZjliZTI3YjBlNDBjNDVm
14
- ODkyZDU4NDkwYzllMDRhMjgxMTI2MTM4YmM3Y2JmNDY0MWNkZTg1MzkzMTVi
15
- Y2NhNWU2YTRjN2JlNGZlODE2MTNhNDNlNzdhNWNjMjI3NWU4ZmQ=
13
+ NmM4YjBjOGI0ZmJiMGUwNjI2ZDA2YThmYWVkZDZmMjI0ZmRjZTMxMDM4MmVm
14
+ MTM2YmM1NjQ3ZjdlYmE5NjM2ZDI3ZjUwYWM1YWY1NDVjN2Y3NzUwMzA3YmY2
15
+ MDdjMjRmYzVmY2QzOTk1ZTYyNjA0Mzc1MDI3MmFlOWI5OWE5MzM=
@@ -21,9 +21,10 @@ rescue LoadError
21
21
  end
22
22
 
23
23
  require 'systemu'
24
+ require 'socket'
24
25
 
25
26
  module Mac
26
- VERSION = '1.6.7'
27
+ VERSION = '1.7.0'
27
28
 
28
29
  def Mac.version
29
30
  ::Mac::VERSION
@@ -57,6 +58,10 @@ module Mac
57
58
 
58
59
  def address
59
60
  return @mac_address if defined? @mac_address and @mac_address
61
+
62
+ @mac_address = from_getifaddrs
63
+ return @mac_address if @mac_address
64
+
60
65
  cmds = '/sbin/ifconfig', '/bin/ifconfig', 'ifconfig', 'ipconfig /all', 'cat /sys/class/net/*/address'
61
66
 
62
67
  output = nil
@@ -70,6 +75,21 @@ module Mac
70
75
  @mac_address = parse(output)
71
76
  end
72
77
 
78
+ def from_getifaddrs
79
+ return unless Socket.respond_to? :getifaddrs
80
+
81
+ 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?
88
+ end
89
+
90
+ @mac_address = mac if mac
91
+ end
92
+
73
93
  def parse(output)
74
94
  lines = output.split(/\n/)
75
95
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "macaddr"
6
- spec.version = "1.6.7"
6
+ spec.version = "1.7.0"
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.6.7
4
+ version: 1.7.0
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-03-03 00:00:00.000000000 Z
11
+ date: 2014-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu