aaalex-ruby-ifconfig 1.2.2 → 1.2.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.
data/Changelog CHANGED
@@ -1,9 +1,12 @@
1
+ Version 1.2.3
2
+ - added addrs_with_mask method in NetworkAdapter (Alex Peuchert)
3
+
1
4
  Version 1.2.2
2
- - increase of build number for GitHub to create GEM
5
+ - increase of build number for GitHub to create GEM (Alex Peuchert)
3
6
 
4
7
  Version 1.2.1
5
8
  - import into GitHub (Alex Peuchert)
6
- - added .gemspec for automatic GEM creation
9
+ - added .gemspec for automatic GEM creation (Alex Peuchert)
7
10
 
8
11
  Version 1.2
9
12
  - All IP addresses (v4 and v6) are ipaddr objects now.
@@ -14,13 +14,13 @@
14
14
  #
15
15
  # cfg = IfconfigWrapper.new.parse # parses the output of ifconfig
16
16
  #
17
- # cfg.interfaces() # returns list of interfaces
17
+ # cfg.interfaces # returns list of interfaces
18
18
  #
19
- # cfg[eth0].addresses('inet') # returns ipv4 address of eth0
19
+ # cfg['eth0'].addresses('inet') # returns ipv4 address of eth0
20
20
  #
21
- # cfg.addrresses('inet') # returns list of all ipv4 addresses
21
+ # cfg.addresses('inet') # returns list of all ipv4 addresses
22
22
  #
23
- # cfg[eth0].status # returns true if interface is up
23
+ # cfg['eth0'].status # returns true if interface is up
24
24
  #
25
25
  # cfg.each { block } # run a block on each interface object
26
26
 
@@ -76,6 +76,17 @@ class NetworkAdapter
76
76
  return types
77
77
  end
78
78
 
79
+ # returns array of arrays
80
+ # [ [address , mask ] ]
81
+ #
82
+ def addrs_with_mask
83
+ addrs = []
84
+ @networks.each_value { |network|
85
+ addrs.push([network.addr.to_s,network.mask])
86
+ }
87
+ return addrs
88
+ end
89
+
79
90
  def has_addr?(addr)
80
91
  return self.addresses.include?(addr)
81
92
  end
@@ -13,7 +13,7 @@ class Ifconfig
13
13
  def initialize(input=nil,verbose=nil)
14
14
  if input.nil?
15
15
  cmd = IO.popen('which ifconfig'){ |f| f.readlines[0] }
16
- exit unless !cmd.nil?
16
+ raise RuntimeError.new("ifconfig not in PATH") unless !cmd.nil?
17
17
  @ifconfig = IO.popen("/sbin/ifconfig -a"){ |f| f.readlines.join }
18
18
  else
19
19
  @ifconfig = input
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aaalex-ruby-ifconfig
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Hobe