Class: Puppet::Util::Package::Version::Debian Private

Inherits:
Numeric
  • Object
show all
Includes:
Comparable
Defined in:
lib/puppet/util/package/version/debian.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: ValidationFailure

Constant Summary collapse

REGEX_EPOCH =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Version string matching regexes

'(?:([0-9]+):)?'
REGEX_UPSTREAM_VERSION =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

alphanumerics and the characters . + - ~ , starts with a digit, ~ only of debian_revision is present

'([\.\+~0-9a-zA-Z-]+?)'
REGEX_DEBIAN_REVISION =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

alphanumerics and the characters + . ~

'(?:-([\.\+~0-9a-zA-Z]*))?'
REGEX_FULL =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

REGEX_EPOCH + REGEX_UPSTREAM_VERSION + REGEX_DEBIAN_REVISION.freeze
REGEX_FULL_RX =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/\A#{REGEX_FULL}\Z/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#debian_revisionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


55
56
57
# File 'lib/puppet/util/package/version/debian.rb', line 55

def debian_revision
  @debian_revision
end

#epochObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


55
56
57
# File 'lib/puppet/util/package/version/debian.rb', line 55

def epoch
  @epoch
end

#upstream_versionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


55
56
57
# File 'lib/puppet/util/package/version/debian.rb', line 55

def upstream_version
  @upstream_version
end

Class Method Details

.parse(ver) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:


17
18
19
20
21
22
23
24
25
# File 'lib/puppet/util/package/version/debian.rb', line 17

def self.parse(ver)
  raise ValidationFailure, "Unable to parse '#{ver}' as a string" unless ver.is_a?(String)

  match, epoch, upstream_version, debian_revision = *ver.match(REGEX_FULL_RX)

  raise ValidationFailure, "Unable to parse '#{ver}' as a debian version identifier" unless match

  new(epoch.to_i, upstream_version, debian_revision).freeze
end

Instance Method Details

#<=>(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


43
44
45
46
47
48
49
50
51
52
53
# File 'lib/puppet/util/package/version/debian.rb', line 43

def <=>(other)
  return nil unless other.is_a?(self.class)
  cmp = @epoch <=> other.epoch
  if cmp == 0
    cmp = compare_upstream_version(other)
    if cmp == 0
      cmp = compare_debian_revision(other)
    end
  end
  cmp
end

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

35
36
37
38
39
40
# File 'lib/puppet/util/package/version/debian.rb', line 35

def eql?(other)
  other.is_a?(self.class) &&
    @epoch.eql?(other.epoch) &&
    @upstream_version.eql?(other.upstream_version) &&
    @debian_revision.eql?(other.debian_revision)
end

#to_sObject Also known as: inspect

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


27
28
29
30
31
32
# File 'lib/puppet/util/package/version/debian.rb', line 27

def to_s
  s = @upstream_version
  s = "#{@epoch}:#{s}" if @epoch != 0
  s = "#{s}-#{@debian_revision}" if @debian_revision
  s
end