puppetlabs/puppet — pull request #702 by jeffweiss (2012-04-23 22:09:09+00:00)
Title: (#13948) $libdir not in $LOAD_PATH

Change `:call_on_define` to `:call_hook` with values of
`:on_define_and_write`, `:on_initialize_and_write`, and `:on_write_only`.
Make hook for `$libdir` `:on_initialize_and_write`.
Make hook for `$factpath` `:on_initialize_and_write`.
Make hook for `$storeconfigs` `:on_initialize_and_write`.
Change `Puppet::Util::Settings` to call hooks on settings designated as
`:on_initialize_and_write` immediately after initialing default
application values.
Add `has_hook? convenience method to
`Puppet::Util::Settings::StringSetting`.
Deprecate `Puppet::Util::Settings::StringSetting#call_on_define`.
Add convenience methods to `Puppet::Util::Settings::StringSetting` for
checking if hook should be called at definition or at initialization.
Add tests for above changes.

Prior to this commit, the hooks for `$libdir` and `$factpath` were not
getting called unless explicitly overridden in the code. This meant that
the default `$libdir` was not part of `$LOAD_PATH` and the default `$factpath`
was not searched for facts. This commit fixes those problems by
enabling settings to declare when the hook should be called. A hook can
be only only when a value is overwritten (`:on_write_only`), which is the
default. A hook can be called with the default value when when the
setting is defined (as soon as `Puppet::Util::Settings.define_settings` is
called) (`:on_define_and_write`), in addition to any time the value is
overwritten. A hook can be called with the default value during
application initialization (`:on_initialize_and_write`), in addition to
any time the value is overwritten.