[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.7-1-98-gf19c0e5

James Turnbull james at lovedthanlost.net
Wed Apr 8 21:48:24 UTC 2009


The following commit has been merged in the master branch:
commit ff5b13a47892e2ab3ee8765bf44cfbd00694d7df
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date:   Fri Dec 19 17:35:08 2008 +0100

    Fix #1807 - make Puppet::Util::Package.versioncmp a module function
    
    Signed-off-by: Brice Figureau <brice-puppet at daysofwonder.com>

diff --git a/lib/puppet/util/package.rb b/lib/puppet/util/package.rb
index 00e04f6..613aa6b 100644
--- a/lib/puppet/util/package.rb
+++ b/lib/puppet/util/package.rb
@@ -28,4 +28,6 @@ module Puppet::Util::Package
         end
         return version_a <=> version_b;
     end
+    
+    module_function :versioncmp
 end
diff --git a/spec/unit/util/package.rb b/spec/unit/util/package.rb
new file mode 100644
index 0000000..7d956ef
--- /dev/null
+++ b/spec/unit/util/package.rb
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+require 'puppet/util/package'
+
+describe Puppet::Util::Package, " versioncmp" do
+
+    it "should be able to be used as a module function" do
+        Puppet::Util::Package.should respond_to(:versioncmp)
+    end
+
+    it "should be able to sort a long set of various unordered versions" do
+        ary = %w{ 1.1.6 2.3 1.1a 3.0 1.5 1 2.4 1.1-4 2.3.1 1.2 2.3.0 1.1-3 2.4b 2.4 2.40.2 2.3a.1 3.1 0002 1.1-5 1.1.a 1.06}
+
+        newary = ary.sort { |a, b| Puppet::Util::Package.versioncmp(a,b) }
+        
+        newary.should == ["0002", "1", "1.06", "1.1-3", "1.1-4", "1.1-5", "1.1.6", "1.1.a", "1.1a", "1.2", "1.5", "2.3", "2.3.0", "2.3.1", "2.3a.1", "2.4", "2.4", "2.4b", "2.40.2", "3.0", "3.1"]
+    end
+    
+end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list