diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/network/formats.rb | 17 | ||||
| -rw-r--r-- | lib/puppet/resource/catalog.rb | 14 | ||||
| -rw-r--r-- | lib/puppet/simple_graph.rb | 14 |
3 files changed, 15 insertions, 30 deletions
diff --git a/lib/puppet/network/formats.rb b/lib/puppet/network/formats.rb index 85e8ce6f8..51354b03d 100644 --- a/lib/puppet/network/formats.rb +++ b/lib/puppet/network/formats.rb @@ -12,18 +12,31 @@ Puppet::Network::FormatHandler.create(:yaml, :mime => "text/yaml") do end def render(instance) - instance.to_yaml + yaml = instance.to_yaml + + yaml = fixup(yaml) unless yaml.nil? + yaml end # Yaml monkey-patches Array, so this works. def render_multiple(instances) - instances.to_yaml + yaml = instances.to_yaml + + yaml = fixup(yaml) unless yaml.nil? + yaml end # Everything's supported def supported?(klass) true end + + # fixup invalid yaml as per: + # http://redmine.ruby-lang.org/issues/show/1331 + def fixup(yaml) + yaml.gsub!(/((?:&id\d+\s+)?!ruby\/object:.*?)\s*\?/) { "? #{$1}" } + yaml + end end diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb index 32fbc38d6..4f60f6e56 100644 --- a/lib/puppet/resource/catalog.rb +++ b/lib/puppet/resource/catalog.rb @@ -417,20 +417,6 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph super end - def to_yaml_properties - result = instance_variables - - # There's a ruby bug that hits us without this: - # http://rubyforge.org/tracker/?group_id=426&atid=1698&func=detail&aid=8886 - # We need our resources to show up in as values in a hash - # before they show up as keys, because otherwise - # the loading fails. - result.delete "@resource_table" - result.unshift "@resource_table" - - result - end - private def cleanup diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb index c5b0f4928..5d6f72943 100644 --- a/lib/puppet/simple_graph.rb +++ b/lib/puppet/simple_graph.rb @@ -360,20 +360,6 @@ class Puppet::SimpleGraph end end - def to_yaml_properties - result = instance_variables - - # There's a ruby bug that hits us without this: - # http://rubyforge.org/tracker/?group_id=426&atid=1698&func=detail&aid=8886 - # We need our resources to show up in as values in a hash - # before they show up as keys, because otherwise - # the loading fails. - result.delete "@edges" - result.unshift "@edges" - - result - end - # Just walk the tree and pass each edge. def walk(source, direction) # Use an iterative, breadth-first traversal of the graph. One could do |
