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.
We will change them as soon as the rest of the pending workflow RFC gets
merged/we have time.


On Mon, Jul 28, 2014 at 5:30 PM, Claire McQuin <notifications@github.com>
wrote:

> In
> lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/README.md:
>
> > +    current_dir = File.dirname(__FILE__)
> > +    cookbook_path ["#{current_dir}/../cookbooks"]
> > +
> > +Which will set `current_dir` to the location of the knife.rb file itself (e.g. `~/chef-repo/.chef/knife.rb`).
> > +
> > +Configure knife to use your preferred copyright holder, email contact and license. Add the following lines to `.chef/knife.rb`.
> > +
> > +    cookbook_copyright "Example, Com."
> > +    cookbook_email     "cookbooks@example.com"
> > +    cookbook_license   "apachev2"
> > +
> > +Supported values for `cookbook_license` are "apachev2", "mit","gplv2","gplv3",  or "none". These settings are used to prefill comments in the default recipe, and the corresponding values in the metadata.rb. You are free to change the the comments in those files.
> > +
> > +Create new cookbooks in this directory with Knife.
> > +
> > +    knife cookbook create COOKBOOK
>
> Question: (why) are we not encouraging chef generate cookbook NAME?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/opscode/chef-dk/pull/118/files#r15500302>.
>