lib/puppet/network/formats.rb in puppet-3.1.0.rc1 vs lib/puppet/network/formats.rb in puppet-3.1.0.rc2
- old
+ new
@@ -146,10 +146,10 @@
return datum if datum.is_a? Numeric
# Simple hash to table
if datum.is_a? Hash and datum.keys.all? { |x| x.is_a? String or x.is_a? Numeric }
output = ''
- column_a = datum.map do |k,v| k.to_s.length end.max + 2
+ column_a = datum.empty? ? 2 : datum.map{ |k,v| k.to_s.length }.max + 2
column_b = 79 - column_a
datum.sort_by { |k,v| k.to_s } .each do |key, value|
output << key.to_s.ljust(column_a)
output << json.render(value).
chomp.gsub(/\n */) { |x| x + (' ' * column_a) }