macaddr 0.0.2 → 1.0.0

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.
Files changed (5) hide show
  1. data/README +10 -0
  2. data/gemspec.rb +0 -1
  3. data/install.rb +0 -0
  4. data/lib/macaddr.rb +38 -2
  5. metadata +40 -33
data/README CHANGED
@@ -15,6 +15,16 @@ INSTALL
15
15
 
16
16
  gem install macaddr
17
17
 
18
+ HISTORY
19
+
20
+ 1.0.0:
21
+
22
+ - rdoc added
23
+
24
+ - eric hodel kicks ass. to find why, see
25
+
26
+ http://drawohara.com/post/44678286/eric-hodel-kicks-ass
27
+
18
28
  SYNOPSIS
19
29
 
20
30
  require 'macaddr'
data/gemspec.rb CHANGED
@@ -16,7 +16,6 @@ Gem::Specification::new do |spec|
16
16
  spec.require_path = "lib"
17
17
  spec.autorequire = lib
18
18
 
19
- spec.has_rdoc = File::exist? "doc"
20
19
  spec.test_suite_file = "test/#{ lib }.rb" if File::directory? "test"
21
20
  #spec.add_dependency 'lib', '>= version'
22
21
 
data/install.rb CHANGED
File without changes
data/lib/macaddr.rb CHANGED
@@ -1,6 +1,38 @@
1
+ ##
2
+ # Cross platform MAC address determination. Works for:
3
+ # * /sbin/ifconfig
4
+ # * /bin/ifconfig
5
+ # * ifconfig
6
+ # * ipconfig /all
7
+ #
8
+ # To return the first MAC address on the system:
9
+ #
10
+ # Mac.address
11
+ #
12
+ # To return an array of all MAC addresses:
13
+ #
14
+ # Mac.address.list
15
+
1
16
  module Mac
17
+ VERSION = '1.0.0'
18
+
19
+ def Mac.version() ::Mac::VERSION end
20
+
2
21
  class << self
22
+
23
+ ##
24
+ # Accessor for the system's first MAC address, requires a call to #address
25
+ # first
26
+
3
27
  attr_accessor "mac_address"
28
+
29
+ ##
30
+ # Discovers and returns the system's MAC addresses. Returns the first
31
+ # MAC address, and includes an accessor #list for the remaining addresses:
32
+ #
33
+ # Mac.addr # => first address
34
+ # Mac.addr.list # => all addresses
35
+
4
36
  def address
5
37
  return @mac_address if defined? @mac_address and @mac_address
6
38
  re = %r/[^:\-](?:[0-9A-F][0-9A-F][:\-]){5}[0-9A-F][0-9A-F][^:\-]/io
@@ -14,20 +46,24 @@ module Mac
14
46
  next unless stdout and stdout.size > 0
15
47
  lines = stdout and break
16
48
  end
17
- raise "all of #{ cmds.join ' ' } failed" unless lines
49
+ raise "all of #{ cmds.join ' ' } failed" unless lines
18
50
 
19
51
  candidates = lines.select{|line| line =~ re}
20
52
  raise 'no mac address candidates' unless candidates.first
21
53
  candidates.map!{|c| c[re].strip}
22
54
 
23
55
  maddr = candidates.first
24
- raise 'no mac address found' unless maddr
56
+ raise 'no mac address found' unless maddr
25
57
 
26
58
  maddr.strip!
27
59
  maddr.instance_eval{ @list = candidates; def list() @list end }
28
60
 
29
61
  @mac_address = maddr
30
62
  end
63
+
64
+ ##
65
+ # Shorter alias for #address
66
+
31
67
  alias_method "addr", "address"
32
68
  end
33
69
  end
metadata CHANGED
@@ -1,50 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
3
- specification_version: 1
4
2
  name: macaddr
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.0.2
7
- date: 2007-09-08 00:00:00 -06:00
8
- summary: macaddr
9
- require_paths:
10
- - lib
11
- email: ara.t.howard@gmail.com
12
- homepage: http://codeforpeople.com/lib/ruby/macaddr/
13
- rubyforge_project:
14
- description:
15
- autorequire: macaddr
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: false
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 1.0.0
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Ara T. Howard
8
+ autorequire: macaddr
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-04 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: ara.t.howard@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
31
24
  files:
32
25
  - gemspec.rb
33
26
  - install.rb
34
27
  - lib
35
28
  - lib/macaddr.rb
36
29
  - README
37
- test_files: []
38
-
30
+ has_rdoc: false
31
+ homepage: http://codeforpeople.com/lib/ruby/macaddr/
32
+ post_install_message:
39
33
  rdoc_options: []
40
34
 
41
- extra_rdoc_files: []
42
-
43
- executables: []
44
-
45
- extensions: []
46
-
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: "0"
42
+ version:
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
47
49
  requirements: []
48
50
 
49
- dependencies: []
51
+ rubyforge_project:
52
+ rubygems_version: 1.2.0
53
+ signing_key:
54
+ specification_version: 2
55
+ summary: macaddr
56
+ test_files: []
50
57