That needs some tests added to make sure it doesn't get messed up later. At
least the sorting and trailing "," should be checked.

Regards,
    Daniel
-- 
Puppet Labs Developer –http://puppetlabs.com
Daniel Pittman <[email protected]>
Contact me via gtalk, email, or phone: +1 (877) 575-9775
Sent from a mobile device. Please forgive me if this is briefer than usual.
On Feb 1, 2011 6:55 PM, "Nan Liu" <[email protected]> wrote:
> 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]<puppet-dev%[email protected]>
.
> For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.
>

-- 
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