If we don't do this, there's a chance we'll get hit by the ruby yaml bug again.
Signed-off-by: Luke Kanies <[email protected]> --- lib/puppet/simple_graph.rb | 12 +++++++++++- spec/unit/simple_graph.rb | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletions(-) diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb index 9709832..dacea1a 100644 --- a/lib/puppet/simple_graph.rb +++ b/lib/puppet/simple_graph.rb @@ -360,7 +360,17 @@ class Puppet::SimpleGraph end def to_yaml_properties - instance_variables + 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. diff --git a/spec/unit/simple_graph.rb b/spec/unit/simple_graph.rb index 2e7bad6..739ce4e 100755 --- a/spec/unit/simple_graph.rb +++ b/spec/unit/simple_graph.rb @@ -31,6 +31,13 @@ describe Puppet::SimpleGraph do proc { @graph.to_dot_graph }.should_not raise_error end + it "should always put its edges first when printing yaml" do + @graph = Puppet::SimpleGraph.new + @graph.add_edge(:one, :two) + p @graph.to_yaml_properties + @graph.to_yaml_properties[0].should == "@edges" + end + describe "when managing vertices" do before do @graph = Puppet::SimpleGraph.new -- 1.6.1 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---
