class Puppet::Util::Package::Version::RPM_VERSION

Attributes

arch[R]
epoch[R]
release[R]
version[R]

Public Class Methods

new(epoch, version, release, arch) click to toggle source
   # File lib/puppet/util/package/version/rpm.rb
66 def initialize(epoch, version, release, arch)
67   @epoch   = epoch
68   @version = version
69   @release = release
70   @arch    = arch
71 end
parse(ver) click to toggle source
   # File lib/puppet/util/package/version/rpm.rb
15 def self.parse(ver)
16   raise ValidationFailure unless ver.is_a?(String)
17   version = rpm_parse_evr(ver)
18   new(version[:epoch], version[:version], version[:release], version[:arch]).freeze
19 end

Public Instance Methods

<=>(other) click to toggle source
   # File lib/puppet/util/package/version/rpm.rb
39 def <=>(other)
40   raise ArgumentError, _("Cannot compare, as %{other} is not a Rpm Version") % { other: other } unless other.is_a?(self.class)
41 
42   rpm_compareEVR(self.to_s, other.to_s)
43 end
==(other)
Alias for: eql?
eql?(other) click to toggle source
   # File lib/puppet/util/package/version/rpm.rb
30 def eql?(other)
31   other.is_a?(self.class) &&
32     @epoch.eql?(other.epoch) &&
33     @version.eql?(other.version) &&
34     @release.eql?(other.release) &&
35     @arch.eql?(other.arch)
36 end
Also aliased as: ==
inspect()
Alias for: to_s
to_s() click to toggle source
   # File lib/puppet/util/package/version/rpm.rb
21 def to_s
22   version_found = ''
23   version_found += "#{@epoch}:"   if @epoch
24   version_found += @version
25   version_found += "-#{@release}" if @release
26   version_found
27 end
Also aliased as: inspect

Private Instance Methods

rpm_compareEVR(a, b) click to toggle source

overwrite rpm_compareEVR to treat no epoch as zero epoch in order to compare version correctly

returns 1 if a is newer than b,

 0 if they are identical
-1 if a is older than b
Calls superclass method Puppet::Util::RpmCompare#rpm_compareEVR
   # File lib/puppet/util/package/version/rpm.rb
53 def rpm_compareEVR(a, b)
54   a_hash = rpm_parse_evr(a)
55   b_hash = rpm_parse_evr(b)
56 
57   a_hash[:epoch] ||= '0'
58   b_hash[:epoch] ||= '0'
59 
60   rc = compare_values(a_hash[:epoch], b_hash[:epoch])
61   return rc unless rc == 0
62 
63   super(a, b)
64 end