summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/parser_support.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-03-31 23:56:09 -0500
committerLuke Kanies <luke@madstop.com>2008-03-31 23:56:09 -0500
commit88dc49cb7b0efe757c92ce28c807b91335acb07a (patch)
tree13fe4561f1f524f97a8bb2c1ff84c1ef981d0241 /lib/puppet/parser/parser_support.rb
parent4165edaeb71ee2883b1bb85ff39a52d5628b259f (diff)
parenta8592f1009040ebf30a98268610915cc33bb3f63 (diff)
downloadpuppet-88dc49cb7b0efe757c92ce28c807b91335acb07a.tar.gz
puppet-88dc49cb7b0efe757c92ce28c807b91335acb07a.tar.xz
puppet-88dc49cb7b0efe757c92ce28c807b91335acb07a.zip
Merge branch 'master' into master_no_global_resources
Conflicts: lib/puppet/node/catalog.rb lib/puppet/type/pfile.rb lib/puppet/type/pfilebucket.rb lib/puppet/util/filetype.rb spec/unit/node/catalog.rb spec/unit/other/transbucket.rb spec/unit/ral/provider/mount/parsed.rb spec/unit/ral/types/file.rb spec/unit/ral/types/interface.rb spec/unit/ral/types/mount.rb spec/unit/ral/types/package.rb spec/unit/ral/types/schedule.rb spec/unit/ral/types/service.rb test/language/compile.rb test/language/lexer.rb test/language/snippets.rb test/lib/puppettest.rb test/ral/types/basic.rb test/ral/types/cron.rb test/ral/types/exec.rb test/ral/types/file.rb test/ral/types/file/target.rb test/ral/types/filebucket.rb test/ral/types/fileignoresource.rb test/ral/types/filesources.rb test/ral/types/group.rb test/ral/types/host.rb test/ral/types/parameter.rb test/ral/types/sshkey.rb test/ral/types/tidy.rb test/ral/types/user.rb test/ral/types/yumrepo.rb
Diffstat (limited to 'lib/puppet/parser/parser_support.rb')
-rw-r--r--lib/puppet/parser/parser_support.rb30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb
index acf3c9f7c..b86a4792b 100644
--- a/lib/puppet/parser/parser_support.rb
+++ b/lib/puppet/parser/parser_support.rb
@@ -47,11 +47,8 @@ class Puppet::Parser::Parser
# Create an AST object, and automatically add the file and line information if
# available.
- def ast(klass, hash = nil)
- hash ||= {}
- unless hash.include?(:line)
- hash[:line] = @lexer.line
- end
+ def ast(klass, hash = {})
+ hash[:line] = @lexer.line unless hash.include?(:line)
unless hash.include?(:file)
if file = @lexer.file
@@ -126,13 +123,17 @@ class Puppet::Parser::Parser
def fqfind(namespace, name, table)
namespace = namespace.downcase
name = name.to_s.downcase
+
+ # If our classname is fully qualified or we have no namespace,
+ # just try directly for the class, and return either way.
if name =~ /^::/ or namespace == ""
classname = name.sub(/^::/, '')
- unless table[classname]
- self.load(classname)
- end
+ self.load(classname) unless table[classname]
return table[classname]
end
+
+ # Else, build our namespace up piece by piece, checking
+ # for the class in each namespace.
ary = namespace.split("::")
while ary.length > 0
@@ -180,7 +181,7 @@ class Puppet::Parser::Parser
"in file #{@lexer.file} at line #{@lexer.line}"
)
end
- files = Puppet::Module::find_manifests(pat, :cwd => dir)
+ files = Puppet::Module::find_manifests(pat, :cwd => dir, :environment => @environment)
if files.size == 0
raise Puppet::ImportError.new("No file(s) found for import " +
"of '#{pat}'")
@@ -224,7 +225,6 @@ class Puppet::Parser::Parser
return false if classname == ""
filename = classname.gsub("::", File::SEPARATOR)
- loaded = false
# First try to load the top-level module
mod = filename.scan(/^[\w-]+/).shift
unless @loaded.include?(mod)
@@ -232,24 +232,24 @@ class Puppet::Parser::Parser
begin
import(mod)
Puppet.info "Autoloaded module %s" % mod
- loaded = true
rescue Puppet::ImportError => detail
# We couldn't load the module
end
end
- unless filename == mod and ! @loaded.include?(mod)
- @loaded << mod
+ return true if classes.include?(classname)
+
+ unless @loaded.include?(filename)
+ @loaded << filename
# Then the individual file
begin
import(filename)
Puppet.info "Autoloaded file %s from module %s" % [filename, mod]
- loaded = true
rescue Puppet::ImportError => detail
# We couldn't load the file
end
end
- return loaded
+ return classes.include?(classname)
end
# Split an fq name into a namespace and name