[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.5-2-109-g5a96442

Micah Anderson micah at riseup.net
Sun Nov 30 00:48:19 UTC 2008


The following commit has been merged in the master branch:
commit e39ae97b082d8200d2215efaf4aab77e098a99fd
Author: Micah Anderson <micah at riseup.net>
Date:   Sat Nov 29 18:42:56 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>
    
    Conflicts:
    
    	CHANGELOG

diff --git a/CHANGELOG b/CHANGELOG
index d3a2ef2..5c5f36b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+0.24.x
+    Fixed #1660 - Added specific recurse values for tidy
+
 0.24.6
     Adding support to the user type for: profiles, auths, project, 
     key/value pairs (extension to Solaris RBAC support added in
diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb
index fe8bde9..8cf705b 100755
--- a/lib/puppet/type/tidy.rb
+++ b/lib/puppet/type/tidy.rb
@@ -249,6 +249,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