Class: SemverDialects::Rpm::Version
- Inherits:
-
BaseVersion
- Object
- BaseVersion
- SemverDialects::Rpm::Version
- Includes:
- TokenPairComparison
- Defined in:
- lib/semver_dialects/rpm.rb
Overview
This implementation references ‘go-rpm-version` github.com/knqyf263/go-rpm-version Which is based on the official `rpmvercmp` github.com/rpm-software-management/rpm/blob/master/rpmio/rpmvercmp.c implementation rpm versioning schema can be found here github.com/rpm-software-management/rpm/blob/master/docs/manual/dependencies.md#versioning Details on how the caret and tilde symbols are handled can be found here docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/#_handling_non_sorting_versions_with_tilde_dot_and_caret
Instance Attribute Summary collapse
-
#addition ⇒ Object
readonly
Returns the value of attribute addition.
-
#epoch ⇒ Object
readonly
Returns the value of attribute epoch.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(tokens, epoch: nil, release_tag: nil) ⇒ Version
constructor
rubocop:todo Lint/MissingSuper.
-
#to_s ⇒ Object
Note that to_s does not accurately recreate the version string.
Methods included from TokenPairComparison
Methods inherited from BaseVersion
Constructor Details
#initialize(tokens, epoch: nil, release_tag: nil) ⇒ Version
rubocop:todo Lint/MissingSuper
36 37 38 39 40 |
# File 'lib/semver_dialects/rpm.rb', line 36 def initialize(tokens, epoch: nil, release_tag: nil) # rubocop:todo Lint/MissingSuper @tokens = tokens @addition = release_tag @epoch = epoch end |
Instance Attribute Details
#addition ⇒ Object (readonly)
Returns the value of attribute addition.
34 35 36 |
# File 'lib/semver_dialects/rpm.rb', line 34 def addition @addition end |
#epoch ⇒ Object (readonly)
Returns the value of attribute epoch.
34 35 36 |
# File 'lib/semver_dialects/rpm.rb', line 34 def epoch @epoch end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
34 35 36 |
# File 'lib/semver_dialects/rpm.rb', line 34 def tokens @tokens end |
Instance Method Details
#<=>(other) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/semver_dialects/rpm.rb', line 42 def <=>(other) # Compare epoch first epoch_cmp = compare_epochs(epoch, other.epoch) return epoch_cmp unless epoch_cmp.zero? # Then compare version cmp = compare_tokens(tokens, other.tokens) return cmp unless cmp.zero? # And finally compare release tags compare_additions(addition, other.addition) end |
#to_s ⇒ Object
Note that to_s does not accurately recreate the version string. More details here gitlab.com/gitlab-org/gitlab/-/issues/428941#note_1882343489
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/semver_dialects/rpm.rb', line 57 def to_s main = if !epoch.nil? "#{epoch}:" + tokens.join('.') else tokens.join('.') end main += "-#{addition.tokens.join('.')}" unless addition.nil? # Remove . around ~ main.gsub(/\.~\./, '~') end |