diff options
Diffstat (limited to 'lib/puppet/parser')
| -rw-r--r-- | lib/puppet/parser/ast/component.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/parser/configuration.rb | 12 | ||||
| -rw-r--r-- | lib/puppet/parser/interpreter.rb | 32 | ||||
| -rw-r--r-- | lib/puppet/parser/parser_support.rb | 11 | ||||
| -rw-r--r-- | lib/puppet/parser/resource.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/parser/scope.rb | 6 | ||||
| -rw-r--r-- | lib/puppet/parser/templatewrapper.rb | 4 |
7 files changed, 29 insertions, 41 deletions
diff --git a/lib/puppet/parser/ast/component.rb b/lib/puppet/parser/ast/component.rb index 65f310212..17cfa9d61 100644 --- a/lib/puppet/parser/ast/component.rb +++ b/lib/puppet/parser/ast/component.rb @@ -27,7 +27,7 @@ class Puppet::Parser::AST false end - def evaluate(hash) + def evaluate_resource(hash) origscope = hash[:scope] title = hash[:title] args = symbolize_options(hash[:arguments] || {}) diff --git a/lib/puppet/parser/configuration.rb b/lib/puppet/parser/configuration.rb index 90812899a..ddfc3606f 100644 --- a/lib/puppet/parser/configuration.rb +++ b/lib/puppet/parser/configuration.rb @@ -12,7 +12,7 @@ require 'puppet/util/errors' class Puppet::Parser::Configuration include Puppet::Util include Puppet::Util::Errors - attr_reader :topscope, :parser, :node, :facts + attr_reader :topscope, :parser, :node, :facts, :collections attr_accessor :extraction_format attr_writer :ast_nodes @@ -30,6 +30,13 @@ class Puppet::Parser::Configuration # Store the fact that we've evaluated a class, and store a reference to # the scope in which it was evaluated, so that we can look it up later. def class_set(name, scope) + if existing = @class_scopes[name] + if existing.nodescope? or scope.nodescope? + raise Puppet::ParseError, "Cannot have classes, nodes, or definitions with the same name" + else + raise Puppet::DevError, "Somehow evaluated the same class twice" + end + end @class_scopes[name] = scope tag(name) end @@ -89,16 +96,19 @@ class Puppet::Parser::Configuration # just tag the configuration and move on. def evaluate_classes(classes = nil) classes ||= node.classes + found = [] classes.each do |name| if klass = @parser.findclass("", name) # This will result in class_set getting called, which # will in turn result in tags. Yay. klass.safeevaluate(:scope => topscope) + found << name else Puppet.info "Could not find class %s for %s" % [name, node.name] tag(name) end end + found end # Make sure we support the requested extraction format. diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index cf3027a5a..54cd9b023 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -17,18 +17,6 @@ class Puppet::Parser::Interpreter include Puppet::Util::Errors - # Create proxy methods, so the scopes can call the interpreter, since - # they don't have access to the parser. - def findclass(namespace, name) - raise "move findclass() out of the interpreter" - @parser.findclass(namespace, name) - end - - def finddefine(namespace, name) - raise "move finddefine() out of the interpreter" - @parser.finddefine(namespace, name) - end - # create our interpreter def initialize(hash) if @code = hash[:Code] @@ -65,26 +53,6 @@ class Puppet::Parser::Interpreter parsefiles end - # Pass these methods through to the parser. - [:newclass, :newdefine, :newnode].each do |name| - define_method(name) do |*args| - raise("move %s out of the interpreter" % name) - @parser.send(name, *args) - end - end - - # Add a new file to be checked when we're checking to see if we should be - # reparsed. - def newfile(*files) - raise "who uses newfile?" - files.each do |file| - unless file.is_a? Puppet::Util::LoadedFile - file = Puppet::Util::LoadedFile.new(file) - end - @files << file - end - end - def parsedate parsefiles() @parsedate diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb index 6d069dc07..967508e56 100644 --- a/lib/puppet/parser/parser_support.rb +++ b/lib/puppet/parser/parser_support.rb @@ -444,6 +444,17 @@ class Puppet::Parser::Parser def string=(string) @lexer.string = string end + + # Add a new file to be checked when we're checking to see if we should be + # reparsed. + def watch_file(*files) + files.each do |file| + unless file.is_a? Puppet::Util::LoadedFile + file = Puppet::Util::LoadedFile.new(file) + end + @files << file + end + end end # $Id$ diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index eace88645..9d3e962f0 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -52,11 +52,10 @@ class Puppet::Parser::Resource if klass = @ref.definedtype finish() scope.configuration.delete_resource(self) - return klass.evaluate(:scope => scope, + return klass.evaluate_resource(:scope => scope, :type => self.type, :title => self.title, :arguments => self.to_hash, - :scope => self.scope, :virtual => self.virtual, :exported => self.exported ) diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index 808362858..527ed4dcd 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -21,7 +21,7 @@ class Puppet::Parser::Scope # Proxy accessors def host - @configuration.host + @configuration.node.name end def interpreter @configuration.interpreter @@ -241,11 +241,11 @@ class Puppet::Parser::Scope # can support multiple unrelated classes with the same name. def setclass(klass) if klass.is_a?(AST::HostClass) - unless klass.classname + unless name = klass.classname raise Puppet::DevError, "Got a %s with no fully qualified name" % klass.class end - @configuration.class_set(klass.classname, self) + @configuration.class_set(name, self) else raise Puppet::DevError, "Invalid class %s" % klass.inspect end diff --git a/lib/puppet/parser/templatewrapper.rb b/lib/puppet/parser/templatewrapper.rb index 3b8cc3a3a..9c3c6c0d0 100644 --- a/lib/puppet/parser/templatewrapper.rb +++ b/lib/puppet/parser/templatewrapper.rb @@ -15,8 +15,8 @@ class Puppet::Parser::TemplateWrapper end # We'll only ever not have an interpreter in testing, but, eh. - if @scope.interp - @scope.interp.newfile(@file) + if @scope.parser + @scope.parser.watch_file(@file) end end |
