[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5-303-gfcfa26a

Matt Robinson matt at puppetlabs.com
Thu Mar 17 10:48:30 UTC 2011


The following commit has been merged in the upstream branch:
commit 24eacb7fe6696a8c049b08ec382c5d1ab114ce67
Author: Nan Liu <nan at puppetlabs.com>
Date:   Tue Feb 1 18:34:23 2011 -0800

    (#5466) Fixed puppet resource bug with trailing ,

diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index e832804..a71675e 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -255,15 +255,26 @@ class Puppet::Resource
 
   # Convert our resource to Puppet code.
   def to_manifest
-    "%s { '%s':\n%s\n}" % [self.type.to_s.downcase, self.title,
-      @parameters.collect { |p, v|
-        if v.is_a? Array
-          "    #{p} => [\'#{v.join("','")}\']"
-        else
-          "    #{p} => \'#{v}\'"
-        end
-      }.join(",\n")
-      ]
+    # Collect list of attributes to align => and move ensure first
+    attr = @parameters.keys
+    attr_max = attr.inject(0) { |max,k| k.to_s.length > max ? k.to_s.length : max }
+
+    attr.sort!
+    if attr.first != :ensure  && attr.include?(:ensure)
+      attr.delete(:ensure)
+      attr.unshift(:ensure)
+    end
+
+    attributes = attr.collect { |k|
+      v = @parameters[k]
+      if v.is_a? Array
+        "  %-#{attr_max}s => %s,\n" % [ k, "[\'#{v.join("', '")}\']" ]
+      else
+        "  %-#{attr_max}s => %s,\n" % [ k, "\'#{v}\'" ]
+      end
+    }
+
+    "%s { '%s':\n%s}" % [self.type.to_s.downcase, self.title, attributes]
   end
 
   def to_ref

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list