lib/puppet/network/formats.rb in puppet-3.2.4 vs lib/puppet/network/formats.rb in puppet-3.3.0.rc2

- old
+ new

@@ -1,16 +1,14 @@ require 'puppet/network/format_handler' Puppet::Network::FormatHandler.create_serialized_formats(:yaml) do - # Yaml doesn't need the class name; it's serialized. def intern(klass, text) data = YAML.load(text, :safe => true, :deserialize_symbols => true) return data if data.is_a?(klass) klass.from_pson(data) end - # Yaml doesn't need the class name; it's serialized. def intern_multiple(klass, text) YAML.load(text, :safe => true, :deserialize_symbols => true).collect do |data| if data.is_a?(klass) data else @@ -26,11 +24,10 @@ # Yaml monkey-patches Array, so this works. def render_multiple(instances) instances.to_yaml end - # Unlike core's yaml, ZAML should support 1.8.1 just fine def supported?(klass) true end end @@ -157,14 +154,23 @@ # 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.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) } + output << "\n" + end + return output + end + + # Print one item per line for arrays + if datum.is_a? Array + output = '' + datum.each do |item| + output << item.to_s output << "\n" end return output end