summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-11-12 11:00:54 -0600
committerLuke Kanies <luke@madstop.com>2007-11-12 11:00:54 -0600
commitdd7caa76e160ed51c8b0e123c18f7526b575bfec (patch)
treeb1014b34503396cfa7efd56d5ec78860a8d29b51 /lib
parent47a26054fea97641aebb3906ca7416a982f4c0d5 (diff)
downloadpuppet-dd7caa76e160ed51c8b0e123c18f7526b575bfec.tar.gz
puppet-dd7caa76e160ed51c8b0e123c18f7526b575bfec.tar.xz
puppet-dd7caa76e160ed51c8b0e123c18f7526b575bfec.zip
Moving some compile tests to the spec/ directory, and
switching the node scope to no longer be lazy evaluation, just like I switched 'main'. When I made all of these classes and nodes lazy evaluated, I should have decoupled my real goal (using resources to evaluate them) from the idea of lazy-evaluating them, and this basically does that. I also changed the scope heirarchy slightly so that scopes will tend to be below the node scope, altho this was already generally the case.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/parser/compile.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/puppet/parser/compile.rb b/lib/puppet/parser/compile.rb
index 3083f4849..45d60a58c 100644
--- a/lib/puppet/parser/compile.rb
+++ b/lib/puppet/parser/compile.rb
@@ -14,7 +14,7 @@ require 'puppet/util/errors'
class Puppet::Parser::Compile
include Puppet::Util
include Puppet::Util::Errors
- attr_reader :topscope, :parser, :node, :facts, :collections, :configuration
+ attr_reader :parser, :node, :facts, :collections, :configuration, :node_scope
# Add a collection to the global list.
def add_collection(coll)
@@ -229,6 +229,12 @@ class Puppet::Parser::Compile
@configuration.add_edge!(scope.resource, resource)
end
+ # The top scope is usually the top-level scope, but if we're using AST nodes,
+ # then it is instead the node's scope.
+ def topscope
+ node_scope || @topscope
+ end
+
private
# If ast nodes are enabled, then see if we can find and evaluate one.
@@ -241,10 +247,7 @@ class Puppet::Parser::Compile
break if astnode = @parser.nodes[name.to_s.downcase]
end
- unless astnode
- astnode = @parser.nodes["default"]
- end
- unless astnode
+ unless (astnode ||= @parser.nodes["default"])
raise Puppet::ParseError, "Could not find default node or by name with '%s'" % node.names.join(", ")
end
@@ -253,6 +256,12 @@ class Puppet::Parser::Compile
resource = Puppet::Parser::Resource.new(:type => "node", :title => astnode.classname, :scope => topscope, :source => topscope.source)
store_resource(topscope, resource)
@configuration.tag(astnode.classname)
+
+ resource.evaluate
+
+ # Now set the node scope appropriately, so that :topscope can
+ # behave differently.
+ @node_scope = class_scope(astnode)
end
# Evaluate our collections and return true if anything returned an object.