Includes following changes:
Fixed puppet resource so it have trailing , for last attribute
Added logic to align =>
Sort attribute by name
Use 2 spaces instead of 4
---
lib/puppet/resource.rb | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index e832804..0419cdd 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -255,14 +255,19 @@ class Puppet::Resource
# Convert our resource to Puppet code.
def to_manifest
+ # Collect list of attributes to align =>
+ attributes = @parameters.collect { |attr, val| attr }
+ attr_max = attributes.max{ |a, b| a.to_s.length <=> b.to_s.length
}.to_s.length
+
"%s { '%s':\n%s\n}" % [self.type.to_s.downcase, self.title,
@parameters.collect { |p, v|
+ space = " " * (attr_max-p.to_s.length)
if v.is_a? Array
- " #{p} => [\'#{v.join("','")}\']"
+ " #{p}#{space} => [\'#{v.join("','")}\']"
else
- " #{p} => \'#{v}\'"
+ " #{p}#{space} => \'#{v}\'"
end
- }.join(",\n")
+ }.sort.join(",\n") + ","
]
end
--
1.7.3.5
--
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.