21760/22005 update preflight to delete old lib dir

In order to install in the top-level site_ruby directory, we need to clean out
any installs in the old site_ruby/1.8 location. We're doing this by setting a
variable in the package:apple task. If it's set, we remove all files there as
well as files in the new location.

While I'm here:
* update erb to strip leading and trailing spaces
* validate critical variables so a script is never generated with dangerous paths
* only target top-level files/dirs in lib, since we're doing rm -RF anyway
(#22206) Add option to disable default schedules
Use Dir.glob(), don't require rubygems or rake, use Dir.chdir as a block
use instance_variable_get instead of eval
(Maint) Mark AdditionalResourceGenerator as private
(#22229) Ensure generated resources contained

The generated resources were left out in the cold with respect to
containers: they had none at all. This changes that to make sure that
the generated resources (via #generate and #eval_generate) have the same
container as the resource that generated them.
(#22288) Add methods to access all parameters of a type

Without this commit there is no simple way to access all parameters of
a type. There is also no simple way to iterate over them. There is
currently a method that will return a list of all parameters that have a
value assigned, however, they are duplicates of the actual parameters. This
means there is no clear way to perform an operation on all parameters at once
that will have lasting side effects.

This commit adds functionality needed by the solution to ticket
(#22288).This functionality this commit adds includes a method to collect all
parameters that currently have a value assigned. This commit also adds a method
to iterate of the collected parameters that currently have a value. The intention
of these methods is to allow things like post catalog compilation hooks to be possible.
(#22229) Provide way of getting the container

The catalog tracks the relationship between the container and the
contained resource but did not provide any clear way to query for the
containment information. This adds a new method #container_of(resource)
that will return the container of the given resource, when one exists.
This removes some duplication around understanding what the container
is.
(21868) Move puppet libary target to /Library/Ruby/Site

We currently drop the puppet library files in /usr/lib/ruby/site_ruby/1.8 on
OSX, which is a symlink to /Library/Ruby/Site/1.8. As of OSX 10.9 Mavericks,
this will no longer work because it will be ruby 2.0.0. There are hard ways
and easy ways to solve this problem. A hard way would be to somehow
introspect the target host at install time, and then dynamically copy the
payload into the correct ruby version specific path. Another hard way would
be to create different OSX packages for different versions of OSX. Or, we
could pick the easy way, which is to just install into /Library/Ruby/Site
(the equivalent of /usr/lib/ruby/site_ruby). Since puppet will work on all
rubies shipped with supported versions of OSX, this will "just work".

Signed-off-by: Moses Mendoza <moses@puppetlabs.com>
(#22319) Correct Puppet::Setting's use of WatchedFile

WatchedFile was introduced after 3.2.0 as a new method of checking for
changes to file.  Puppet::Settings was calling a non-existent method on
the new WatchedFile, and would cause a daemonized Puppet to abort if one
of its watched configuration files was changed.

This is a minor change to call #to_str instead.
Merge pull request #1855 from zaphod42/issue/master/22229-ensure-generated-resources-contained

(#22229) Ensure generated resources contained
Merge pull request #1857 from jpartlow/issue/stable/22319-puppet-settings-misuses-watchedfile

(#22319) Correct Puppet::Setting's use of WatchedFile
Merge branch 'master' into stable to prepare for 3.3.0.
Merge pull request #1856 from MosesMendoza/ticket/master/21868_fix_apple_target

(21868) Move puppet libary target to /Library/Ruby/Site
Merge pull request #1830 from ccaviness/22005-install-to-top-level-site_ruby

21760/22005 update preflight to delete old lib dir
(#22288) Add post_compile_hook to Puppet::Parameter

Without this commit there is no message sent to parameters (and
subclasses thereof) to indicate the catalog has completed compilation.
This is an issue for any parameter that is not based on
`Puppet::Type::RelationshipMetaparam` and needs to do something on
completion of catalog compilation. An example for such application would
be verifying some other resource made it into the catalog so that a
value may be used fro it for the current type.

This commit add an enhancement to the `Puppet::Type#finish` method. This
method will now list through all parameters, including
`Puppet::Type::RelationshipMetaparam` parameters, and call the
`post_compile_hook` method if implemented. This commit also adds an
abstract method comment to `Puppet::Parameter`.
(#22288) Add tests for new methods in `Puppet::Type`

Without this commit there is no way to test the functionality
added to access all parameters in `Puppet::Type`. The functionality
being tested consists of two new methods to access all parameters that
have values set for an instance of `Puppet::Type`.

This commit adds three tests to the 'spec/unit/type_spec.rb' to test the
new behavior.
(#22288) Add test coverage for `post_compile_hook`

Without this commit there is no way to test the functionality surrounding
the `post_compile_hook' for parameters. The functionality mentioned allows a
`post_compile_hook` method to be implemented by any parameter. This hook is
called on the parameters from the `Puppet::Type#finish` method.

This commit adds a new test to 'spec/unit/type_spec.rb' in order to validate
the new behavior that has been added.
(22329) Only delete puppet files in the preflight

Previously, the OSX preflight removed the contents of the 'hiera' directory
which also happens to be where the puppet.pkg places the contents of
hiera_puppet. The fix is pretty easy - from the hiera dir, only remove the
files that exist in the 'puppet' project, no others, e.g. not those from the
hiera.pkg. This commit accomplishes this by only deleting files from 'hiera',
not the directories. It's a bit crufty, but its better than clobbering the
wrong files. With the puppet directory, we can still just remove it. This
commit also fixes some obvious oddities with the rm calls. Previously we just
called rm -Rf indiscriminately. This PR ensures we're calling rm -f on files
and rm -Rf on directories.

Signed-off-by: Moses Mendoza <moses@puppetlabs.com>
Merge pull request #1858 from MosesMendoza/ticket/master/22329_fix_osx_preflight

(22329) Only delete puppet files in the preflight