semver_dialects 4.1.0 → 4.1.1
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/interval_set.rb +2 -4
- data/lib/semver_dialects/semantic_version.rb +49 -24
- data/lib/semver_dialects/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 547533257e61f2d3583e6b05b4ee56838087402a17f37fa996bea21f23cb3087
|
|
4
|
+
data.tar.gz: 9015fd687eec1c51c1c600ab4ebb9a0af6f16225e1f958b5ed724efb41e3c992
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1a8ab53f0556a1b4b5cdb13858726b3f8512ed0bfb2eb8e35b2595f6ea95ab4f0b9ae4041d14a89031126e4c9e9bf8f7411c925ab5bb1cbec53ecd879fadb7e
|
|
7
|
+
data.tar.gz: d80dc382f3658bb791eae032fdf7ffa9daf721575aeb0986ddda438f844f1cd6fa5f16fb2ed003aeac749dde6e0dba219b581968d6f6b96c6fd4955c204aa291
|
|
@@ -9,12 +9,10 @@ module SemverDialects
|
|
|
9
9
|
|
|
10
10
|
def initialize
|
|
11
11
|
@intervals = []
|
|
12
|
-
@interval_set = Set.new
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
def add(interval)
|
|
16
15
|
@intervals << interval
|
|
17
|
-
@interval_set.add(interval)
|
|
18
16
|
end
|
|
19
17
|
|
|
20
18
|
def <<(item)
|
|
@@ -101,11 +99,11 @@ module SemverDialects
|
|
|
101
99
|
end
|
|
102
100
|
|
|
103
101
|
def includes?(other)
|
|
104
|
-
@
|
|
102
|
+
@intervals.include?(other)
|
|
105
103
|
end
|
|
106
104
|
|
|
107
105
|
def overlaps_with?(other)
|
|
108
|
-
@
|
|
106
|
+
@intervals.each do |interval|
|
|
109
107
|
return true unless interval.intersect(other).instance_of?(EmptyInterval)
|
|
110
108
|
end
|
|
111
109
|
false
|
|
@@ -108,18 +108,19 @@ module SemverDialects
|
|
|
108
108
|
@suffix_segments.any?(&:is_post_release)
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
+
WILDCARD_HIT = :__wildcard_hit__
|
|
112
|
+
|
|
111
113
|
def <=>(other)
|
|
112
114
|
return nil unless other.is_a?(SemanticVersion)
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return 0 if a.wildcard? || b.wildcard?
|
|
116
|
+
cmp = compare_segments(@prefix_segments, other.prefix_segments)
|
|
117
|
+
return 0 if cmp.equal?(WILDCARD_HIT)
|
|
118
|
+
return cmp unless cmp.zero?
|
|
118
119
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
cmp = compare_segments(@suffix_segments, other.suffix_segments)
|
|
121
|
+
return 0 if cmp.equal?(WILDCARD_HIT)
|
|
122
|
+
|
|
123
|
+
cmp
|
|
123
124
|
end
|
|
124
125
|
|
|
125
126
|
def to_normalized_s
|
|
@@ -141,6 +142,25 @@ module SemverDialects
|
|
|
141
142
|
def patch
|
|
142
143
|
@prefix_segments.size >= 3 ? @prefix_segments[2].to_s : '0'
|
|
143
144
|
end
|
|
145
|
+
|
|
146
|
+
private
|
|
147
|
+
|
|
148
|
+
def compare_segments(a, b) # rubocop:disable Naming/MethodParameterName
|
|
149
|
+
zero = SemverDialects::ZERO_SEGMENT
|
|
150
|
+
len = a.size > b.size ? a.size : b.size
|
|
151
|
+
i = 0
|
|
152
|
+
while i < len
|
|
153
|
+
seg_a = i < a.size ? a[i] : zero
|
|
154
|
+
seg_b = i < b.size ? b[i] : zero
|
|
155
|
+
return WILDCARD_HIT if seg_a.wildcard? || seg_b.wildcard?
|
|
156
|
+
|
|
157
|
+
cmp = seg_a <=> seg_b
|
|
158
|
+
return cmp if cmp != 0
|
|
159
|
+
|
|
160
|
+
i += 1
|
|
161
|
+
end
|
|
162
|
+
0
|
|
163
|
+
end
|
|
144
164
|
end
|
|
145
165
|
|
|
146
166
|
class SemanticVersionSegment # rubocop:todo Style/Documentation
|
|
@@ -186,32 +206,35 @@ module SemverDialects
|
|
|
186
206
|
else
|
|
187
207
|
@normalized_group_string = group_string_ucase
|
|
188
208
|
end
|
|
209
|
+
|
|
210
|
+
parsed = Integer(@normalized_group_string, exception: false)
|
|
211
|
+
@numeric_value = parsed
|
|
212
|
+
@is_numeric = !parsed.nil?
|
|
213
|
+
@is_wildcard = @normalized_group_string == 'X'
|
|
189
214
|
end
|
|
190
215
|
|
|
191
216
|
def <=>(other)
|
|
192
217
|
return nil unless other.is_a?(SemanticVersionSegment)
|
|
193
218
|
|
|
194
|
-
|
|
195
|
-
other_semver = other.normalized_group_string
|
|
219
|
+
return 0 if @is_wildcard || other.wildcard?
|
|
196
220
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
a_numeric_b_non_numeric = self_semver.number? && !other_semver.number?
|
|
200
|
-
b_numeric_a_non_numeric = other_semver.number? && !self_semver.number?
|
|
221
|
+
if @is_numeric
|
|
222
|
+
return @numeric_value <=> other.numeric_value if other.numeric?
|
|
201
223
|
|
|
202
|
-
if both_are_numbers
|
|
203
|
-
self_semver.to_i <=> other_semver.to_i
|
|
204
|
-
elsif at_least_one_is_x
|
|
205
|
-
0
|
|
206
|
-
elsif a_numeric_b_non_numeric
|
|
207
224
|
-1
|
|
208
|
-
elsif
|
|
225
|
+
elsif other.numeric?
|
|
209
226
|
1
|
|
210
227
|
else
|
|
211
|
-
|
|
228
|
+
@normalized_group_string <=> other.normalized_group_string
|
|
212
229
|
end
|
|
213
230
|
end
|
|
214
231
|
|
|
232
|
+
attr_reader :numeric_value
|
|
233
|
+
|
|
234
|
+
def numeric?
|
|
235
|
+
@is_numeric
|
|
236
|
+
end
|
|
237
|
+
|
|
215
238
|
def to_normalized_s
|
|
216
239
|
@normalized_group_string
|
|
217
240
|
end
|
|
@@ -221,15 +244,17 @@ module SemverDialects
|
|
|
221
244
|
end
|
|
222
245
|
|
|
223
246
|
def wildcard?
|
|
224
|
-
|
|
247
|
+
@is_wildcard
|
|
225
248
|
end
|
|
226
249
|
|
|
227
250
|
def is_number? # rubocop:todo Naming/PredicateName
|
|
228
|
-
|
|
251
|
+
@is_numeric
|
|
229
252
|
end
|
|
230
253
|
|
|
231
254
|
def is_zero? # rubocop:todo Naming/PredicateName
|
|
232
|
-
|
|
255
|
+
@is_numeric && @numeric_value.zero?
|
|
233
256
|
end
|
|
234
257
|
end
|
|
258
|
+
|
|
259
|
+
ZERO_SEGMENT = SemanticVersionSegment.new('0').freeze
|
|
235
260
|
end
|
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: 4.1.
|
|
4
|
+
version: 4.1.1
|
|
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: 2026-
|
|
13
|
+
date: 2026-06-09 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: pastel
|