summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-08-18 18:14:19 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-08-24 11:38:19 +1000
commit6fa9271a944f4167f82cb51affe1c0b795428b73 (patch)
treef74716eb7c6dd4a1c6e3836d80bf4379625da665 /lib
parentc7526808c9d2d7efbcc39f33112001bd9bd42b56 (diff)
downloadpuppet-6fa9271a944f4167f82cb51affe1c0b795428b73.tar.gz
puppet-6fa9271a944f4167f82cb51affe1c0b795428b73.tar.xz
puppet-6fa9271a944f4167f82cb51affe1c0b795428b73.zip
Fixing #2549 - autoloading of top-level classes works again
This was broken in the recent refactor around autoloading, which didn't special-case classes that specified that they were top-level. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/parser/parser_support.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb
index 68cd3825c..c32a69b3d 100644
--- a/lib/puppet/parser/parser_support.rb
+++ b/lib/puppet/parser/parser_support.rb
@@ -117,15 +117,21 @@ class Puppet::Parser::Parser
namespace = namespace.downcase
name = name.downcase
fullname = (namespace + "::" + name).sub(/^::/, '')
- names_to_try = [fullname]
- # Try to load the module init file if we're a qualified name
- names_to_try << fullname.split("::")[0] if fullname.include?("::")
+ if name =~ /^::/
+ names_to_try = [name.sub(/^::/, '')]
+ else
+ names_to_try = [fullname]
+
+ # Try to load the module init file if we're a qualified name
+ names_to_try << fullname.split("::")[0] if fullname.include?("::")
- # Otherwise try to load the bare name on its own. This
- # is appropriate if the class we're looking for is in a
- # module that's different from our namespace.
- names_to_try << name
+ # Otherwise try to load the bare name on its own. This
+ # is appropriate if the class we're looking for is in a
+ # module that's different from our namespace.
+ names_to_try << name
+ names_to_try.compact!
+ end
until (result = @loaded_code.send(method, namespace, name)) or names_to_try.empty? do
self.load(names_to_try.shift)
@@ -151,6 +157,7 @@ class Puppet::Parser::Parser
# We can't interpolate at this point since we don't have any
# scopes set up. Warn the user if they use a variable reference
+ raise "Got no file" unless file
pat = file
if pat.index("$")
Puppet.warning(