diff options
Diffstat (limited to 'lib/puppet/modules.rb')
-rw-r--r-- | lib/puppet/modules.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/puppet/modules.rb b/lib/puppet/modules.rb index cf611b82c..2d48a6a4e 100644 --- a/lib/puppet/modules.rb +++ b/lib/puppet/modules.rb @@ -1,6 +1,8 @@ # Support for modules class Puppet::Module + TEMPLATES = "templates" + # Return an array of paths by splitting the +modulepath+ config # parameter. Only consider paths that are absolute and existing # directories @@ -32,11 +34,39 @@ class Puppet::Module # Instance methods + # Find the concrete file denoted by +file+. If +file+ is absolute, + # return it directly. Otherwise try to find it as a template in a + # module. If that fails, return it relative to the +templatedir+ config + # param. + # In all cases, an absolute path is returned, which does not + # necessarily refer to an existing file + def self.find_template(file) + if file =~ /^#{File::SEPARATOR}/ + return file + end + + mod = find(file) + if mod + return mod.template(file) + else + return File.join(Puppet[:templatedir], file) + end + end + attr_reader :name, :path def initialize(name, path) @name = name @path = path end + def strip(file) + n, rest = file.split(File::SEPARATOR, 2) + return rest + end + + def template(file) + return File::join(path, TEMPLATES, strip(file)) + end + private :initialize end |