Class: Puppet::Util::Package::Version::Rpm

Inherits:
Numeric
  • Object
show all
Extended by:
RpmCompare
Includes:
Comparable, RpmCompare
Defined in:
lib/puppet/util/package/version/rpm.rb

Defined Under Namespace

Classes: ValidationFailure

Constant Summary

Constants included from RpmCompare

RpmCompare::ARCH_LIST, RpmCompare::ARCH_REGEX

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RpmCompare

compare_values, rpm_parse_evr, rpmvercmp

Instance Attribute Details

#archObject (readonly)

Returns the value of attribute arch.



14
15
16
# File 'lib/puppet/util/package/version/rpm.rb', line 14

def arch
  @arch
end

#epochObject (readonly)

Returns the value of attribute epoch.



14
15
16
# File 'lib/puppet/util/package/version/rpm.rb', line 14

def epoch
  @epoch
end

#releaseObject (readonly)

Returns the value of attribute release.



14
15
16
# File 'lib/puppet/util/package/version/rpm.rb', line 14

def release
  @release
end

#versionObject (readonly)

Returns the value of attribute version.



14
15
16
# File 'lib/puppet/util/package/version/rpm.rb', line 14

def version
  @version
end

Class Method Details

.parse(ver) ⇒ Object

Raises:



16
17
18
19
20
21
# File 'lib/puppet/util/package/version/rpm.rb', line 16

def self.parse(ver)
  raise ValidationFailure unless ver.is_a?(String)

  version = rpm_parse_evr(ver)
  new(version[:epoch], version[:version], version[:release], version[:arch]).freeze
end

Instance Method Details

#<=>(other) ⇒ Object

Raises:

  • (ArgumentError)


41
42
43
44
45
# File 'lib/puppet/util/package/version/rpm.rb', line 41

def <=>(other)
  raise ArgumentError, _("Cannot compare, as %{other} is not a Rpm Version") % { other: other } unless other.is_a?(self.class)

  rpm_compare_evr(to_s, other.to_s)
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


32
33
34
35
36
37
38
# File 'lib/puppet/util/package/version/rpm.rb', line 32

def eql?(other)
  other.is_a?(self.class) &&
    @epoch.eql?(other.epoch) &&
    @version.eql?(other.version) &&
    @release.eql?(other.release) &&
    @arch.eql?(other.arch)
end

#to_sObject Also known as: inspect



23
24
25
26
27
28
29
# File 'lib/puppet/util/package/version/rpm.rb', line 23

def to_s
  version_found = ''.dup
  version_found += "#{@epoch}:" if @epoch
  version_found += @version
  version_found += "-#{@release}" if @release
  version_found
end