metal_archives 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metal_archives/utils/nil_date.rb +8 -3
- data/lib/metal_archives/version.rb +1 -1
- data/spec/utils/nil_date_spec.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be48eaad4a6cd07eb30ca4bb8fe47a2e91133a7c
|
4
|
+
data.tar.gz: ceb20dba52c27c606d3e41ae6c970304980e7cea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 227e05ac3f34011a196a7ca11e755b83acef9f2c90d4a8e2510baf19cf67c2aa01c0efcadc12fb97dbede1ba84ba074c92fcf0fb6f396af6aa0d293f07785c82
|
7
|
+
data.tar.gz: 0351352e817f0f6300b52e9289b7237474071669d02c16e24f4a12965498f81838da2f224b1235af00e991a17b57abdaf30c6535d6800d3aea409e866730ae5d
|
@@ -46,9 +46,14 @@ module MetalArchives
|
|
46
46
|
def self.parse(value)
|
47
47
|
split = value.split('-')
|
48
48
|
|
49
|
-
year = Integer(split[0])
|
50
|
-
|
51
|
-
|
49
|
+
year = Integer(split[0], 10) if split.any? && split[0] && !split[0].empty?
|
50
|
+
year = nil if year == 0
|
51
|
+
|
52
|
+
month = Integer(split[1], 10) if split.length > 1 && split[1] && !split[1].empty?
|
53
|
+
month = nil if month == 0
|
54
|
+
|
55
|
+
day = Integer(split[2], 10) if split.length > 2 && split[2] && !split[2].empty?
|
56
|
+
day = nil if day == 0
|
52
57
|
|
53
58
|
return MetalArchives::NilDate.new year, month, day
|
54
59
|
rescue => e
|
data/spec/utils/nil_date_spec.rb
CHANGED
@@ -78,6 +78,14 @@ RSpec.describe MetalArchives::NilDate do
|
|
78
78
|
expect(date.day?).to be false
|
79
79
|
end
|
80
80
|
|
81
|
+
it 'parses dates with leading zeroes' do
|
82
|
+
date = described_class.parse '2017-01-00'
|
83
|
+
|
84
|
+
expect(date.year).to eq 2017
|
85
|
+
expect(date.month).to eq 1
|
86
|
+
expect(date.day).to eq nil
|
87
|
+
end
|
88
|
+
|
81
89
|
it 'parses full dates' do
|
82
90
|
date = described_class.parse '2012-10-02'
|
83
91
|
|