[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:21 UTC 2008


The following commit has been merged in the master branch:
commit 24d10dad526aa0e7e13487b395bbe1c2d8436f45
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 d12a0e8..a2b5be6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,6 @@
 0.24.x
+    Fixed #1660 - Added specific recurse values for tidy
+
     Fixed #1661 - Type reference: tidy should specify manditory parameters
 
 0.24.6
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