naturalsorter 3.0.20 → 3.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/naturalsorter/version.rb +1 -1
- data/lib/version_tag_recognizer.rb +13 -1
- data/spec/naturalsorter/version_tag_recognizer_spec.rb +28 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab1f05afaca4d011db3ad1d1238b9669c330b48a16bbaa334be0f0b09bd53729
|
4
|
+
data.tar.gz: 34b3348f206adad23c86044180038c39d849d54bc0c072766b50cf882a4fe685
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 635bef8758a11ef53c8c8d876c0ce9e2e3d4326f0c52a4a868004daa4929a9844a98fc93cce882790a24f65b27cd399a5adc8da32879fa559fa0174c3d8fc4f8
|
7
|
+
data.tar.gz: 4fe4e73b1f4a819711c443e7cbaf259aca84705e869c9dd36985b1baa034ec0ca2eb0be4b25af175fb923bbc897c7ba39273865b2ce8f521e3ae5174f501ad70
|
@@ -24,12 +24,24 @@ class VersionTagRecognizer
|
|
24
24
|
return 1
|
25
25
|
end
|
26
26
|
|
27
|
+
def self.value_for_key( value )
|
28
|
+
return 0 if A_STABILITY_DEV.eql? value
|
29
|
+
return 2 if A_STABILITY_SNAPSHOT.eql? value
|
30
|
+
return 3 if A_STABILITY_ALPHA.eql? value
|
31
|
+
return 4 if A_STABILITY_BETA.eql? value
|
32
|
+
return 5 if A_STABILITY_RC.eql? value
|
33
|
+
return 6 if A_STABILITY_PRE.eql? value
|
34
|
+
return 10 if A_STABILITY_STABLE.eql? value
|
35
|
+
return 11 if A_STABILITY_PATCH.eql? value
|
36
|
+
return 1
|
37
|
+
end
|
38
|
+
|
27
39
|
def self.compare_tags( a, b)
|
28
40
|
a_val = self.value_for a
|
29
41
|
b_val = self.value_for b
|
30
42
|
return -1 if a_val < b_val
|
31
43
|
return 1 if a_val > b_val
|
32
|
-
return
|
44
|
+
return 0
|
33
45
|
end
|
34
46
|
|
35
47
|
def self.tagged? value
|
@@ -297,6 +297,31 @@ describe VersionTagRecognizer do
|
|
297
297
|
end
|
298
298
|
|
299
299
|
|
300
|
+
it "returns the right value for stable" do
|
301
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_STABLE)).to eql(10)
|
302
|
+
end
|
303
|
+
it "returns the right value for patch" do
|
304
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_PATCH)).to eql(11)
|
305
|
+
end
|
306
|
+
it "returns the right value for pre" do
|
307
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_PRE)).to eql(6)
|
308
|
+
end
|
309
|
+
it "returns the right value for rc" do
|
310
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_RC)).to eql(5)
|
311
|
+
end
|
312
|
+
it "returns the right value for beta" do
|
313
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_BETA)).to eql(4)
|
314
|
+
end
|
315
|
+
it "returns the right value for alpha" do
|
316
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_ALPHA)).to eql(3)
|
317
|
+
end
|
318
|
+
it "returns the right value for snapshot" do
|
319
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_SNAPSHOT)).to eql(2)
|
320
|
+
end
|
321
|
+
it "returns the right value for dev" do
|
322
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_DEV)).to eql(0)
|
323
|
+
end
|
324
|
+
|
300
325
|
|
301
326
|
it "returns compares right for alpha and beta" do
|
302
327
|
expect( VersionTagRecognizer.compare_tags("1.1.1-alpha", "1.1.1-beta")).to eql(-1)
|
@@ -334,6 +359,9 @@ describe VersionTagRecognizer do
|
|
334
359
|
it "does fit stability" do
|
335
360
|
expect( VersionTagRecognizer.does_it_fit_stability?( "2.2.1-BETA", "beta" )).to be_truthy
|
336
361
|
end
|
362
|
+
it "does fit stability" do
|
363
|
+
expect( VersionTagRecognizer.does_it_fit_stability?( "2.2.1-alpha", "beta" )).to be_falsey
|
364
|
+
end
|
337
365
|
it "does fit stability" do
|
338
366
|
expect( VersionTagRecognizer.does_it_fit_stability?( "2.2.x-dev", "dev" )).to be_truthy
|
339
367
|
end
|