This fixes a ruby bug 
(http://rubyforge.org/tracker/?group_id=426&atid=1698&func=detail&aid=8886)
that otherwise results in yaml producing text it can't read
back in.

Signed-off-by: Luke Kanies <[email protected]>
---
 lib/puppet/resource/catalog.rb |   14 ++++++++++++++
 spec/unit/resource/catalog.rb  |    4 ++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb
index 88aa951..cb0ce03 100644
--- a/lib/puppet/resource/catalog.rb
+++ b/lib/puppet/resource/catalog.rb
@@ -416,6 +416,20 @@ 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/spec/unit/resource/catalog.rb b/spec/unit/resource/catalog.rb
index 6a5922e..d51f8fb 100755
--- a/spec/unit/resource/catalog.rb
+++ b/spec/unit/resource/catalog.rb
@@ -801,6 +801,10 @@ describe Puppet::Resource::Catalog, "when compiling" do
         it "should be able to be dumped to yaml" do
             YAML.dump(@catalog).should be_instance_of(String)
         end
+
+        it "should always have its resource table first in its yaml property 
list" do
+            @catalog.to_yaml_properties[0].should == "@resource_table"
+        end
     end
 
     describe "when converting from yaml" do
-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to