summaryrefslogtreecommitdiffstats
path: root/lib/puppet/module.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-02-17 19:00:03 -0600
committerLuke Kanies <luke@madstop.com>2009-02-18 22:38:45 -0600
commit1be7c763b51c0cb6b271429f83ca4afb733bbf63 (patch)
tree43fecae7a7a8c02ca41eca1c542e9a005e3e8c7d /lib/puppet/module.rb
parent2b4469d1c881065587a28924c702cefbf46d098d (diff)
downloadpuppet-1be7c763b51c0cb6b271429f83ca4afb733bbf63.tar.gz
puppet-1be7c763b51c0cb6b271429f83ca4afb733bbf63.tar.xz
puppet-1be7c763b51c0cb6b271429f83ca4afb733bbf63.zip
Using the Environments to handle a lot of Module searching
Since Environments now know how to look for modules, a lot of the Module code was able to be pushed into them. Also moving some of the tests to instance-level tests, rather than just testing the class-level interfaces. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/module.rb')
-rw-r--r--lib/puppet/module.rb39
1 files changed, 2 insertions, 37 deletions
diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb
index 5ae3f3121..54eb4bd97 100644
--- a/lib/puppet/module.rb
+++ b/lib/puppet/module.rb
@@ -34,19 +34,7 @@ class Puppet::Module
# parameter. Only consider paths that are absolute and existing
# directories
def self.modulepath(environment = nil)
- dirs = Puppet.settings.value(:modulepath, environment).split(":")
- if ENV["PUPPETLIB"]
- dirs = ENV["PUPPETLIB"].split(":") + dirs
- end
- dirs.collect do |dir|
- if dir !~ /^#{File::SEPARATOR}/
- File.join(Dir.getwd, dir)
- else
- dir
- end
- end.select do |p|
- p =~ /^#{File::SEPARATOR}/ && File::directory?(p)
- end
+ Puppet::Node::Environment.new(environment).modulepath
end
# Return an array of paths by splitting the +templatedir+ config
@@ -62,30 +50,7 @@ class Puppet::Module
# absolute, or if there is no module whose name is the first component
# of +path+, return +nil+
def self.find(modname, environment = nil)
- # Modules shouldn't be fully qualified.
- return nil if modname =~ %r/^#{File::SEPARATOR}/
-
- modpath = modulepath(environment).collect { |path|
- File::join(path, modname)
- }.find { |f| File::directory?(f) }
- return nil unless modpath
-
- return self.new(modname, modpath)
- end
-
- # Return an array of the full path of every subdirectory in each
- # directory in the modulepath.
- def self.all(environment = nil)
- modulepath(environment).map do |mp|
- Dir.new(mp).map do |modfile|
- modpath = File.join(mp, modfile)
- unless modfile == '.' or modfile == '..' or !File.directory?(modpath)
- modpath
- else
- nil
- end
- end
- end.flatten.compact
+ Puppet::Node::Environment.new(environment).module(modname)
end
# Instance methods