class Chef::Provider::Package::Yum::RPMVersion
Attributes
e[R]
epoch[R]
r[R]
release[R]
v[R]
version[R]
Public Class Methods
new(*args)
click to toggle source
# File lib/chef/provider/package/yum.rb, line 233 def initialize(*args) if args.size == 1 @e, @v, @r = RPMUtils.version_parse(args[0]) elsif args.size == 3 @e = args[0].to_i @v = args[1] @r = args[2] else raise ArgumentError, "Expecting either 'epoch-version-release' or 'epoch, " + "version, release'" end end
parse(*args)
click to toggle source
# File lib/chef/provider/package/yum.rb, line 250 def self.parse(*args) self.new(*args) end
Public Instance Methods
<=>(y)
click to toggle source
# File lib/chef/provider/package/yum.rb, line 254 def <=>(y) compare_versions(y) end
compare(y)
click to toggle source
# File lib/chef/provider/package/yum.rb, line 258 def compare(y) compare_versions(y, false) end
evr()
click to toggle source
# File lib/chef/provider/package/yum.rb, line 275 def evr "#{@e}:#{@v}-#{@r}" end
partial_compare(y)
click to toggle source
# File lib/chef/provider/package/yum.rb, line 262 def partial_compare(y) compare_versions(y, true) end
to_s()
click to toggle source
RPM::Version rpm_version_to_s equivalent
# File lib/chef/provider/package/yum.rb, line 267 def to_s if @r.nil? @v else "#{@v}-#{@r}" end end
Private Instance Methods
compare_versions(y, partial=false)
click to toggle source
Rough RPM::Version rpm_version_cmp equivalent - except much slower :)
partial lets epoch and version segment equality be good enough to return equal, eg:
2:1.2-1 == 2:1.2 2:1.2-1 == 2:
# File lib/chef/provider/package/yum.rb, line 288 def compare_versions(y, partial=false) x = self # compare epoch if (x.e.nil? == false and x.e > 0) and y.e.nil? return 1 elsif x.e.nil? and (y.e.nil? == false and y.e > 0) return -1 elsif x.e.nil? == false and y.e.nil? == false if x.e < y.e return -1 elsif x.e > y.e return 1 end end # compare version if partial and (x.v.nil? or y.v.nil?) return 0 elsif x.v.nil? == false and y.v.nil? return 1 elsif x.v.nil? and y.v.nil? == false return -1 elsif x.v.nil? == false and y.v.nil? == false cmp = RPMUtils.rpmvercmp(x.v, y.v) return cmp if cmp != 0 end # compare release if partial and (x.r.nil? or y.r.nil?) return 0 elsif x.r.nil? == false and y.r.nil? return 1 elsif x.r.nil? and y.r.nil? == false return -1 elsif x.r.nil? == false and y.r.nil? == false cmp = RPMUtils.rpmvercmp(x.r, y.r) return cmp end return 0 end