relaton-bib 1.2.2 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaton_bib.rb +16 -13
- data/lib/relaton_bib/hash_converter.rb +17 -6
- data/lib/relaton_bib/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: 2c556856365ed3b55dfead00fa129508a6d541aaa04fa96d4a37997761d77aaf
|
4
|
+
data.tar.gz: 1e819257d4ee84d00bd6a0634a6abbc91b19ed6d9854275c0b9c04db4bb43c1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a65cc8f9435f61a0313d744f3827a55a91e7ccb7edc1d143f318d38cb2fb07b7fa75b7cdb871133c631d4deee778ba1c552811b11aa4aec479370cfcbe28d87f
|
7
|
+
data.tar.gz: 3c105c0244fd7e2f3fbdca1a9fd0626560f9d6e5f754743ff23530311885f0fca8c31e70cfcaae1961cc0ee957908854063d2972390885bbe46a3beb8179d194
|
data/lib/relaton_bib.rb
CHANGED
@@ -10,24 +10,27 @@ module RelatonBib
|
|
10
10
|
class RequestError < StandardError; end
|
11
11
|
|
12
12
|
class << self
|
13
|
-
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
13
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
14
14
|
|
15
|
-
# @param date [String]
|
15
|
+
# @param date [String, Integer, Date]
|
16
16
|
# @return [Date, NilClass]
|
17
|
-
def parse_date(
|
18
|
-
if
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
def parse_date(date)
|
18
|
+
return date if date.is_a?(Date)
|
19
|
+
|
20
|
+
sdate = date.to_s
|
21
|
+
case sdate
|
22
|
+
when /(?<date>\w+\s\d{4})/ # February 2012
|
23
|
+
Date.strptime($~[:date], "%B %Y")
|
24
|
+
when /(?<date>\w+\s\d{1,2},\s\d{4})/ # February 11, 2012
|
25
|
+
Date.strptime($~[:date], "%B %d, %Y")
|
26
|
+
when /(?<date>\d{4}-\d{2}-\d{2})/ # 2012-02-11
|
27
|
+
Date.parse($~[:date])
|
28
|
+
when /(?<date>\d{4}-\d{2})/ # 2012-02
|
26
29
|
Date.strptime date, "%Y-%m"
|
27
|
-
|
30
|
+
when /(?<date>\d{4})/ then Date.strptime $~[:date], "%Y" # 2012
|
28
31
|
end
|
29
32
|
end
|
30
|
-
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
33
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
31
34
|
end
|
32
35
|
|
33
36
|
private
|
@@ -375,18 +375,29 @@ module RelatonBib
|
|
375
375
|
end
|
376
376
|
end
|
377
377
|
|
378
|
-
# rubocop:disable Metrics/AbcSize
|
379
|
-
|
380
378
|
# @param ret [Hash]
|
381
379
|
def validity_hash_to_bib(ret)
|
382
380
|
return unless ret[:validity]
|
383
381
|
|
384
|
-
|
385
|
-
|
386
|
-
|
382
|
+
b = parse_validity_time(ret[:validity], :begins)
|
383
|
+
e = parse_validity_time(ret[:validity], :ends)
|
384
|
+
r = parse_validity_time(ret[:validity], :revision)
|
387
385
|
ret[:validity] = Validity.new(begins: b, ends: e, revision: r)
|
388
386
|
end
|
389
|
-
|
387
|
+
|
388
|
+
def parse_validity_time(val, period)
|
389
|
+
t = val[period]&.to_s
|
390
|
+
return unless t
|
391
|
+
|
392
|
+
p = period == :ends ? -1 : 1
|
393
|
+
case t
|
394
|
+
when /^\d{4}$/
|
395
|
+
Date.new(t.to_i, p, p).to_time
|
396
|
+
when /^(?<year>\d{4})-(?<month>\d{1,2})$/
|
397
|
+
Date.new($~[:year].to_i, $~[:month].to_i, p).to_time
|
398
|
+
else Time.parse t
|
399
|
+
end
|
400
|
+
end
|
390
401
|
|
391
402
|
# @param ret [Hash]
|
392
403
|
def editorialgroup_hash_to_bib(ret)
|
data/lib/relaton_bib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-bib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|