Cache the result of build_catalog

This commit is contained in:
Ilya Margolin 2012-07-31 16:00:23 +02:00
parent eed11c7dc0
commit 4ae3e45af7
1 changed files with 10 additions and 1 deletions

View File

@ -1,6 +1,10 @@
module RSpec::Puppet
module Support
def build_catalog nodename, facts_val
@@cache = {}
protected
def build_catalog_without_cache nodename, facts_val
node_obj = Puppet::Node.new(nodename)
node_obj.merge(facts_val)
@ -13,6 +17,11 @@ module RSpec::Puppet
end
end
public
def build_catalog *args
@@cache[args] ||= self.build_catalog_without_cache(*args)
end
def munge_facts(facts)
output = {}
facts.keys.each { |key| output[key.to_s] = facts[key] }