opscode/chef-dk — pull request #118 by adamhjk (2014-07-29 00:07:09+00:00)
Title: Easy generators

Depends on PR #117

Adds ChefDK::Generator.add_attr_to_context, which handles adding
instance variables (and optionally their values) to the
ChefDK::Generator::Context and ChefDK::Generator::TemplateHelper. This
makes writing new generators much easier, because you don't have to be
aware of how/when/where the context variables are set up - you can just
focus in on the generator you are adding.

Additionally, any option added to a generator is dynamically added to
the Context and TemplateHelper if it has a value, making the barrier
even smaller. One thing to note is that generator options really should
either be true/false or have default values that make sense for the
generator, or you're liable to get errors. (This is appropriate, I
think)

While cleaning up the existing context accessors, I noticed that at
least one of them (license_description) existed in a template, but was
never set anywhere. I implemented the method within the TemplateHelper,
so that you can dynamically ask for the correct license description to
embedd in a file, including what to comment the license with.