diff options
author | James Turnbull <james@lovedthanlost.net> | 2009-04-27 00:00:56 +1000 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-04-27 00:00:56 +1000 |
commit | 636a91de9304caf32d179b7de5ca6dca296a7f2c (patch) | |
tree | e2db552b82a7d6d563443538c492acde2a690709 /lib | |
parent | 9df0583dcb6f8ea6d815bceb3da33d2cb7449f08 (diff) | |
download | facter-636a91de9304caf32d179b7de5ca6dca296a7f2c.tar.gz facter-636a91de9304caf32d179b7de5ca6dca296a7f2c.tar.xz facter-636a91de9304caf32d179b7de5ca6dca296a7f2c.zip |
Partial fix for #2191 - Facter compatibility for Ruby 1.9
Diffstat (limited to 'lib')
-rw-r--r-- | lib/facter/macaddress.rb | 12 | ||||
-rw-r--r-- | lib/facter/util/ip.rb | 2 | ||||
-rw-r--r-- | lib/facter/virtual.rb | 8 |
3 files changed, 11 insertions, 11 deletions
diff --git a/lib/facter/macaddress.rb b/lib/facter/macaddress.rb index e048209..94d00f4 100644 --- a/lib/facter/macaddress.rb +++ b/lib/facter/macaddress.rb @@ -3,7 +3,7 @@ Facter.add(:macaddress) do setcode do ether = [] output = %x{/sbin/ifconfig -a} - output.each do |s| + output.each_line do |s| ether.push($1) if s =~ /(?:ether|HWaddr) (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ end ether[0] @@ -15,7 +15,7 @@ Facter.add(:macaddress) do setcode do ether = [] output = %x{/sbin/ifconfig} - output.each do |s| + output.each_line do |s| if s =~ /(?:ether|lladdr)\s+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ ether.push($1) end @@ -30,7 +30,7 @@ Facter.add(:macaddress) do ether = nil output = %x{/sbin/ifconfig} - output.split(/^\S/).each do |str| + output.split(/^\S/).each_line do |str| if str =~ /10baseT/ # we're wired str =~ /ether (\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/ ether = $1 @@ -47,12 +47,12 @@ Facter.add(:macaddress) do ether = [] ip = nil output = %x{/usr/sbin/ifconfig -a} - output.each do |str| + output.each_line do |str| if str =~ /([a-z]+\d+): flags=/ devname = $1 unless devname =~ /lo0/ output2 = %x{/usr/bin/entstat #{devname}} - output2.each do |str2| + output2.each_line do |str2| if str2 =~ /^Hardware Address: (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/ ether.push($1) end @@ -69,7 +69,7 @@ Facter.add(:macaddress) do setcode do ether = [] output = %x{ipconfig /all} - output.split(/\r\n/).each do |str| + output.split(/\r\n/).each_line do |str| if str =~ /.*Physical Address.*: (\w{1,2}-\w{1,2}-\w{1,2}-\w{1,2}-\w{1,2}-\w{1,2})/ ether.push($1.gsub(/-/, ":")) end diff --git a/lib/facter/util/ip.rb b/lib/facter/util/ip.rb index 374d9f3..a2125ea 100644 --- a/lib/facter/util/ip.rb +++ b/lib/facter/util/ip.rb @@ -120,7 +120,7 @@ module Facter::Util::IP output_int = get_single_interface_output(interface) if interface != /^lo[0:]?\d?/ - output_int.each do |s| + output_int.each_line do |s| if s =~ regex value = $1 if label == 'netmask' && convert_from_hex?(kernel) diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb index 97d7cba..3ad6f8a 100644 --- a/lib/facter/virtual.rb +++ b/lib/facter/virtual.rb @@ -32,7 +32,7 @@ Facter.add("virtual") do if result == "physical" output = Facter::Util::Resolution.exec('lspci') if not output.nil? - output.each do |p| + output.each_line do |p| # --- look for the vmware video card to determine if it is virtual => vmware. # --- 00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter result = "vmware" if p =~ /VM[wW]are/ @@ -40,13 +40,13 @@ Facter.add("virtual") do else output = Facter::Util::Resolution.exec('dmidecode') if not output.nil? - output.each do |pd| + output.each_line do |pd| result = "vmware" if pd =~ /VMware|Parallels/ end else output = Facter::Util::Resolution.exec('prtdiag') if not output.nil? - output.each do |pd| + output.each_line do |pd| result = "vmware" if pd =~ /VMware|Parallels/ end end @@ -61,7 +61,7 @@ Facter.add("virtual") do output = Facter::Util::Resolution.exec('mount') if not output.nil? - output.each do |p| + output.each_line do |p| result = "vserver" if p =~ /\/dev\/hdv1/ end end |