]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/lib/facter/util/puppet_settings.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / lib / facter / util / puppet_settings.rb
1 module Facter
2   module Util
3     module PuppetSettings
4       # This method is intended to provide a convenient way to evaluate a
5       # Facter code block only if Puppet is loaded.  This is to account for the
6       # situation where the fact happens to be in the load path, but Puppet is
7       # not loaded for whatever reason.  Perhaps the user is simply running
8       # facter without the --puppet flag and they happen to be working in a lib
9       # directory of a module.
10       def self.with_puppet
11         begin
12           Module.const_get("Puppet")
13         rescue NameError
14           nil
15         else
16           yield
17         end
18       end
19     end
20   end
21 end