michaeldv/awesome_print — pull request #120 by vStone (2013-05-15 06:41:52+00:00)
Title: Fixes undefined method `[]' for :@attributename:Symbol when using in pup...

...pet (functions)

On my centos machine (ruby 1.8.7 (2011-06-30 patchlevel 352)), the awesome_object method fails using it from within a puppet function.
```
Error: undefined method `[]' for :@content:Symbol at /etc/puppet/environments/production/modules/upstream/infrastructure/manifests/init.pp:10 on node puppetca01.virtual.vstone.org
/usr/lib/ruby/gems/1.8/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:130:in `awesome_object'
/usr/lib/ruby/gems/1.8/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:128:in `map'
/usr/lib/ruby/gems/1.8/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:128:in `awesome_object'
/usr/lib/ruby/gems/1.8/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:65:in `awesome_self'
/usr/lib/ruby/gems/1.8/gems/awesome_print-1.1.0/lib/awesome_print/formatter.rb:28:in `format'
/usr/lib/ruby/gems/1.8/gems/awesome_print-1.1.0/lib/awesome_print/inspector.rb:137:in `unnested'
/usr/lib/ruby/gems/1.8/gems/awesome_print-1.1.0/lib/awesome_print/inspector.rb:104:in `awesome'
/usr/lib/ruby/gems/1.8/gems/awesome_print-1.1.0/lib/awesome_print/core_ext/kernel.rb:10:in `ai'
/usr/lib/ruby/gems/1.8/gems/awesome_print-1.1.0/lib/awesome_print/core_ext/kernel.rb:15:in `ap'

```

It looks like var[1..-1] does not work properly since var is a Symbol. This is due to some monkeypatching done by puppet:
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/monkey_patches.rb#L233

Although this might be a puppet flaw, its an easy enough fix here (as opposed to waiting 3 years with the puppet codebase ;))