[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585
James Turnbull
james at lovedthanlost.net
Fri Jan 23 14:21:32 UTC 2009
The following commit has been merged in the master branch:
commit 57e791b9e7da931e61dd8dfc0f68bd13cf2e6449
Author: Luke Kanies <luke at madstop.com>
Date: Mon Oct 27 23:37:33 2008 -0500
Fixing #1660 - Adding specifically supported values for tidy recursion.
Basically just copied the code for the recurse parameter from 'file'.
Signed-off-by: Luke Kanies <luke at madstop.com>
diff --git a/CHANGELOG b/CHANGELOG
index 8415c06..83b9840 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,6 @@
0.24.x
+ Fixed #1660 - Added specific recurse values for tidy
+
Fixed #1698 - All logs should now show up in the reports
Fixed #1661 - Type reference: tidy should specify manditory parameters
diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb
index 7a46432..c352ec8 100755
--- a/lib/puppet/type/tidy.rb
+++ b/lib/puppet/type/tidy.rb
@@ -252,6 +252,23 @@ module Puppet
newparam(:recurse) do
desc "If target is a directory, recursively descend
into the directory looking for files to tidy."
+
+ newvalues(:true, :false, :inf, /^[0-9]+$/)
+
+ # Replace the validation so that we allow numbers in
+ # addition to string representations of them.
+ validate { |arg| }
+ munge do |value|
+ newval = super(value)
+ case newval
+ when :true, :inf: true
+ when :false: false
+ when Integer, Fixnum, Bignum: value
+ when /^\d+$/: Integer(value)
+ else
+ raise ArgumentError, "Invalid recurse value %s" % value.inspect
+ end
+ end
end
newparam(:rmdirs) do
diff --git a/spec/unit/type/tidy.rb b/spec/unit/type/tidy.rb
new file mode 100755
index 0000000..ee820d4
--- /dev/null
+++ b/spec/unit/type/tidy.rb
@@ -0,0 +1,60 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+tidy = Puppet::Type.type(:tidy)
+
+describe tidy do
+ after { tidy.clear }
+ [:ensure, :age, :size].each do |property|
+ it "should have a %s property" % property do
+ tidy.attrclass(property).ancestors.should be_include(Puppet::Property)
+ end
+
+ it "should have documentation for its %s property" % property do
+ tidy.attrclass(property).doc.should be_instance_of(String)
+ end
+ end
+
+ [:path, :matches, :type, :recurse, :rmdirs].each do |param|
+ it "should have a %s parameter" % param do
+ tidy.attrclass(param).ancestors.should be_include(Puppet::Parameter)
+ end
+
+ it "should have documentation for its %s param" % param do
+ tidy.attrclass(param).doc.should be_instance_of(String)
+ end
+ end
+
+ describe "when validating parameter values" do
+ describe "for 'recurse'" do
+ before do
+ @tidy = tidy.create :path => "/tmp", :age => "100d"
+ end
+
+ it "should allow 'true'" do
+ lambda { @tidy[:recurse] = true }.should_not raise_error
+ end
+
+ it "should allow 'false'" do
+ lambda { @tidy[:recurse] = false }.should_not raise_error
+ end
+
+ it "should allow integers" do
+ lambda { @tidy[:recurse] = 10 }.should_not raise_error
+ end
+
+ it "should allow string representations of integers" do
+ lambda { @tidy[:recurse] = "10" }.should_not raise_error
+ end
+
+ it "should allow 'inf'" do
+ lambda { @tidy[:recurse] = "inf" }.should_not raise_error
+ end
+
+ it "should not allow arbitrary values" do
+ lambda { @tidy[:recurse] = "whatever" }.should raise_error
+ end
+ end
+ end
+end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list