summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshafer <shafer@980ebf18-57e1-0310-9a29-db15c13687c0>2005-09-13 20:54:07 +0000
committershafer <shafer@980ebf18-57e1-0310-9a29-db15c13687c0>2005-09-13 20:54:07 +0000
commit157953a125f3ed74db58bd5ed66d7e99f7937074 (patch)
treece5ba443ed870938432114277c74637b4b282b9f
parent51948bd716d7da4e17704140769f15b6723c97e8 (diff)
downloadpuppet-157953a125f3ed74db58bd5ed66d7e99f7937074.tar.gz
puppet-157953a125f3ed74db58bd5ed66d7e99f7937074.tar.xz
puppet-157953a125f3ed74db58bd5ed66d7e99f7937074.zip
added ignore to pfile
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@654 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/type/pfile.rb54
1 files changed, 50 insertions, 4 deletions
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index 086be244e..a2dc0a89e 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -836,7 +836,8 @@ module Puppet
:path,
:backup,
:linkmaker,
- :recurse
+ :recurse,
+ :ignore
]
@paramdoc[:path] = "The path to the file to manage. Must be fully
@@ -853,12 +854,17 @@ module Puppet
@paramdoc[:recurse] = "Whether and how deeply to do recursive
management. **false**/*true*/*inf*/*number*"
+ @paramdoc[:ignore] = "A parameter which omits action on files matching specified
+ patterns during recursion i.e. .svn, *.ini"
+
@paramdoc[:source] = "Where to retrieve the contents of the files.
Currently only supports local copying, but will eventually
support multiple protocols for copying. Arguments are specified
using either a full local path or using a URI (currently only
*file* is supported as a protocol)."
+
+
@name = :file
@namevar = :path
@@ -988,6 +994,49 @@ module Puppet
end
def newchild(path, hash = {})
+
+ #make local copy of arguments
+ args = @arghash.dup
+
+ #check if ignored
+ match_ignore = false;
+ if args.include?(:ignore)
+ ignore = args[:ignore]
+
+ #Make sure the value of ignore is in correct type
+ unless ignore.is_a?(Array) | ignore.is_a?(String)
+ raise Puppet::DevError.new("Ignore must be a string or an Array")
+ end
+
+ if ignore.is_a?(String)
+ ignore = Array.new(1,ignore)
+ end
+
+ ignore.each{|pattern|
+
+ #make sure we got strings
+ unless pattern.is_a?(String)
+ raise Puppet::DevError.new(
+ "If Ignore is an Array it must contain strings of patterns")
+ end
+
+ #try to match the pattern
+ match = Regexp.new(pattern.split("*").join("\/*"))
+
+ if match =~ path
+ match_ignore = true
+ break
+ end
+
+ }
+
+ #if the patten is matched return no child
+ if match_ignore
+ return nil
+ end
+
+ end
+
if path =~ %r{^#{File::SEPARATOR}}
raise Puppet::DevError.new(
"Must pass relative paths to PFile#newchild()"
@@ -996,9 +1045,6 @@ module Puppet
path = File.join(self.name, path)
end
- args = @arghash.dup
- #args = {}
-
args[:path] = path
# FIXME I think this is obviated now