mac-address 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +57 -0
- data/README.md +54 -0
- data/Rakefile +8 -0
- data/lib/mac-address.rb +81 -0
- data/lib/mac-address/version.rb +5 -0
- data/lib/macaddr.rb +4 -0
- data/mac-address.gemspec +26 -0
- data/spec/fixtures/noifconfig +3 -0
- data/spec/fixtures/osx +39 -0
- data/spec/fixtures/windows +84 -0
- data/spec/mac-address_spec.rb +55 -0
- data/spec/macaddr-compatibility_spec.rb +17 -0
- data/spec/spec_helper.rb +8 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZmZlMDk1MDI3OTI4NjJhZTRiOGUzZTBmZTE3ZmU0NmZhYmY5MTRkNQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzMxMjdmMWQyM2U4NjUwYTcxMzU1ZmRkMzY0N2VjOTk4Yjc5N2U2Zg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
OGNkODExZmQzZjJmYjEzMmY5MmRlZTBmNjE5NTczZTY1Nzc3Y2U3MTM1ODEw
|
10
|
+
NjdhZmM2NzM5Y2FlNDc3ZjliNTRjZjI5ZWVlYWEzMTJhY2Q2N2I4YzA0ZjQ2
|
11
|
+
NTExYjE1ZTFkODdjYjkxMWFhZDJjYTNlMDI2ZjQ1NDY3NjE4YWQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTk5ZDY1MzA5OGYzMjEwMTMyNzI3MGZhNTEyZDZkY2JkNGUwYmRkYjkxNzJm
|
14
|
+
NWEzMTk5YzUyYzYzYjg0Mzk2ZDliNjQwMDYxYzdhOTcxMTAwMDM0YzZhOTQ3
|
15
|
+
ZWUyZmE3ZDE5ZWYzODI3Y2QzMTQyOTJlNWIzY2UzYjIwYzQ5Y2E=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
MacAddress is copyrighted free software by Ara T. Howard <ara.t.howard@gmail.com>,
|
2
|
+
Ryan Biesemeyer <ryan@yaauie.com>, and other contributors.
|
3
|
+
You can redistribute it and/or modify it under either the terms of the
|
4
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
5
|
+
|
6
|
+
1. You may make and give away verbatim copies of the source form of the
|
7
|
+
software without restriction, provided that you duplicate all of the
|
8
|
+
original copyright notices and associated disclaimers.
|
9
|
+
|
10
|
+
2. You may modify your copy of the software in any way, provided that
|
11
|
+
you do at least ONE of the following:
|
12
|
+
|
13
|
+
a) place your modifications in the Public Domain or otherwise
|
14
|
+
make them Freely Available, such as by posting said
|
15
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
16
|
+
the author to include your modifications in the software.
|
17
|
+
|
18
|
+
b) use the modified software only within your corporation or
|
19
|
+
organization.
|
20
|
+
|
21
|
+
c) give non-standard binaries non-standard names, with
|
22
|
+
instructions on where to get the original software distribution.
|
23
|
+
|
24
|
+
d) make other distribution arrangements with the author.
|
25
|
+
|
26
|
+
3. You may distribute the software in object code or binary form,
|
27
|
+
provided that you do at least ONE of the following:
|
28
|
+
|
29
|
+
a) distribute the binaries and library files of the software,
|
30
|
+
together with instructions (in the manual page or equivalent)
|
31
|
+
on where to get the original distribution.
|
32
|
+
|
33
|
+
b) accompany the distribution with the machine-readable source of
|
34
|
+
the software.
|
35
|
+
|
36
|
+
c) give non-standard binaries non-standard names, with
|
37
|
+
instructions on where to get the original software distribution.
|
38
|
+
|
39
|
+
d) make other distribution arrangements with the author.
|
40
|
+
|
41
|
+
4. You may modify and include the part of the software into any other
|
42
|
+
software (possibly commercial). But some files in the distribution
|
43
|
+
are not written by the author, so that they are not under these terms.
|
44
|
+
|
45
|
+
For the list of those files and their copying conditions, see the
|
46
|
+
file LEGAL.
|
47
|
+
|
48
|
+
5. The scripts and library files supplied as input to or produced as
|
49
|
+
output from the software do not automatically fall under the
|
50
|
+
copyright of the software, but belong to whomever generated them,
|
51
|
+
and may be sold commercially, and may be aggregated with this
|
52
|
+
software.
|
53
|
+
|
54
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
55
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
56
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
57
|
+
PURPOSE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# MacAddress
|
2
|
+
|
3
|
+
`mac-address` gem is a clone of @ahoward's `macaddr` gem, and is a suitable
|
4
|
+
drop-in replacement.
|
5
|
+
|
6
|
+
The purpose of this fork is to fix version 1.6.2, which failed to list its
|
7
|
+
dependencies, and to simplify the development and test environments to allow
|
8
|
+
easier contribution.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'mac-address'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install mac-address
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
`MacAddress` gives you access to your MAC addresses.
|
27
|
+
|
28
|
+
~~~ ruby
|
29
|
+
require 'mac-address'
|
30
|
+
|
31
|
+
MacAddress.address
|
32
|
+
#=> 'c8:bc:c8:9b:28:b1'
|
33
|
+
MacAddress.address.list
|
34
|
+
#=> ['c8:bc:c8:9b:28:b1', 'd0:4e:f1:68:29:79']
|
35
|
+
~~~
|
36
|
+
|
37
|
+
Or, you can use this as a drop-in replacement for the `macaddr` gem:
|
38
|
+
|
39
|
+
~~~ ruby
|
40
|
+
require 'macaddr'
|
41
|
+
|
42
|
+
Mac.address
|
43
|
+
#=> 'c8:bc:c8:9b:28:b1'
|
44
|
+
Mac.address.list
|
45
|
+
#=> ['c8:bc:c8:9b:28:b1', 'd0:4e:f1:68:29:79']
|
46
|
+
~~~
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/mac-address.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems' unless defined?(::Gem)
|
4
|
+
require 'mac-address/version'
|
5
|
+
require 'systemu'
|
6
|
+
|
7
|
+
##
|
8
|
+
# Cross platform MAC address determination. Works for:
|
9
|
+
# * /sbin/ifconfig
|
10
|
+
# * /bin/ifconfig
|
11
|
+
# * ifconfig
|
12
|
+
# * ipconfig /all
|
13
|
+
# * cat /sys/class/net/*/address
|
14
|
+
#
|
15
|
+
# To return the first MAC address on the system:
|
16
|
+
#
|
17
|
+
# MacAddress.address
|
18
|
+
#
|
19
|
+
# To return an array of all MAC addresses:
|
20
|
+
#
|
21
|
+
# MacAddress.address.list
|
22
|
+
#
|
23
|
+
module MacAddress
|
24
|
+
class << self
|
25
|
+
|
26
|
+
def version
|
27
|
+
VERSION
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# Accessor for the system's first MAC address, requires a call to #address
|
32
|
+
# first
|
33
|
+
attr_accessor "mac_address"
|
34
|
+
|
35
|
+
##
|
36
|
+
# Discovers and returns the system's MAC addresses. Returns the first
|
37
|
+
# MAC address, and includes an accessor #list for the remaining addresses:
|
38
|
+
#
|
39
|
+
# Mac.addr # => first address
|
40
|
+
# Mac.addr.list # => all addresses
|
41
|
+
def address
|
42
|
+
return @mac_address if defined? @mac_address and @mac_address
|
43
|
+
re = %r/[^:\-](?:[0-9A-F][0-9A-F][:\-]){5}[0-9A-F][0-9A-F][^:\-]/io
|
44
|
+
cmds = '/sbin/ifconfig', '/bin/ifconfig', 'ifconfig', 'ipconfig /all', 'cat /sys/class/net/*/address'
|
45
|
+
|
46
|
+
null = test(?e, '/dev/null') ? '/dev/null' : 'NUL'
|
47
|
+
|
48
|
+
output = nil
|
49
|
+
cmds.each do |cmd|
|
50
|
+
status, stdout, stderr = systemu(cmd) rescue next
|
51
|
+
next unless stdout and stdout.size > 0
|
52
|
+
output = stdout and break
|
53
|
+
end
|
54
|
+
raise "all of #{ cmds.join ' ' } failed" unless output
|
55
|
+
|
56
|
+
@mac_address = parse(output)
|
57
|
+
end
|
58
|
+
|
59
|
+
def parse(output)
|
60
|
+
lines = output.split(/\n/)
|
61
|
+
|
62
|
+
candidates = lines.select{|line| line =~ RE}
|
63
|
+
raise 'no mac address candidates' unless candidates.first
|
64
|
+
candidates.map!{|c| c[RE].strip}
|
65
|
+
|
66
|
+
maddr = candidates.first
|
67
|
+
raise 'no mac address found' unless maddr
|
68
|
+
|
69
|
+
maddr.strip!
|
70
|
+
maddr.instance_eval{ @list = candidates; def list() @list end }
|
71
|
+
maddr
|
72
|
+
end
|
73
|
+
|
74
|
+
##
|
75
|
+
# Shorter alias for #address
|
76
|
+
alias_method "addr", "address"
|
77
|
+
end
|
78
|
+
|
79
|
+
RE = %r/(?:[^:\-]|\A)(?:[0-9A-F][0-9A-F][:\-]){5}[0-9A-F][0-9A-F](?:[^:\-]|\Z)/io
|
80
|
+
end
|
81
|
+
|
data/lib/macaddr.rb
ADDED
data/mac-address.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mac-address/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'mac-address'
|
8
|
+
spec.version = MacAddress::VERSION
|
9
|
+
spec.authors = ['Ara T. Howard', 'Ryan Biesemeyer']
|
10
|
+
spec.email = ["ryan@yaauie.com"]
|
11
|
+
spec.summary = 'cross platform mac address determination for ruby'
|
12
|
+
spec.description = 'based on @ahoward\'s macaddr gem'
|
13
|
+
spec.homepage = 'https://github.com/yaauie/mac-address'
|
14
|
+
spec.license = 'ruby'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'rspec', '>= 2.14.1'
|
24
|
+
|
25
|
+
spec.add_runtime_dependency 'systemu', '~> 2.5.0'
|
26
|
+
end
|
data/spec/fixtures/osx
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
|
2
|
+
inet6 ::1 prefixlen 128
|
3
|
+
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
|
4
|
+
inet 127.0.0.1 netmask 0xff000000
|
5
|
+
inet6 fdb1:49bc:790c:b10:cabc:c8ff:fe9b:28b1 prefixlen 128
|
6
|
+
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
|
7
|
+
stf0: flags=0<> mtu 1280
|
8
|
+
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
9
|
+
ether c8:bc:c8:9b:28:b1
|
10
|
+
media: autoselect (none)
|
11
|
+
status: inactive
|
12
|
+
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
13
|
+
ether c8:bc:c8:dc:c9:44
|
14
|
+
inet 10.0.1.7 netmask 0xffffff00 broadcast 10.0.1.255
|
15
|
+
media: autoselect
|
16
|
+
status: active
|
17
|
+
en2: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
18
|
+
ether 0b:0b:0b:0b:0b:0b
|
19
|
+
inet6 fe80::cabc:c8ff:fe9b:28b1%en2 prefixlen 64 scopeid 0x6
|
20
|
+
inet 169.254.67.37 netmask 0xffff0000 broadcast 169.254.255.255
|
21
|
+
media: autoselect (10baseT/UTP <full-duplex>)
|
22
|
+
status: active
|
23
|
+
fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078
|
24
|
+
lladdr 78:ca:39:ff:fe:37:4f:44
|
25
|
+
media: autoselect <full-duplex>
|
26
|
+
status: inactive
|
27
|
+
vmnet1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
28
|
+
ether 00:50:56:c0:00:01
|
29
|
+
inet 172.16.139.1 netmask 0xffffff00 broadcast 172.16.139.255
|
30
|
+
vmnet8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
31
|
+
ether 00:50:56:c0:00:08
|
32
|
+
inet 192.168.33.1 netmask 0xffffff00 broadcast 192.168.33.255
|
33
|
+
en4: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
|
34
|
+
ether c8:bc:c8:dc:ba:8a
|
35
|
+
media: autoselect
|
36
|
+
status: inactive
|
37
|
+
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1500
|
38
|
+
inet6 fe80::cabc:c8ff:fe9b:28b1%utun0 prefixlen 64 scopeid 0x9
|
39
|
+
inet6 fd00:6587:52d7:f8f2:cabc:c8ff:fe9b:28b1 prefixlen 64
|
@@ -0,0 +1,84 @@
|
|
1
|
+
Windows IP Configuration
|
2
|
+
|
3
|
+
Host Name . . . . . . . . . . . . : creep
|
4
|
+
Primary Dns Suffix . . . . . . . :
|
5
|
+
Node Type . . . . . . . . . . . . : Hybrid
|
6
|
+
IP Routing Enabled. . . . . . . . : No
|
7
|
+
WINS Proxy Enabled. . . . . . . . : No
|
8
|
+
|
9
|
+
Ethernet adapter Bluetooth Network Connection:
|
10
|
+
|
11
|
+
Media State . . . . . . . . . . . : Media disconnected
|
12
|
+
Connection-specific DNS Suffix . :
|
13
|
+
Description . . . . . . . . . . . : Bluetooth Device (Personal Area Network)
|
14
|
+
Physical Address. . . . . . . . . : 5C-51-4F-AF-09-9C
|
15
|
+
DHCP Enabled. . . . . . . . . . . : Yes
|
16
|
+
Autoconfiguration Enabled . . . . : Yes
|
17
|
+
|
18
|
+
Wireless LAN adapter Local Area Connection* 3:
|
19
|
+
|
20
|
+
Media State . . . . . . . . . . . : Media disconnected
|
21
|
+
Connection-specific DNS Suffix . :
|
22
|
+
Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter
|
23
|
+
Physical Address. . . . . . . . . : 5C-51-4F-51-49-E1
|
24
|
+
DHCP Enabled. . . . . . . . . . . : No
|
25
|
+
Autoconfiguration Enabled . . . . : Yes
|
26
|
+
|
27
|
+
Wireless LAN adapter Wi-Fi:
|
28
|
+
|
29
|
+
Connection-specific DNS Suffix . :
|
30
|
+
Description . . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 7260
|
31
|
+
Physical Address. . . . . . . . . : 5C-51-4F-22-7C-F3
|
32
|
+
DHCP Enabled. . . . . . . . . . . : Yes
|
33
|
+
Autoconfiguration Enabled . . . . : Yes
|
34
|
+
Link-local IPv6 Address . . . . .:0:0:ffff::1%1
|
35
|
+
fec0:0:0:ffff::2%1
|
36
|
+
fec0:0:0:ffff::3%1
|
37
|
+
NetBIOS over Tcpip. . . . . . . . : Disabled
|
38
|
+
|
39
|
+
Ethernet adapter VMware Network Adapter VMnet8:
|
40
|
+
|
41
|
+
Connection-specific DNS Suffix . :
|
42
|
+
Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet8
|
43
|
+
Physical Address. . . . . . . . . : 00-50-56-CC-1G-58
|
44
|
+
DHCP Enabled. . . . . . . . . . . : Yes
|
45
|
+
Autoconfiguration Enabled . . . . : Yes
|
46
|
+
Link-local IPv6 Address . . . . . : fe80::a871:fd53:1414:ddf8%37(Preferred)
|
47
|
+
IPv4 Address. . . . . . . . . . . : 192.168.159.1(Preferred)
|
48
|
+
Subnet Mask . . . . . . . . . . . : 255.255.255.0
|
49
|
+
Default Gateway . . . . . . . . . :
|
50
|
+
DHCP Server . . . . . . . . . . . : 192.168.159.254
|
51
|
+
DHCPv6 IAID . . . . . . . . . . . : 956332947
|
52
|
+
DHCPv6 Client DUID. . . . . . . . : C6-E4-F7-FD-49-02-EA-68-F8-62-A6-E8-B0-5E
|
53
|
+
|
54
|
+
DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
|
55
|
+
fec0:0:0:ffff::2%1
|
56
|
+
fec0:0:0:ffff::3%1
|
57
|
+
NetBIOS over Tcpip. . . . . . . . : Disabled
|
58
|
+
|
59
|
+
Tunnel adapter isatap.{B6D31E02-C3CF-2D1E-A006-21A63F4641B8}:
|
60
|
+
|
61
|
+
Media State . . . . . . . . . . . : Media disconnected
|
62
|
+
Connection-specific DNS Suffix . :
|
63
|
+
Description . . . . . . . . . . . : Microsoft ISATAP Adapter
|
64
|
+
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
|
65
|
+
DHCP Enabled. . . . . . . . . . . : No
|
66
|
+
Autoconfiguration Enabled . . . . : Yes
|
67
|
+
|
68
|
+
Tunnel adapter isatap.{7F778B96-AC4E-3010-B94C-C43263C1FB7}:
|
69
|
+
|
70
|
+
Media State . . . . . . . . . . . : Media disconnected
|
71
|
+
Connection-specific DNS Suffix . :
|
72
|
+
Description . . . . . . . . . . . : Microsoft ISATAP Adapter #5
|
73
|
+
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
|
74
|
+
DHCP Enabled. . . . . . . . . . . : No
|
75
|
+
Autoconfiguration Enabled . . . . : Yes
|
76
|
+
|
77
|
+
Tunnel adapter isatap.{8AA97F00-6DC4-627B-3BED-C3A469453CDD}:
|
78
|
+
|
79
|
+
Media State . . . . . . . . . . . : Media disconnected
|
80
|
+
Connection-specific DNS Suffix . :
|
81
|
+
Description . . . . . . . . . . . : Microsoft ISATAP Adapter #9
|
82
|
+
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
|
83
|
+
DHCP Enabled. . . . . . . . . . . : No
|
84
|
+
Autoconfiguration Enabled . . . . : Yes
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper.rb'
|
3
|
+
|
4
|
+
shared_examples_for 'MacAddress::parse' do
|
5
|
+
let(:output) do
|
6
|
+
fixture(scenario)
|
7
|
+
end
|
8
|
+
let(:parsed_result) do
|
9
|
+
described_class::parse(output)
|
10
|
+
end
|
11
|
+
subject { parsed_result }
|
12
|
+
|
13
|
+
it { should be_a_kind_of String }
|
14
|
+
it { should match MacAddress::RE }
|
15
|
+
its(:list) { should be_a_kind_of Array }
|
16
|
+
it { should eql expected }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe MacAddress do
|
20
|
+
include Rspec::FixtureLoader
|
21
|
+
|
22
|
+
it { should respond_to :address }
|
23
|
+
|
24
|
+
context '::parse' do
|
25
|
+
context 'noifconfig' do
|
26
|
+
let(:scenario) { 'noifconfig' }
|
27
|
+
let(:expected) { 'd0:4e:f1:68:29:79' }
|
28
|
+
include_examples 'MacAddress::parse'
|
29
|
+
end
|
30
|
+
context 'osx' do
|
31
|
+
let(:scenario) { 'osx' }
|
32
|
+
let(:expected) { 'c8:bc:c8:9b:28:b1' }
|
33
|
+
include_examples 'MacAddress::parse'
|
34
|
+
end
|
35
|
+
context 'windows' do
|
36
|
+
let(:scenario) { 'windows' }
|
37
|
+
let(:expected) { '5C-51-4F-AF-09-9C' }
|
38
|
+
include_examples 'MacAddress::parse'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context '::address' do
|
43
|
+
before(:each) do
|
44
|
+
described_class.instance_variable_set(:@mac_address, nil)
|
45
|
+
described_class.stub(:systemu) { |cmd| [0, fixture('osx'), ''] }
|
46
|
+
end
|
47
|
+
subject { described_class.address }
|
48
|
+
|
49
|
+
it { should match MacAddress::RE }
|
50
|
+
it 'should memoize the result' do
|
51
|
+
described_class.should_receive(:parse).once.and_call_original
|
52
|
+
3.times { described_class.address }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe 'macaddr compatibility' do
|
4
|
+
before(:all) { require 'macaddr' }
|
5
|
+
context '::Mac' do
|
6
|
+
subject { ::Mac }
|
7
|
+
it { should eq ::MacAddress }
|
8
|
+
end
|
9
|
+
context '::MacAddr' do
|
10
|
+
subject { ::MacAddr }
|
11
|
+
it { should eq ::MacAddress }
|
12
|
+
end
|
13
|
+
context '::Macaddr' do
|
14
|
+
subject { ::Macaddr }
|
15
|
+
it { should eq ::MacAddress }
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mac-address
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.6.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ara T. Howard
|
8
|
+
- Ryan Biesemeyer
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.3'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.3'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 2.14.1
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.14.1
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: systemu
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.5.0
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.5.0
|
70
|
+
description: based on @ahoward's macaddr gem
|
71
|
+
email:
|
72
|
+
- ryan@yaauie.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/mac-address.rb
|
83
|
+
- lib/mac-address/version.rb
|
84
|
+
- lib/macaddr.rb
|
85
|
+
- mac-address.gemspec
|
86
|
+
- spec/fixtures/noifconfig
|
87
|
+
- spec/fixtures/osx
|
88
|
+
- spec/fixtures/windows
|
89
|
+
- spec/mac-address_spec.rb
|
90
|
+
- spec/macaddr-compatibility_spec.rb
|
91
|
+
- spec/spec_helper.rb
|
92
|
+
homepage: https://github.com/yaauie/mac-address
|
93
|
+
licenses:
|
94
|
+
- ruby
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.2.2
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: cross platform mac address determination for ruby
|
116
|
+
test_files:
|
117
|
+
- spec/fixtures/noifconfig
|
118
|
+
- spec/fixtures/osx
|
119
|
+
- spec/fixtures/windows
|
120
|
+
- spec/mac-address_spec.rb
|
121
|
+
- spec/macaddr-compatibility_spec.rb
|
122
|
+
- spec/spec_helper.rb
|
123
|
+
has_rdoc:
|