Remove workarounds that were only needed because ruby's builtin YAML lib is broken.
Signed-off-by: Jesse Wolfe <[email protected]> --- lib/puppet/network/formats.rb | 41 ++++++--------------------------------- spec/unit/network/formats.rb | 42 ----------------------------------------- 2 files changed, 7 insertions(+), 76 deletions(-) diff --git a/lib/puppet/network/formats.rb b/lib/puppet/network/formats.rb index 92f778c..eec632d 100644 --- a/lib/puppet/network/formats.rb +++ b/lib/puppet/network/formats.rb @@ -12,30 +12,17 @@ Puppet::Network::FormatHandler.create(:yaml, :mime => "text/yaml") do end def render(instance) - yaml = instance.to_yaml - - yaml = fixup(yaml) unless yaml.nil? - yaml + instance.to_yaml end # Yaml monkey-patches Array, so this works. def render_multiple(instances) - yaml = instances.to_yaml - - yaml = fixup(yaml) unless yaml.nil? - yaml + instances.to_yaml end - # Everything's supported unless you're on 1.8.1 + # Unlike core's yaml, ZAML should support 1.8.1 just fine def supported?(klass) - RUBY_VERSION != '1.8.1' - 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 + true end end @@ -66,29 +53,15 @@ Puppet::Network::FormatHandler.create(:b64_zlib_yaml, :mime => "text/b64_zlib_ya end def render(instance) - yaml = instance.to_yaml - - yaml = encode(fixup(yaml)) unless yaml.nil? - yaml + encode(instance.to_yaml) end def render_multiple(instances) - yaml = instances.to_yaml - - yaml = encode(fixup(yaml)) unless yaml.nil? - yaml + encode(instances.to_yaml) end - # Because of yaml issue in ruby 1.8.1... def supported?(klass) - RUBY_VERSION != '1.8.1' and use_zlib? - 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 + true end def encode(text) diff --git a/spec/unit/network/formats.rb b/spec/unit/network/formats.rb index 78b35fd..fd78ebf 100755 --- a/spec/unit/network/formats.rb +++ b/spec/unit/network/formats.rb @@ -50,29 +50,12 @@ describe "Puppet Network Format" do @yaml.render(instance).should == "foo" end - it "should fixup generated yaml on render" do - instance = mock 'instance', :to_yaml => "foo" - - @yaml.expects(:fixup).with("foo").returns "bar" - - @yaml.render(instance).should == "bar" - end - it "should render multiple instances by calling 'to_yaml' on the array" do instances = [mock('instance')] instances.expects(:to_yaml).returns "foo" @yaml.render_multiple(instances).should == "foo" end - it "should fixup generated yaml on render" do - instances = [mock('instance')] - instances.stubs(:to_yaml).returns "foo" - - @yaml.expects(:fixup).with("foo").returns "bar" - - @yaml.render(instances).should == "bar" - end - it "should intern by calling 'YAML.load'" do text = "foo" YAML.expects(:load).with("foo").returns "bar" @@ -84,10 +67,6 @@ describe "Puppet Network Format" do YAML.expects(:load).with("foo").returns "bar" @yaml.intern_multiple(String, text).should == "bar" end - - it "should fixup incorrect yaml to correct" do - @yaml.fixup("&id004 !ruby/object:Puppet::Relationship ?").should == "? &id004 !ruby/object:Puppet::Relationship" - end end describe "base64 compressed yaml" do @@ -108,14 +87,6 @@ describe "Puppet Network Format" do @yaml.render(instance) end - it "should fixup generated yaml on render" do - instance = mock 'instance', :to_yaml => "foo" - - @yaml.expects(:fixup).with("foo").returns "bar" - - @yaml.render(instance) - end - it "should encode generated yaml on render" do instance = mock 'instance', :to_yaml => "foo" @@ -130,15 +101,6 @@ describe "Puppet Network Format" do @yaml.render_multiple(instances) end - it "should fixup generated yaml on render" do - instances = [mock('instance')] - instances.stubs(:to_yaml).returns "foo" - - @yaml.expects(:fixup).with("foo").returns "bar" - - @yaml.render(instances) - end - it "should encode generated yaml on render" do instances = [mock('instance')] instances.stubs(:to_yaml).returns "foo" @@ -173,10 +135,6 @@ describe "Puppet Network Format" do @yaml.encode("foo").should == "baz" end - it "should fixup incorrect yaml to correct" do - @yaml.fixup("&id004 !ruby/object:Puppet::Relationship ?").should == "? &id004 !ruby/object:Puppet::Relationship" - end - describe "when zlib is disabled" do before do Puppet[:zlib] = false -- 1.7.0.4 -- 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.
