Class: Puppet::Util::Package::Version::Pip Private
- Includes:
- Comparable
- Defined in:
- lib/puppet/util/package/version/pip.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
- VERSION_PATTERN =
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.
" v? (?: (?:(?<epoch>[0-9]+)!)? # epoch (?<release>[0-9]+(?:\\.[0-9]+)*) # release segment (?<pre> # pre-release [-_\\.]? (?<pre_l>(a|b|c|rc|alpha|beta|pre|preview)) [-_\\.]? (?<pre_n>[0-9]+)? )? (?<post> # post release (?:-(?<post_n1>[0-9]+)) | (?: [-_\\.]? (?<post_l>post|rev|r) [-_\\.]? (?<post_n2>[0-9]+)? ) )? (?<dev> # dev release [-_\\.]? (?<dev_l>dev) [-_\\.]? (?<dev_n>[0-9]+)? )? ) (?:\\+(?<local>[a-z0-9]+(?:[-_\\.][a-z0-9]+)*))? # local version "
Instance Attribute Summary collapse
- #key ⇒ Object readonly private
Class Method Summary collapse
- .compare(version_a, version_b) ⇒ Object private
- .parse(version) ⇒ Object private
Instance Method Summary collapse
- #<=>(other) ⇒ Object private
- #eql?(other) ⇒ Boolean (also: #==) private
- #to_s ⇒ Object (also: #inspect) private
Instance Attribute Details
#key ⇒ Object (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.
77 78 79 |
# File 'lib/puppet/util/package/version/pip.rb', line 77 def key @key end |
Class Method Details
.compare(version_a, version_b) ⇒ 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.
46 47 48 49 50 51 |
# File 'lib/puppet/util/package/version/pip.rb', line 46 def self.compare(version_a, version_b) version_a = parse(version_a) unless version_a.is_a?(self) version_b = parse(version_b) unless version_b.is_a?(self) version_a <=> version_b end |
.parse(version) ⇒ 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.
37 38 39 40 41 42 43 44 |
# File 'lib/puppet/util/package/version/pip.rb', line 37 def self.parse(version) raise ValidationFailure, version.to_s unless version.is_a? String matched = version.match(Regexp.new(("^\\s*") + VERSION_PATTERN + ("\\s*$"), Regexp::EXTENDED | Regexp::MULTILINE | Regexp::IGNORECASE)) raise ValidationFailure, version unless matched new(matched) 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.
72 73 74 75 |
# File 'lib/puppet/util/package/version/pip.rb', line 72 def <=>(other) raise ValidationFailure, other.to_s unless other.is_a?(self.class) compare(key, other.key) 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.
67 68 69 |
# File 'lib/puppet/util/package/version/pip.rb', line 67 def eql?(other) other.is_a?(self.class) && key.eql?(other.key) end |
#to_s ⇒ Object 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.
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/puppet/util/package/version/pip.rb', line 53 def to_s parts = [] parts.push("#{@epoch_data}!") if @epoch_data && @epoch_data != 0 parts.push(@release_data.join(".")) if @release_data parts.push(@pre_data.join) if @pre_data parts.push(".post#{@post_data[1]}") if @post_data parts.push(".dev#{@dev_data[1]}") if @dev_data parts.push("+#{@local_data.join(".")}") if @local_data parts.join end |