[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:32:12 UTC 2010


The following commit has been merged in the upstream branch:
commit 44cba9cfb85a43f758c457bf3a5e661706f1e8f3
Author: Luke Kanies <luke at reductivelabs.com>
Date:   Tue Mar 16 09:05:02 2010 -0700

    Adding "checksum?" helper method to Checksums module
    
    Signed-off-by: Luke Kanies <luke at reductivelabs.com>

diff --git a/lib/puppet/util/checksums.rb b/lib/puppet/util/checksums.rb
index 39477ee..f68f776 100644
--- a/lib/puppet/util/checksums.rb
+++ b/lib/puppet/util/checksums.rb
@@ -1,6 +1,11 @@
 # A stand-alone module for calculating checksums
 # in a generic way.
 module Puppet::Util::Checksums
+    # Is the provided string a checksum?
+    def checksum?(string)
+        string =~ /^\{(\w{3,5})\}\S+/
+    end
+
     # Strip the checksum type from an existing checksum
     def sumtype(checksum)
         if checksum =~ /^\{(\w+)\}/
diff --git a/spec/unit/util/checksums.rb b/spec/unit/util/checksums.rb
index 615ed90..e0c9909 100755
--- a/spec/unit/util/checksums.rb
+++ b/spec/unit/util/checksums.rb
@@ -28,6 +28,22 @@ describe Puppet::Util::Checksums do
         end
     end
 
+    it "should have a method for determining whether a given string is a checksum" do
+        @summer.should respond_to(:checksum?)
+    end
+
+    %w{{md5}asdfasdf {sha1}asdfasdf {ctime}asdasdf {mtime}asdfasdf}.each do |sum|
+        it "should consider #{sum} to be a checksum" do
+            @summer.should be_checksum(sum)
+        end
+    end
+
+    %w{{nosuchsum}asdfasdf {a}asdfasdf {ctime}}.each do |sum|
+        it "should not consider #{sum} to be a checksum" do
+            @summer.should_not be_checksum(sum)
+        end
+    end
+
     it "should have a method for stripping a sum type from an existing checksum" do
         @summer.sumtype("{md5}asdfasdfa").should == "md5"
     end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list