Module: SemverDialects::Rpm::TokenPairComparison
- Included in:
- ReleaseTag, Version
- Defined in:
- lib/semver_dialects/rpm.rb
Overview
rubocop:todo Style/Documentation
Instance Method Summary collapse
-
#compare_token_pair(a, b) ⇒ Object
Token can be either alphabets, integers or tilde.
Instance Method Details
#compare_token_pair(a, b) ⇒ Object
Token can be either alphabets, integers or tilde. Caret is currently not supported. More details here gitlab.com/gitlab-org/gitlab/-/issues/428941#note_1882343489 Precedence: numeric token > string token > no token > tilda (~)
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/semver_dialects/rpm.rb', line 11 def compare_token_pair(a, b) # rubocop:todo Naming/MethodParameterName return 1 if a != '~' && b == '~' return -1 if a == '~' && b != '~' return 1 if !a.nil? && b.nil? return -1 if a.nil? && !b.nil? return 1 if a.is_a?(Integer) && b.is_a?(String) return -1 if a.is_a?(String) && b.is_a?(Integer) # Remaining scenario are tokens of the same type ie Integer or String. Use <=> to compare a <=> b end |