semver_dialects 3.4.2 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/semver_dialects/apk.rb +7 -7
- data/lib/semver_dialects/base_version.rb +4 -4
- data/lib/semver_dialects/boundary.rb +6 -6
- data/lib/semver_dialects/commands/check_version.rb +1 -1
- data/lib/semver_dialects/interval.rb +8 -6
- data/lib/semver_dialects/interval_parser.rb +3 -3
- data/lib/semver_dialects/interval_set.rb +1 -1
- data/lib/semver_dialects/interval_set_parser.rb +1 -1
- data/lib/semver_dialects/maven.rb +7 -4
- data/lib/semver_dialects/rpm.rb +9 -8
- data/lib/semver_dialects/semantic_version.rb +9 -9
- data/lib/semver_dialects/semver2.rb +14 -10
- data/lib/semver_dialects/version.rb +1 -1
- data/lib/semver_dialects.rb +17 -10
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12af4a8e1f6c11b5ae7ff80bd47fb58b28b6364f49bdcd37d65d8a30fb0af22a
|
4
|
+
data.tar.gz: 957a0026a4a436d5718fe473901460386ec3ddddbea1b8c00f357bbda84529ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a854f058b3a3910cdf116a38561689602e71c311e6373202857ae9d0dbeb107e87dabb16a00b3ddc63a82b74982dcc1999e779c4af9ecd1a480b5cf486b4da9
|
7
|
+
data.tar.gz: fd96abdf439f3cb239aab8527bc6124b8b0d7f0841755ee6ce0205b4d68901669ba55a311c26bcd10fa94a077ad3e94a5e3d1aa845b08ae14ef2b1844fd8bef2
|
data/lib/semver_dialects/apk.rb
CHANGED
@@ -13,7 +13,7 @@ module SemverDialects
|
|
13
13
|
|
14
14
|
attr_reader :tokens, :pre_release, :post_release, :revision
|
15
15
|
|
16
|
-
def initialize(tokens, pre_release: [], post_release: [], revision: [])
|
16
|
+
def initialize(tokens, pre_release: [], post_release: [], revision: []) # rubocop:todo Lint/MissingSuper
|
17
17
|
@tokens = tokens
|
18
18
|
@pre_release = pre_release
|
19
19
|
@post_release = post_release
|
@@ -51,7 +51,7 @@ module SemverDialects
|
|
51
51
|
|
52
52
|
# Token can be either integer or string
|
53
53
|
# Precedence: numeric token > string token > no token
|
54
|
-
def compare_token_pair(a, b)
|
54
|
+
def compare_token_pair(a, b) # rubocop:todo Naming/MethodParameterName
|
55
55
|
return 1 if !a.nil? && b.nil?
|
56
56
|
return -1 if a.nil? && !b.nil?
|
57
57
|
|
@@ -64,7 +64,7 @@ module SemverDialects
|
|
64
64
|
|
65
65
|
# Precedence: post-release > no release > pre-release
|
66
66
|
# https://wiki.alpinelinux.org/wiki/APKBUILD_Reference#pkgver
|
67
|
-
def compare_pre_release(a, b)
|
67
|
+
def compare_pre_release(a, b) # rubocop:todo Naming/MethodParameterName
|
68
68
|
return 0 if a.empty? && b.empty?
|
69
69
|
return -1 if !a.empty? && b.empty?
|
70
70
|
return 1 if a.empty? && !b.empty?
|
@@ -74,7 +74,7 @@ module SemverDialects
|
|
74
74
|
|
75
75
|
# Precedence: post-release > no release > pre-release
|
76
76
|
# https://wiki.alpinelinux.org/wiki/APKBUILD_Reference#pkgver
|
77
|
-
def compare_post_release(a, b)
|
77
|
+
def compare_post_release(a, b) # rubocop:todo Naming/MethodParameterName
|
78
78
|
return 0 if a.empty? && b.empty?
|
79
79
|
return 1 if !a.empty? && b.empty?
|
80
80
|
return -1 if a.empty? && !b.empty?
|
@@ -86,7 +86,7 @@ module SemverDialects
|
|
86
86
|
# Post-release precedence: cvs < svn < git < hg < p
|
87
87
|
# Precedence for releases with number eg alpha1:
|
88
88
|
# release without number < release with number
|
89
|
-
def compare_suffix(a, b, order)
|
89
|
+
def compare_suffix(a, b, order) # rubocop:todo Naming/MethodParameterName
|
90
90
|
a_suffix = order[a[0]]
|
91
91
|
b_suffix = order[b[0]]
|
92
92
|
|
@@ -102,7 +102,7 @@ module SemverDialects
|
|
102
102
|
(a_value || 0) <=> (b_value || 0)
|
103
103
|
end
|
104
104
|
|
105
|
-
def compare_revisions(a, b)
|
105
|
+
def compare_revisions(a, b) # rubocop:todo Naming/MethodParameterName
|
106
106
|
return 0 if a.empty? && b.empty?
|
107
107
|
return 1 if !a.empty? && b.empty?
|
108
108
|
return -1 if a.empty? && !b.empty?
|
@@ -117,7 +117,7 @@ module SemverDialects
|
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
-
class VersionParser
|
120
|
+
class VersionParser # rubocop:todo Style/Documentation
|
121
121
|
DASH = /-/
|
122
122
|
ALPHABETS = /([a-zA-Z]+)/
|
123
123
|
DIGITS = /([0-9]+)/
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# by implementing specific token classes.
|
19
19
|
#
|
20
20
|
module SemverDialects
|
21
|
-
class BaseVersion
|
21
|
+
class BaseVersion # rubocop:todo Style/Documentation
|
22
22
|
include Comparable
|
23
23
|
|
24
24
|
attr_reader :tokens, :addition
|
@@ -36,14 +36,14 @@ module SemverDialects
|
|
36
36
|
|
37
37
|
def <=>(other)
|
38
38
|
cmp = compare_tokens(tokens, other.tokens)
|
39
|
-
return cmp unless cmp
|
39
|
+
return cmp unless cmp.zero?
|
40
40
|
|
41
41
|
compare_additions(addition, other.addition)
|
42
42
|
end
|
43
43
|
|
44
44
|
# Returns true if the version tokens are equivalent to zero
|
45
45
|
# and the addition is also equivalent to zero.
|
46
|
-
def is_zero?
|
46
|
+
def is_zero? # rubocop:todo Naming/PredicateName
|
47
47
|
return false if compare_tokens(tokens, [0]) != 0
|
48
48
|
|
49
49
|
return true if addition.nil?
|
@@ -57,7 +57,7 @@ module SemverDialects
|
|
57
57
|
max_idx = [a.size, b.size].max - 1
|
58
58
|
(0..max_idx).each do |idx|
|
59
59
|
cmp = compare_token_pair(a[idx], b[idx])
|
60
|
-
return cmp unless cmp
|
60
|
+
return cmp unless cmp.zero?
|
61
61
|
end
|
62
62
|
0
|
63
63
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# It can either be above all versions (infinity),
|
5
5
|
# below all versions (negative infinity), or any version.
|
6
6
|
module SemverDialects
|
7
|
-
class Boundary
|
7
|
+
class Boundary # rubocop:todo Style/Documentation
|
8
8
|
include Comparable
|
9
9
|
|
10
10
|
attr_accessor :semver
|
@@ -25,7 +25,7 @@ module SemverDialects
|
|
25
25
|
semver <=> other.semver
|
26
26
|
end
|
27
27
|
|
28
|
-
def is_initial_version?
|
28
|
+
def is_initial_version? # rubocop:todo Naming/PredicateName
|
29
29
|
@semver.is_zero?
|
30
30
|
end
|
31
31
|
end
|
@@ -34,13 +34,13 @@ module SemverDialects
|
|
34
34
|
# When used as the lower boundary of an interval, any version
|
35
35
|
# that is smaller than the upper boundary is in the interval.
|
36
36
|
class BelowAll < Boundary
|
37
|
-
def initialize; end
|
37
|
+
def initialize; end # rubocop:todo Lint/MissingSuper
|
38
38
|
|
39
39
|
def to_s
|
40
40
|
'-inf'
|
41
41
|
end
|
42
42
|
|
43
|
-
def is_initial_version?
|
43
|
+
def is_initial_version? # rubocop:todo Naming/PredicateName
|
44
44
|
false
|
45
45
|
end
|
46
46
|
|
@@ -55,13 +55,13 @@ module SemverDialects
|
|
55
55
|
# When used as the upper boundary of an interval, any version
|
56
56
|
# that is greater than the lower boundary is in the interval.
|
57
57
|
class AboveAll < Boundary
|
58
|
-
def initialize; end
|
58
|
+
def initialize; end # rubocop:todo Lint/MissingSuper
|
59
59
|
|
60
60
|
def to_s
|
61
61
|
'+inf'
|
62
62
|
end
|
63
63
|
|
64
|
-
def is_initial_version?
|
64
|
+
def is_initial_version? # rubocop:todo Naming/PredicateName
|
65
65
|
false
|
66
66
|
end
|
67
67
|
|
@@ -7,7 +7,7 @@ module SemverDialects
|
|
7
7
|
module Commands
|
8
8
|
# The check version command implementation
|
9
9
|
class CheckVersion < SemverDialects::Command
|
10
|
-
def initialize(type, version, constraint, options)
|
10
|
+
def initialize(type, version, constraint, options) # rubocop:todo Lint/MissingSuper
|
11
11
|
@type = type
|
12
12
|
@version = version
|
13
13
|
@constraint = constraint
|
@@ -32,7 +32,7 @@ module SemverDialects
|
|
32
32
|
|
33
33
|
# this look odd -- we have to use it here though, because it may be that placeholders are present inside
|
34
34
|
# the version for which > and < would yield true
|
35
|
-
return EmptyInterval.new if
|
35
|
+
return EmptyInterval.new if @start_cut > other_interval.end_cut || other_interval.start_cut > @end_cut
|
36
36
|
|
37
37
|
start_cut_new = max(@start_cut, other_interval.start_cut)
|
38
38
|
end_cut_new = min(@end_cut, other_interval.end_cut)
|
@@ -123,7 +123,9 @@ module SemverDialects
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def universal?
|
126
|
-
(bit_set?(IntervalType::LEFT_OPEN) && bit_set?(IntervalType::RIGHT_OPEN) &&
|
126
|
+
(bit_set?(IntervalType::LEFT_OPEN) && bit_set?(IntervalType::RIGHT_OPEN) &&
|
127
|
+
@start_cut.instance_of?(BelowAll) && @end_cut.instance_of?(AboveAll)) ||
|
128
|
+
@start_cut.is_initial_version? && @end_cut.instance_of?(AboveAll)
|
127
129
|
end
|
128
130
|
|
129
131
|
def to_gem_s
|
@@ -181,7 +183,7 @@ module SemverDialects
|
|
181
183
|
IntervalType::RIGHT_OPEN)
|
182
184
|
end
|
183
185
|
|
184
|
-
def compute_boundary(interval_a, interval_b, start_cut_new, end_cut_new, left_check, right_check)
|
186
|
+
def compute_boundary(interval_a, interval_b, start_cut_new, end_cut_new, left_check, right_check) # rubocop:disable Metrics/ParameterLists
|
185
187
|
start_cut_a = interval_a.start_cut
|
186
188
|
end_cut_a = interval_a.end_cut
|
187
189
|
type_a = interval_a.type
|
@@ -211,7 +213,7 @@ module SemverDialects
|
|
211
213
|
left_type | right_type
|
212
214
|
end
|
213
215
|
|
214
|
-
def get_canoncial_s(delimiter = ' ', eq = '=')
|
216
|
+
def get_canoncial_s(delimiter = ' ', eq = '=') # rubocop:todo Naming/MethodParameterName
|
215
217
|
if distinct?
|
216
218
|
"#{eq}#{@start_cut}"
|
217
219
|
else
|
@@ -250,8 +252,8 @@ module SemverDialects
|
|
250
252
|
end
|
251
253
|
end
|
252
254
|
|
253
|
-
class EmptyInterval < Interval
|
254
|
-
def initialize; end
|
255
|
+
class EmptyInterval < Interval # rubocop:todo Style/Documentation
|
256
|
+
def initialize; end # rubocop:todo Lint/MissingSuper
|
255
257
|
|
256
258
|
def to_s
|
257
259
|
'empty'
|
@@ -15,9 +15,9 @@
|
|
15
15
|
# that's been detected.
|
16
16
|
#
|
17
17
|
module SemverDialects
|
18
|
-
module IntervalParser
|
19
|
-
#
|
20
|
-
#
|
18
|
+
module IntervalParser # rubocop:todo Style/Documentation
|
19
|
+
# Version string validation is only validated not to be white space.
|
20
|
+
# All other version validation is delegated to the version parsers.
|
21
21
|
CONSTRAINT_REGEXP = Regexp.new('(?<op>[><=]+)\s*(?<version>[^\s]+)').freeze
|
22
22
|
|
23
23
|
def self.parse(typ, versionstring)
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# It can express a range like "[1.0,2.0],[3.0,4.0]" (Maven syntax),
|
5
5
|
# that is between 1.0 and 2.0 (included) OR between 3.0 and 4.0 (included).
|
6
6
|
module SemverDialects
|
7
|
-
class IntervalSet
|
7
|
+
class IntervalSet # rubocop:todo Style/Documentation
|
8
8
|
attr_reader :intervals
|
9
9
|
|
10
10
|
def initialize
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# IntervalSetParser parses a string that represents an interval set
|
4
4
|
# in a syntax that's specific to a package type.
|
5
5
|
module SemverDialects
|
6
|
-
module IntervalSetParser
|
6
|
+
module IntervalSetParser # rubocop:todo Style/Documentation
|
7
7
|
# parse parses a string and returns an IntervalSet.
|
8
8
|
# The string is expected to be in a syntax that's specific the given package type.
|
9
9
|
def self.parse(typ, interval_set_string)
|
@@ -11,7 +11,7 @@ module SemverDialects
|
|
11
11
|
SNAPSHOT = -1
|
12
12
|
SP = 'sp'
|
13
13
|
|
14
|
-
class Version < BaseVersion
|
14
|
+
class Version < BaseVersion # rubocop:todo Style/Documentation
|
15
15
|
attr_accessor :addition
|
16
16
|
|
17
17
|
# Return an array similar to the one Maven generates when parsing versions.
|
@@ -26,7 +26,7 @@ module SemverDialects
|
|
26
26
|
tokens.clone.append(addition.to_a)
|
27
27
|
end
|
28
28
|
|
29
|
-
def to_s(as_addition = false)
|
29
|
+
def to_s(as_addition = false) # rubocop:disable Style/OptionalBooleanParameter
|
30
30
|
s = ''
|
31
31
|
if tokens.any?
|
32
32
|
s += '-' if as_addition
|
@@ -63,7 +63,7 @@ module SemverDialects
|
|
63
63
|
# Special qualifier "sp" is right after GA and before any lexical or numeric token.
|
64
64
|
# Strings should be converted to lower case before being compared by this method.
|
65
65
|
# 1-a0 == 1-alpha < 1-0 == 1 == 1final == 1 ga < 1sp < 1-a < 1-1
|
66
|
-
def compare_token_pair(a = 0, b = 0)
|
66
|
+
def compare_token_pair(a = 0, b = 0) # rubocop:todo Naming/MethodParameterName
|
67
67
|
a ||= 0
|
68
68
|
b ||= 0
|
69
69
|
|
@@ -89,7 +89,7 @@ module SemverDialects
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
class VersionParser
|
92
|
+
class VersionParser # rubocop:todo Style/Documentation
|
93
93
|
def self.parse(input)
|
94
94
|
new(input).parse
|
95
95
|
end
|
@@ -105,6 +105,9 @@ module SemverDialects
|
|
105
105
|
@version = Version.new([])
|
106
106
|
@result = @version
|
107
107
|
parse_version(false)
|
108
|
+
|
109
|
+
raise InvalidVersionError, input if @result.to_a.empty?
|
110
|
+
|
108
111
|
result
|
109
112
|
end
|
110
113
|
|
data/lib/semver_dialects/rpm.rb
CHANGED
@@ -4,11 +4,11 @@ require 'strscan'
|
|
4
4
|
|
5
5
|
module SemverDialects
|
6
6
|
module Rpm
|
7
|
-
module TokenPairComparison
|
7
|
+
module TokenPairComparison # rubocop:todo Style/Documentation
|
8
8
|
# Token can be either alphabets, integers or tilde.
|
9
9
|
# Caret is currently not supported. More details here https://gitlab.com/gitlab-org/gitlab/-/issues/428941#note_1882343489
|
10
10
|
# Precedence: numeric token > string token > no token > tilda (~)
|
11
|
-
def compare_token_pair(a, b)
|
11
|
+
def compare_token_pair(a, b) # rubocop:todo Naming/MethodParameterName
|
12
12
|
return 1 if a != '~' && b == '~'
|
13
13
|
return -1 if a == '~' && b != '~'
|
14
14
|
|
@@ -24,7 +24,8 @@ module SemverDialects
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# This implementation references `go-rpm-version` https://github.com/knqyf263/go-rpm-version
|
27
|
-
# Which is based on the official `rpmvercmp`
|
27
|
+
# Which is based on the official `rpmvercmp`
|
28
|
+
# https://github.com/rpm-software-management/rpm/blob/master/rpmio/rpmvercmp.c implementation
|
28
29
|
# rpm versioning schema can be found here https://github.com/rpm-software-management/rpm/blob/master/docs/manual/dependencies.md#versioning
|
29
30
|
# Details on how the caret and tilde symbols are handled can be found here https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/#_handling_non_sorting_versions_with_tilde_dot_and_caret
|
30
31
|
class Version < BaseVersion
|
@@ -32,7 +33,7 @@ module SemverDialects
|
|
32
33
|
|
33
34
|
attr_reader :tokens, :addition, :epoch
|
34
35
|
|
35
|
-
def initialize(tokens, epoch: nil, release_tag: nil)
|
36
|
+
def initialize(tokens, epoch: nil, release_tag: nil) # rubocop:todo Lint/MissingSuper
|
36
37
|
@tokens = tokens
|
37
38
|
@addition = release_tag
|
38
39
|
@epoch = epoch
|
@@ -67,20 +68,20 @@ module SemverDialects
|
|
67
68
|
|
68
69
|
private
|
69
70
|
|
70
|
-
def compare_epochs(a, b)
|
71
|
+
def compare_epochs(a, b) # rubocop:todo Naming/MethodParameterName
|
71
72
|
(a || 0) <=> (b || 0)
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
75
|
-
class ReleaseTag < BaseVersion
|
76
|
+
class ReleaseTag < BaseVersion # rubocop:todo Style/Documentation
|
76
77
|
include TokenPairComparison
|
77
78
|
|
78
|
-
def initialize(tokens)
|
79
|
+
def initialize(tokens) # rubocop:todo Lint/MissingSuper
|
79
80
|
@tokens = tokens
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
83
|
-
class VersionParser
|
84
|
+
class VersionParser # rubocop:todo Style/Documentation
|
84
85
|
DASH = /-/
|
85
86
|
ALPHABET = /([a-zA-Z]+)/
|
86
87
|
TILDE = /~/
|
@@ -57,7 +57,7 @@ module SemverDialects
|
|
57
57
|
prefix_delimiter -= 1
|
58
58
|
end
|
59
59
|
|
60
|
-
unless prefix_delimiter
|
60
|
+
unless prefix_delimiter.negative?
|
61
61
|
@prefix_segments = split_array[0..prefix_delimiter].map do |group_string|
|
62
62
|
SemanticVersionSegment.new(group_string)
|
63
63
|
end
|
@@ -96,7 +96,7 @@ module SemverDialects
|
|
96
96
|
[first_array_prefix.concat(first_array_suffix), second_array_prefix.concat(second_array_suffix)]
|
97
97
|
end
|
98
98
|
|
99
|
-
def is_zero?
|
99
|
+
def is_zero? # rubocop:todo Naming/PredicateName
|
100
100
|
@prefix_segments.empty? || @prefix_segments.all?(&:is_zero?)
|
101
101
|
end
|
102
102
|
|
@@ -143,12 +143,12 @@ module SemverDialects
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
-
class SemanticVersionSegment
|
146
|
+
class SemanticVersionSegment # rubocop:todo Style/Documentation
|
147
147
|
include Comparable
|
148
148
|
|
149
149
|
attr_accessor :normalized_group_string, :original_group_string, :is_post_release, :is_pre_release
|
150
150
|
|
151
|
-
@@group_suffixes = {
|
151
|
+
@@group_suffixes = { # rubocop:todo Style/ClassVars
|
152
152
|
# pre-releases
|
153
153
|
'PRE' => -16,
|
154
154
|
'PREVIEW' => -16,
|
@@ -180,8 +180,8 @@ module SemverDialects
|
|
180
180
|
|
181
181
|
if @@group_suffixes.key?(group_string_ucase)
|
182
182
|
value = @@group_suffixes[group_string_ucase]
|
183
|
-
@is_post_release = value
|
184
|
-
@is_pre_release = value
|
183
|
+
@is_post_release = value.positive?
|
184
|
+
@is_pre_release = value.negative?
|
185
185
|
@normalized_group_string = @@group_suffixes[group_string_ucase].to_s
|
186
186
|
else
|
187
187
|
@normalized_group_string = group_string_ucase
|
@@ -224,12 +224,12 @@ module SemverDialects
|
|
224
224
|
normalized_group_string == 'X'
|
225
225
|
end
|
226
226
|
|
227
|
-
def is_number?
|
227
|
+
def is_number? # rubocop:todo Naming/PredicateName
|
228
228
|
normalized_group_string.number?
|
229
229
|
end
|
230
230
|
|
231
|
-
def is_zero?
|
232
|
-
is_number? ? normalized_group_string.to_i
|
231
|
+
def is_zero? # rubocop:todo Naming/PredicateName
|
232
|
+
is_number? ? normalized_group_string.to_i.zero? : false
|
233
233
|
end
|
234
234
|
end
|
235
235
|
end
|
@@ -7,8 +7,8 @@ module SemverDialects
|
|
7
7
|
# Represents a token that matches any major, minor, or patch number.
|
8
8
|
ANY_NUMBER = 'x'
|
9
9
|
|
10
|
-
class Version < BaseVersion
|
11
|
-
def initialize(tokens, prerelease_tag: nil)
|
10
|
+
class Version < BaseVersion # rubocop:todo Style/Documentation
|
11
|
+
def initialize(tokens, prerelease_tag: nil) # rubocop:todo Lint/MissingSuper
|
12
12
|
@tokens = tokens
|
13
13
|
@addition = prerelease_tag
|
14
14
|
end
|
@@ -41,14 +41,14 @@ module SemverDialects
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
class PrereleaseTag < BaseVersion
|
45
|
-
def initialize(tokens)
|
44
|
+
class PrereleaseTag < BaseVersion # rubocop:todo Style/Documentation
|
45
|
+
def initialize(tokens) # rubocop:todo Lint/MissingSuper
|
46
46
|
@tokens = tokens
|
47
47
|
end
|
48
48
|
|
49
49
|
# Returns true if the prerelease tag is empty.
|
50
50
|
# In Semver 2 1.2.3-0 is NOT equivalent to 1.2.3.
|
51
|
-
def is_zero?
|
51
|
+
def is_zero? # rubocop:todo Naming/PredicateName
|
52
52
|
tokens.empty?
|
53
53
|
end
|
54
54
|
|
@@ -63,7 +63,8 @@ module SemverDialects
|
|
63
63
|
# Numeric identifiers always have lower precedence than non-numeric identifiers.
|
64
64
|
return -1
|
65
65
|
when nil
|
66
|
-
# A larger set of pre-release fields has a higher precedence than a smaller set,
|
66
|
+
# A larger set of pre-release fields has a higher precedence than a smaller set,
|
67
|
+
# if all of the preceding identifiers are equal.
|
67
68
|
return 1
|
68
69
|
end
|
69
70
|
when String
|
@@ -72,16 +73,19 @@ module SemverDialects
|
|
72
73
|
# Numeric identifiers always have lower precedence than non-numeric identifiers.
|
73
74
|
return 1
|
74
75
|
when nil
|
75
|
-
# A larger set of pre-release fields has a higher precedence than a smaller set,
|
76
|
+
# A larger set of pre-release fields has a higher precedence than a smaller set,
|
77
|
+
# if all of the preceding identifiers are equal.
|
76
78
|
return 1
|
77
79
|
end
|
78
80
|
when nil
|
79
81
|
case b
|
80
82
|
when Integer
|
81
|
-
# A larger set of pre-release fields has a higher precedence than a smaller set,
|
83
|
+
# A larger set of pre-release fields has a higher precedence than a smaller set,
|
84
|
+
# if all of the preceding identifiers are equal.
|
82
85
|
return -1
|
83
86
|
when String
|
84
|
-
# A larger set of pre-release fields has a higher precedence than a smaller set,
|
87
|
+
# A larger set of pre-release fields has a higher precedence than a smaller set,
|
88
|
+
# if all of the preceding identifiers are equal.
|
85
89
|
return -1
|
86
90
|
end
|
87
91
|
end
|
@@ -91,7 +95,7 @@ module SemverDialects
|
|
91
95
|
end
|
92
96
|
end
|
93
97
|
|
94
|
-
class VersionParser
|
98
|
+
class VersionParser # rubocop:todo Style/Documentation
|
95
99
|
def self.parse(input)
|
96
100
|
new(input).parse
|
97
101
|
end
|
data/lib/semver_dialects.rb
CHANGED
@@ -14,23 +14,25 @@ require 'semver_dialects/interval_set'
|
|
14
14
|
require 'semver_dialects/interval_set_parser'
|
15
15
|
require 'deb_version'
|
16
16
|
|
17
|
-
module SemverDialects
|
17
|
+
module SemverDialects # rubocop:todo Style/Documentation
|
18
18
|
# Captures all errors that could be possibly raised
|
19
19
|
class Error < StandardError
|
20
20
|
end
|
21
21
|
|
22
|
-
class UnsupportedPackageTypeError < Error
|
23
|
-
def initialize(
|
24
|
-
|
22
|
+
class UnsupportedPackageTypeError < Error # rubocop:todo Style/Documentation
|
23
|
+
def initialize(pkg_type)
|
24
|
+
super
|
25
|
+
@pkg_type = pkg_type
|
25
26
|
end
|
26
27
|
|
27
28
|
def message
|
28
|
-
"unsupported package type '#{@
|
29
|
+
"unsupported package type '#{@pkg_type}'"
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
|
-
class UnsupportedVersionError < Error
|
33
|
+
class UnsupportedVersionError < Error # rubocop:todo Style/Documentation
|
33
34
|
def initialize(raw_version)
|
35
|
+
super
|
34
36
|
@raw_version = raw_version
|
35
37
|
end
|
36
38
|
|
@@ -39,8 +41,9 @@ module SemverDialects
|
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
42
|
-
class InvalidVersionError < Error
|
44
|
+
class InvalidVersionError < Error # rubocop:todo Style/Documentation
|
43
45
|
def initialize(raw_version)
|
46
|
+
super
|
44
47
|
@raw_version = raw_version
|
45
48
|
end
|
46
49
|
|
@@ -49,8 +52,9 @@ module SemverDialects
|
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
52
|
-
class InvalidConstraintError < Error
|
55
|
+
class InvalidConstraintError < Error # rubocop:todo Style/Documentation
|
53
56
|
def initialize(raw_constraint)
|
57
|
+
super
|
54
58
|
@raw_constraint = raw_constraint
|
55
59
|
end
|
56
60
|
|
@@ -59,10 +63,11 @@ module SemverDialects
|
|
59
63
|
end
|
60
64
|
end
|
61
65
|
|
62
|
-
class IncompleteScanError < InvalidVersionError
|
66
|
+
class IncompleteScanError < InvalidVersionError # rubocop:todo Style/Documentation
|
63
67
|
attr_reader :rest
|
64
68
|
|
65
69
|
def initialize(rest)
|
70
|
+
super
|
66
71
|
@rest = rest
|
67
72
|
end
|
68
73
|
|
@@ -128,7 +133,9 @@ module SemverDialects
|
|
128
133
|
#
|
129
134
|
# quoting https://go.dev/ref/mod#pseudo-versions
|
130
135
|
#
|
131
|
-
# Each pseudo-version may be in one of three forms, depending on the base version.
|
136
|
+
# Each pseudo-version may be in one of three forms, depending on the base version.
|
137
|
+
# These forms ensure that a pseudo-version compares higher than its base version,
|
138
|
+
# but lower than the next tagged version.
|
132
139
|
#
|
133
140
|
|
134
141
|
# vX.0.0-yyyymmddhhmmss-abcdefabcdef is used when there is no known
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: semver_dialects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Thome
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-08-
|
13
|
+
date: 2024-08-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pastel
|
@@ -68,6 +68,20 @@ dependencies:
|
|
68
68
|
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: 0.10.1
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: unparser
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.6.13
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 0.6.13
|
71
85
|
- !ruby/object:Gem::Dependency
|
72
86
|
name: benchmark-ips
|
73
87
|
requirement: !ruby/object:Gem::Requirement
|
@@ -209,7 +223,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
223
|
requirements:
|
210
224
|
- - ">="
|
211
225
|
- !ruby/object:Gem::Version
|
212
|
-
version: '0'
|
226
|
+
version: '3.0'
|
213
227
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
228
|
requirements:
|
215
229
|
- - ">="
|