From 3421954444f4c06d6e7b80430f89fccf56343fe2 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 25 Nov 2008 22:20:39 -0600 Subject: Fixing #1755 - handling fully qualified classes correctly. This involves lexing '::class' tokens along with correctly looking them up from the Resource::Reference class. Signed-off-by: Luke Kanies --- lib/puppet/parser/lexer.rb | 2 +- lib/puppet/parser/resource/reference.rb | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb index 69a46d0c1..a7b87e6d1 100644 --- a/lib/puppet/parser/lexer.rb +++ b/lib/puppet/parser/lexer.rb @@ -134,7 +134,7 @@ class Puppet::Parser::Lexer '*' => :TIMES, '<<' => :LSHIFT, '>>' => :RSHIFT, - %r{([a-z][-\w]*::)+[a-z][-\w]*} => :CLASSNAME, + %r{([a-z][-\w]*)?(::[a-z][-\w]*)+} => :CLASSNAME, # Require '::' in the class name, else we'd compete with NAME %r{((::){0,1}[A-Z][-\w]*)+} => :CLASSREF ) diff --git a/lib/puppet/parser/resource/reference.rb b/lib/puppet/parser/resource/reference.rb index c59748049..cb505d606 100644 --- a/lib/puppet/parser/resource/reference.rb +++ b/lib/puppet/parser/resource/reference.rb @@ -37,7 +37,7 @@ class Puppet::Parser::Resource::Reference < Puppet::ResourceReference if self.title == :main tmp = @scope.findclass("") else - unless tmp = @scope.findclass(self.title) + unless tmp = @scope.parser.classes[self.title] fail Puppet::ParseError, "Could not find class '%s'" % self.title end end @@ -46,8 +46,9 @@ class Puppet::Parser::Resource::Reference < Puppet::ResourceReference fail Puppet::ParseError, "Could not find node '%s'" % self.title end else # normal definitions - # We have to swap these variables around so the errors are right. - tmp = @scope.finddefine(self.type) + # The resource type is capitalized, so we have to downcase. Really, + # we should have a better interface for finding these, but eh. + tmp = @scope.parser.definitions[self.type.downcase] end if tmp -- cgit