diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/util/trocla_helper.rb | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/puppet/util/trocla_helper.rb b/lib/puppet/util/trocla_helper.rb index 94670ae..ce583f5 100644 --- a/lib/puppet/util/trocla_helper.rb +++ b/lib/puppet/util/trocla_helper.rb @@ -22,13 +22,22 @@ module Puppet::Util::TroclaHelper options = YAML.load(options) end - configfile = File.join(File.dirname(Puppet.settings[:config]), "troclarc.yaml") + has_options ? store.send(trocla_func, key, format, options) : store.send(trocla_func, key, format) + end + module_function :trocla + + private - raise(Puppet::ParseError, "Trocla config file #{configfile} is not readable") unless File.exist?(configfile) + def store + @store ||= begin + require 'trocla' + configfile = File.join(File.dirname(Puppet.settings[:config]), "troclarc.yaml") - require 'trocla' + raise(Puppet::ParseError, "Trocla config file #{configfile} is not readable") unless File.exist?(configfile) - has_options ? Trocla.new(configfile).send(trocla_func, key, format, options) : Trocla.new(configfile).send(trocla_func, key, format) + Trocla.new(configfile) + end end - module_function :trocla + module_function :store + end |