diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-10-04 18:24:24 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-10-04 18:24:24 +0000 |
commit | 28cee40689440388994a4768bd301ae32c8ecc05 (patch) | |
tree | c865ab44f4c9247052cf83de16ffc8ebe8b15e54 /lib/puppet/parser/functions.rb | |
parent | e0e291332bd4676962a28c7b220ae5c5e9651c0a (diff) | |
download | puppet-28cee40689440388994a4768bd301ae32c8ecc05.tar.gz puppet-28cee40689440388994a4768bd301ae32c8ecc05.tar.xz puppet-28cee40689440388994a4768bd301ae32c8ecc05.zip |
Merging the changes from the override-refactor branch. This is a significant rewrite of the parser, but it has little affect on the rest of the code tree.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1726 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser/functions.rb')
-rw-r--r-- | lib/puppet/parser/functions.rb | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb index 9562441bc..96fccd7cd 100644 --- a/lib/puppet/parser/functions.rb +++ b/lib/puppet/parser/functions.rb @@ -76,29 +76,24 @@ module Functions # Include the specified classes newfunction(:include) do |vals| - vals.each do |val| - if objecttype = lookuptype(val) - # It's a defined type, so set it into the scope so it can - # be evaluated. - setobject( - :type => val, - :arguments => {} - ) - else - raise Puppet::ParseError, "Unknown class %s" % val - end + klasses = evalclasses(*vals) + + missing = vals.find_all do |klass| + ! klass.include?(klass) + end + + # Throw an error if we didn't evaluate all of the classes. + if missing.length == 1 + self.fail Puppet::ParseError, + "Could not find class %s" % missing + elsif missing.length > 1 + self.fail Puppet::ParseError, + "Could not find classes %s" % missing.join(", ") end end # Tag the current scope with each passed name newfunction(:tag) do |vals| - vals.each do |val| - # Some hackery, because the tags are stored by object id - # for singletonness. - self.setclass(val.object_id, val) - end - - # Also add them as tags self.tag(*vals) end @@ -120,16 +115,13 @@ module Functions # Test whether a given class or definition is defined newfunction(:defined, :rvalue) do |vals| - retval = true - - vals.each do |val| - unless builtintype?(val) or lookuptype(val) - retval = false - break - end + # For some reason, it doesn't want me to return from here. + if vals.detect do |val| Puppet::Type.type(val) or finddefine(val) end + true + else + false end - return retval end newfunction(:fail, :statement) do |vals| @@ -151,7 +143,7 @@ module Functions # Use a wrapper, so the template can't get access to the full # Scope object. debug "Retrieving template %s" % file - wrapper = Puppet::Parser::Scope::TemplateWrapper.new(self, file) + wrapper = Puppet::Parser::TemplateWrapper.new(self, file) begin wrapper.result() |