Class: Puppet::Util::Package::Version::Debian
- Includes:
- Comparable
- Defined in:
- lib/puppet/util/package/version/debian.rb
Defined Under Namespace
Classes: ValidationFailure
Constant Summary collapse
- REGEX_EPOCH =
Version string matching regexes
'(?:([0-9]+):)?'
- REGEX_UPSTREAM_VERSION =
alphanumerics and the characters . + - ~ , starts with a digit, ~ only of debian_revision is present
'([\.\+~0-9a-zA-Z-]+?)'
- REGEX_DEBIAN_REVISION =
alphanumerics and the characters + . ~
'(?:-([\.\+~0-9a-zA-Z]*))?'
- REGEX_FULL =
REGEX_EPOCH + REGEX_UPSTREAM_VERSION + REGEX_DEBIAN_REVISION.freeze
- REGEX_FULL_RX =
/\A#{REGEX_FULL}\Z/
Instance Attribute Summary collapse
-
#debian_revision ⇒ Object
readonly
Returns the value of attribute debian_revision.
-
#epoch ⇒ Object
readonly
Returns the value of attribute epoch.
-
#upstream_version ⇒ Object
readonly
Returns the value of attribute upstream_version.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
- #to_s ⇒ Object (also: #inspect)
Instance Attribute Details
#debian_revision ⇒ Object (readonly)
Returns the value of attribute debian_revision.
58 59 60 |
# File 'lib/puppet/util/package/version/debian.rb', line 58 def debian_revision @debian_revision end |
#epoch ⇒ Object (readonly)
Returns the value of attribute epoch.
58 59 60 |
# File 'lib/puppet/util/package/version/debian.rb', line 58 def epoch @epoch end |
#upstream_version ⇒ Object (readonly)
Returns the value of attribute upstream_version.
58 59 60 |
# File 'lib/puppet/util/package/version/debian.rb', line 58 def upstream_version @upstream_version end |
Class Method Details
.parse(ver) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/puppet/util/package/version/debian.rb', line 19 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
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/puppet/util/package/version/debian.rb', line 45 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: ==
37 38 39 40 41 42 |
# File 'lib/puppet/util/package/version/debian.rb', line 37 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_s ⇒ Object Also known as: inspect
29 30 31 32 33 34 |
# File 'lib/puppet/util/package/version/debian.rb', line 29 def to_s s = @upstream_version s = "#{@epoch}:#{s}" if @epoch != 0 s = "#{s}-#{@debian_revision}" if @debian_revision s end |