macaddr 1.6.7 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/macaddr.rb +21 -1
- data/macaddr.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjkzYjEyMDE0ZTU3YzI2MmRlNDFiOWRmNzMwOGE2YWNmY2JhMTVhZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDY2ZTVhMmI5MWI0NzRhYzUyNGY1MTRiODA2MTI3ZWJlMzY5NjQ1Yg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTEzMTNhMjViOWRhYjQ0ZDBjNDI5N2ZhNDM5NmQ3NmFmNDg1YTcyOWFmYjIy
|
10
|
+
ZTc0YmFhYTU5MjIyNGI1NjIyOWRjOTdkNmY3ODlhOGFiNWRmYzcyZjJlNWEw
|
11
|
+
MDI5MGRhZGRhYjhhYzU3OTY3ODI3NTljOGE5Zjk5YTkxYmRiYjY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmM4YjBjOGI0ZmJiMGUwNjI2ZDA2YThmYWVkZDZmMjI0ZmRjZTMxMDM4MmVm
|
14
|
+
MTM2YmM1NjQ3ZjdlYmE5NjM2ZDI3ZjUwYWM1YWY1NDVjN2Y3NzUwMzA3YmY2
|
15
|
+
MDdjMjRmYzVmY2QzOTk1ZTYyNjA0Mzc1MDI3MmFlOWI5OWE5MzM=
|
data/lib/macaddr.rb
CHANGED
@@ -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.
|
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
|
|
data/macaddr.gemspec
CHANGED
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.
|
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-
|
11
|
+
date: 2014-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: systemu
|