module Puppet::Util::Package
Public Class Methods
versioncmp(version_a, version_b)
click to toggle source
# File lib/puppet/util/package.rb 2 def versioncmp(version_a, version_b) 3 vre = /[-.]|\d+|[^-.\d]+/ 4 ax = version_a.scan(vre) 5 bx = version_b.scan(vre) 6 7 while (ax.length>0 && bx.length>0) 8 a = ax.shift 9 b = bx.shift 10 11 if( a == b ) then next 12 elsif (a == '-' && b == '-') then next 13 elsif (a == '-') then return -1 14 elsif (b == '-') then return 1 15 elsif (a == '.' && b == '.') then next 16 elsif (a == '.' ) then return -1 17 elsif (b == '.' ) then return 1 18 elsif (a =~ /^\d+$/ && b =~ /^\d+$/) then 19 if( a =~ /^0/ or b =~ /^0/ ) then 20 return a.to_s.upcase <=> b.to_s.upcase 21 end 22 return a.to_i <=> b.to_i 23 else 24 return a.upcase <=> b.upcase 25 end 26 end 27 version_a <=> version_b; 28 end
Private Instance Methods
versioncmp(version_a, version_b)
click to toggle source
# File lib/puppet/util/package.rb 2 def versioncmp(version_a, version_b) 3 vre = /[-.]|\d+|[^-.\d]+/ 4 ax = version_a.scan(vre) 5 bx = version_b.scan(vre) 6 7 while (ax.length>0 && bx.length>0) 8 a = ax.shift 9 b = bx.shift 10 11 if( a == b ) then next 12 elsif (a == '-' && b == '-') then next 13 elsif (a == '-') then return -1 14 elsif (b == '-') then return 1 15 elsif (a == '.' && b == '.') then next 16 elsif (a == '.' ) then return -1 17 elsif (b == '.' ) then return 1 18 elsif (a =~ /^\d+$/ && b =~ /^\d+$/) then 19 if( a =~ /^0/ or b =~ /^0/ ) then 20 return a.to_s.upcase <=> b.to_s.upcase 21 end 22 return a.to_i <=> b.to_i 23 else 24 return a.upcase <=> b.upcase 25 end 26 end 27 version_a <=> version_b; 28 end