summaryrefslogtreecommitdiffstats
path: root/lib/puppet/file_serving
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-02-17 17:15:17 -0600
committerLuke Kanies <luke@madstop.com>2009-02-18 22:38:44 -0600
commiteec1caddf0dc431229ceb1741b357a9fefce5c38 (patch)
tree8ca642aca39d0e34882faef244e778bc263e2eb7 /lib/puppet/file_serving
parentbdf3a80e29313008367d83f5a1ec6e4121e4ec74 (diff)
downloadpuppet-eec1caddf0dc431229ceb1741b357a9fefce5c38.tar.gz
puppet-eec1caddf0dc431229ceb1741b357a9fefce5c38.tar.xz
puppet-eec1caddf0dc431229ceb1741b357a9fefce5c38.zip
Adding support for merging multiple filesets.
This is required for plugins, which recurse across multiple directories. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/file_serving')
-rw-r--r--lib/puppet/file_serving/fileset.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb
index caad1b319..74a3c27fe 100644
--- a/lib/puppet/file_serving/fileset.rb
+++ b/lib/puppet/file_serving/fileset.rb
@@ -11,6 +11,23 @@ class Puppet::FileServing::Fileset
attr_reader :path, :ignore, :links
attr_accessor :recurse
+ # Produce a hash of files, with merged so that earlier files
+ # with the same postfix win. E.g., /dir1/subfile beats /dir2/subfile.
+ # It's a hash because we need to know the relative path of each file,
+ # and the base directory.
+ # This will probably only ever be used for searching for plugins.
+ def self.merge(*filesets)
+ result = {}
+
+ filesets.each do |fileset|
+ fileset.files.each do |file|
+ result[file] ||= fileset.path
+ end
+ end
+
+ result
+ end
+
# Return a list of all files in our fileset. This is different from the
# normal definition of find in that we support specific levels
# of recursion, which means we need to know when we're going another