Keep the order of iface attributes the same accross rubies
1.8 doesn't maintain insertion order for Hash keys like 1.9 does so we end up with ~random order for the display with the previous technique. Switch to an Array instead of a Hash so it's always the same.unstable
parent
ed3700b5da
commit
db88145294
|
@ -47,19 +47,19 @@ class Interface
|
||||||
mac_addr.each_byte { |o| macocts << o }
|
mac_addr.each_byte { |o| macocts << o }
|
||||||
macocts += [0] * (6 - macocts.size) if macocts.size < 6
|
macocts += [0] * (6 - macocts.size) if macocts.size < 6
|
||||||
|
|
||||||
info = {
|
info = [
|
||||||
"Name" => mac_name,
|
["Name" , mac_name ],
|
||||||
"Hardware MAC" => sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
|
["Hardware MAC" , sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
|
||||||
macocts[0], macocts[1], macocts[2],
|
macocts[0], macocts[1], macocts[2],
|
||||||
macocts[3], macocts[4], macocts[5]),
|
macocts[3], macocts[4], macocts[5])],
|
||||||
"MTU" => mtu,
|
["MTU" , mtu ],
|
||||||
"Flags" => flags,
|
["Flags" , flags ],
|
||||||
"IPv4 Address" => ((ip and ip != "0.0.0.0") ? ip : nil),
|
["IPv4 Address" , ((ip and ip != "0.0.0.0") ? ip : nil) ],
|
||||||
"IPv4 Netmask" => netmask,
|
["IPv4 Netmask" , netmask ],
|
||||||
"IPv6 Address" => ((ip6 and ip6 != "::") ? ip6 : nil),
|
["IPv6 Address" , ((ip6 and ip6 != "::") ? ip6 : nil) ],
|
||||||
"IPv6 Netmask" => netmask6,
|
["IPv6 Netmask" , ((netmask6 and netmask6 != "::") ? netmask6 : nil) ],
|
||||||
}
|
]
|
||||||
pad = info.keys.max_by{|k|k.length}.length
|
pad = info.map{|i| i[0] }.max_by{|k|k.length}.length
|
||||||
|
|
||||||
ret = sprintf(
|
ret = sprintf(
|
||||||
"Interface %2d\n" +
|
"Interface %2d\n" +
|
||||||
|
|
Loading…
Reference in New Issue