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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ed8310a30556ecb2a4162a99f848fdb990c69cc
4
- data.tar.gz: 0ab681f3fa13d9c26157490d6de20be03595e63c
3
+ metadata.gz: be48eaad4a6cd07eb30ca4bb8fe47a2e91133a7c
4
+ data.tar.gz: ceb20dba52c27c606d3e41ae6c970304980e7cea
5
5
  SHA512:
6
- metadata.gz: c5e2062fc9b6ddc67bc2439c572cd6dd359bcf3ece870fbb09c4a3d294d075e588227c522273e276808507729834273becd1392cfd83c89a2839e6da4d4cd97c
7
- data.tar.gz: f708e10fd9ed4d1eb4f35abe5585dd0703aa633b931bff6f1a8a4ed730c140b46f071582fc34be1c04751a4824fe7bc926b1d2c111cacf1f6b89c00a7536246a
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]) unless split.empty?
50
- month = Integer(split[1]) if split.length > 1
51
- day = Integer(split[2]) if split.length > 2
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
@@ -4,5 +4,5 @@ module MetalArchives
4
4
  ##
5
5
  # MetalArchives API version
6
6
  #
7
- VERSION = '2.0.1'
7
+ VERSION = '2.0.2'
8
8
  end
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metal_archives
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Dejonckheere