From 94de52657c0cfff9bed312cffe78f9b59b9081d2 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 17 Feb 2009 18:07:27 -0600 Subject: The 'Environment' class can now calculate its modulepath. This includes adding PUPPETLIB from the shell environment. I'm moving responsibility for this from the Module class, because nearly every method in Puppet::Module accepted 'environment' as its argument, which is a good sign that it's on the wrong class. Signed-off-by: Luke Kanies --- lib/puppet/node/environment.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/puppet/node') diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb index d4c04469c..785a5ccec 100644 --- a/lib/puppet/node/environment.rb +++ b/lib/puppet/node/environment.rb @@ -37,6 +37,22 @@ class Puppet::Node::Environment return nil end + def modulepath + dirs = self[:modulepath].split(File::PATH_SEPARATOR) + if ENV["PUPPETLIB"] + dirs = ENV["PUPPETLIB"].split(File::PATH_SEPARATOR) + dirs + end + dirs.collect do |dir| + if dir !~ /^#{File::SEPARATOR}/ + File.join(Dir.getwd, dir) + else + dir + end + end.find_all do |p| + p =~ /^#{File::SEPARATOR}/ && FileTest.directory?(p) + end + end + # Return all modules from this environment. def modules result = [] -- cgit