summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-02-17 18:07:27 -0600
committerLuke Kanies <luke@madstop.com>2009-02-18 22:38:45 -0600
commit94de52657c0cfff9bed312cffe78f9b59b9081d2 (patch)
tree5800599be24e403ef4a8accf9a435aefcc814471 /lib/puppet
parent2573ef1c4c2d472f9cf41ab3a1b67b7408d704b4 (diff)
downloadpuppet-94de52657c0cfff9bed312cffe78f9b59b9081d2.tar.gz
puppet-94de52657c0cfff9bed312cffe78f9b59b9081d2.tar.xz
puppet-94de52657c0cfff9bed312cffe78f9b59b9081d2.zip
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 <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/node/environment.rb16
1 files changed, 16 insertions, 0 deletions
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 = []