diff options
author | lutter <lutter@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-09 00:48:28 +0000 |
---|---|---|
committer | lutter <lutter@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-09 00:48:28 +0000 |
commit | ebcb6b6df7af42632a6c1beaa1b60171ff32b61e (patch) | |
tree | 2d82562a541862f20daf9e05f1a3642a27e4ffb1 /lib/puppet/modules.rb | |
parent | ba6257c02ef5e4bd32d58d40087f84dda95141c3 (diff) | |
download | puppet-ebcb6b6df7af42632a6c1beaa1b60171ff32b61e.tar.gz puppet-ebcb6b6df7af42632a6c1beaa1b60171ff32b61e.tar.xz puppet-ebcb6b6df7af42632a6c1beaa1b60171ff32b61e.zip |
The template function now tries to first find a template within a module
(if the template path looks like it belongs to a module) and only when that
fails looks for it in templatedir
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2277 980ebf18-57e1-0310-9a29-db15c13687c0
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 |