relaton-bib 1.6.0 → 1.6.1
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 +1 -1
- data/lib/relaton_bib/bibliographic_date.rb +13 -10
- 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: e1acb1bee569016f446bebcaeac0a98d1491d19be9a87dbd072cabec368c1aea
|
4
|
+
data.tar.gz: 48897d74a02ea1fe1d2578ac8fbe9f6bd89d1f0fb47b19000f75dbc7697caac7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef1c0e62f60371c2416af0d0436165ba187d95004a2b8e6401b0c56ac98c0a4a4d1a75a4ec44f65bc5c50130e38d453107bbc370c291c23697efb8aae5f1c422
|
7
|
+
data.tar.gz: 2c7a9ccf203fe180282339700b580b575db35ce712901784b3c0e72005279561ad0e9218202b2d4f1a9ed609fc9118412a1ae9a7919fb913015efae150e2eeb1
|
data/lib/relaton_bib.rb
CHANGED
@@ -15,7 +15,7 @@ module RelatonBib
|
|
15
15
|
# @param date [String, Integer, Date]
|
16
16
|
# @param str [Boolean]
|
17
17
|
# @return [Date, nil]
|
18
|
-
def parse_date(date, str = true) # rubocop:disable Metrics/CyclomaticComplexity,
|
18
|
+
def parse_date(date, str = true) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity,Metrics/AbcSize
|
19
19
|
return date if date.is_a?(Date)
|
20
20
|
|
21
21
|
case date.to_s
|
@@ -31,12 +31,12 @@ module RelatonBib
|
|
31
31
|
# @return [String, Date, nil]
|
32
32
|
def from(part = nil)
|
33
33
|
d = instance_variable_get "@#{__callee__}".to_sym
|
34
|
-
return d unless part
|
34
|
+
return d unless part && d
|
35
35
|
|
36
36
|
date = parse_date(d)
|
37
37
|
return date if part == :date
|
38
38
|
|
39
|
-
date.send
|
39
|
+
date.is_a?(Date) ? date.send(part) : date
|
40
40
|
end
|
41
41
|
|
42
42
|
alias_method :to, :from
|
@@ -87,20 +87,23 @@ module RelatonBib
|
|
87
87
|
# @param format [Symbol, nil] :full (yyyy-mm-dd), :short (yyyy-mm) or nil
|
88
88
|
# @return [String]
|
89
89
|
def date_format(date, format = nil)
|
90
|
-
case format
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
90
|
+
tmplt = case format
|
91
|
+
when :short then "%Y-%m"
|
92
|
+
when :full then "%Y-%m-%d"
|
93
|
+
else return date
|
94
|
+
end
|
95
|
+
d = parse_date(date)
|
96
|
+
d.is_a?(Date) ? d.strftime(tmplt) : d
|
95
97
|
end
|
96
98
|
|
97
99
|
# @param date [String]
|
98
100
|
# @return [Date]
|
99
101
|
def parse_date(date)
|
100
102
|
case date
|
101
|
-
when
|
102
|
-
when
|
103
|
-
when
|
103
|
+
when /^\d{4}-\d{2}-\d{2}/ then Date.parse(date) # 2012-02-11
|
104
|
+
when /^\d{4}-\d{2}/ then Date.strptime(date, "%Y-%m") # 2012-02
|
105
|
+
when /^\d{4}/ then Date.strptime(date, "%Y") # 2012
|
106
|
+
else date
|
104
107
|
end
|
105
108
|
end
|
106
109
|
end
|
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.6.
|
4
|
+
version: 1.6.1
|
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-
|
11
|
+
date: 2020-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|