relaton-bib 1.12.0 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/relaton_bib/hash_converter.rb +41 -50
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib.rb +9 -0
- 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: e0b1ea12faaf38ba10b73a5febe3ac1740c9746319b7a20038c263373ea3dd25
|
|
4
|
+
data.tar.gz: ef008d6e8283479a0daec628bd7cb22219ff77ff4a53813b64478d916e0f4de1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a279a45bb36054842755b1ca417865a61caaa913bdff2847672649688ff2c08d051cccb5ad13b7fd650a893c442dddd533e9d45cc7847964f6938f63ecabaa80
|
|
7
|
+
data.tar.gz: 4a6782ace9e988681e61422acc62bd14117e1188041bddda5d5e6c213b1eb2f1c4f7c7d1d646e7502a33260ef1e58b4fd12ba50e3e3f3a7ccb8cd1d8fcda3d86
|
|
@@ -33,8 +33,8 @@ module RelatonBib
|
|
|
33
33
|
accesslocation_hash_to_bib(ret)
|
|
34
34
|
classification_hash_to_bib(ret)
|
|
35
35
|
validity_hash_to_bib(ret)
|
|
36
|
-
ret[:keyword] = array(ret[:keyword])
|
|
37
|
-
ret[:license] = array(ret[:license])
|
|
36
|
+
ret[:keyword] = RelatonBib.array(ret[:keyword])
|
|
37
|
+
ret[:license] = RelatonBib.array(ret[:license])
|
|
38
38
|
editorialgroup_hash_to_bib ret
|
|
39
39
|
ics_hash_to_bib ret
|
|
40
40
|
structuredidentifier_hash_to_bib ret
|
|
@@ -49,7 +49,7 @@ module RelatonBib
|
|
|
49
49
|
def extent_hash_to_bib(ret)
|
|
50
50
|
return unless ret[:extent]
|
|
51
51
|
|
|
52
|
-
ret[:extent] = array(ret[:extent]).map do |e|
|
|
52
|
+
ret[:extent] = RelatonBib.array(ret[:extent]).map do |e|
|
|
53
53
|
locality e
|
|
54
54
|
# ret[:extent][i] = Locality.new(e[:type], e[:reference_from],
|
|
55
55
|
# e[:reference_to])
|
|
@@ -68,7 +68,7 @@ module RelatonBib
|
|
|
68
68
|
def size_hash_to_bib(ret)
|
|
69
69
|
return unless ret[:size]
|
|
70
70
|
|
|
71
|
-
ret[:size] = array(ret[:size])
|
|
71
|
+
ret[:size] = RelatonBib.array(ret[:size])
|
|
72
72
|
size = ret[:size]&.map do |val|
|
|
73
73
|
BibliographicSize::Value.new(**val)
|
|
74
74
|
end
|
|
@@ -78,7 +78,7 @@ module RelatonBib
|
|
|
78
78
|
def title_hash_to_bib(ret)
|
|
79
79
|
return unless ret[:title]
|
|
80
80
|
|
|
81
|
-
ret[:title] = array(ret[:title])
|
|
81
|
+
ret[:title] = RelatonBib.array(ret[:title])
|
|
82
82
|
.reduce(TypedTitleStringCollection.new) do |m, t|
|
|
83
83
|
if t.is_a?(Hash) then m << t
|
|
84
84
|
else
|
|
@@ -90,19 +90,19 @@ module RelatonBib
|
|
|
90
90
|
def language_hash_to_bib(ret)
|
|
91
91
|
return unless ret[:language]
|
|
92
92
|
|
|
93
|
-
ret[:language] = array(ret[:language])
|
|
93
|
+
ret[:language] = RelatonBib.array(ret[:language])
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
def script_hash_to_bib(ret)
|
|
97
97
|
return unless ret[:script]
|
|
98
98
|
|
|
99
|
-
ret[:script] = array(ret[:script])
|
|
99
|
+
ret[:script] = RelatonBib.array(ret[:script])
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
def abstract_hash_to_bib(ret)
|
|
103
103
|
return unless ret[:abstract]
|
|
104
104
|
|
|
105
|
-
ret[:abstract] = array(ret[:abstract]).map do |a|
|
|
105
|
+
ret[:abstract] = RelatonBib.array(ret[:abstract]).map do |a|
|
|
106
106
|
a.is_a?(String) ? FormattedString.new(content: a) : a
|
|
107
107
|
end
|
|
108
108
|
end
|
|
@@ -110,13 +110,13 @@ module RelatonBib
|
|
|
110
110
|
def link_hash_to_bib(ret)
|
|
111
111
|
return unless ret[:link]
|
|
112
112
|
|
|
113
|
-
ret[:link] = array(ret[:link])
|
|
113
|
+
ret[:link] = RelatonBib.array(ret[:link])
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
def place_hash_to_bib(ret)
|
|
117
117
|
return unless ret[:place]
|
|
118
118
|
|
|
119
|
-
ret[:place] = array(ret[:place]).map do |pl|
|
|
119
|
+
ret[:place] = RelatonBib.array(ret[:place]).map do |pl|
|
|
120
120
|
pl.is_a?(String) ? Place.new(name: pl) : Place.new(**pl)
|
|
121
121
|
end
|
|
122
122
|
end
|
|
@@ -124,13 +124,13 @@ module RelatonBib
|
|
|
124
124
|
def accesslocation_hash_to_bib(ret)
|
|
125
125
|
return unless ret[:accesslocation]
|
|
126
126
|
|
|
127
|
-
ret[:accesslocation] = array(ret[:accesslocation])
|
|
127
|
+
ret[:accesslocation] = RelatonBib.array(ret[:accesslocation])
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
def dates_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize
|
|
131
131
|
return unless ret[:date]
|
|
132
132
|
|
|
133
|
-
ret[:date] = array(ret[:date])
|
|
133
|
+
ret[:date] = RelatonBib.array(ret[:date])
|
|
134
134
|
ret[:date].each_with_index do |d, i|
|
|
135
135
|
# value is synonym of on: it is reserved word in YAML
|
|
136
136
|
if d[:value]
|
|
@@ -143,7 +143,7 @@ module RelatonBib
|
|
|
143
143
|
def docid_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize
|
|
144
144
|
return unless ret[:docid]
|
|
145
145
|
|
|
146
|
-
ret[:docid] = array(ret[:docid])
|
|
146
|
+
ret[:docid] = RelatonBib.array(ret[:docid])
|
|
147
147
|
ret[:docid]&.each_with_index do |id, i|
|
|
148
148
|
id[:type] ||= id[:id].match(/^\w+(?=\s)/)&.to_s
|
|
149
149
|
ret[:docid][i] = DocumentIdentifier.new(**id)
|
|
@@ -153,7 +153,7 @@ module RelatonBib
|
|
|
153
153
|
def version_hash_to_bib(ret)
|
|
154
154
|
return unless ret[:version]
|
|
155
155
|
|
|
156
|
-
ret[:version] = array(ret[:version]).map do |v|
|
|
156
|
+
ret[:version] = RelatonBib.array(ret[:version]).map do |v|
|
|
157
157
|
BibliographicItem::Version.new(v[:revision_date], v[:draft])
|
|
158
158
|
end
|
|
159
159
|
end
|
|
@@ -161,7 +161,7 @@ module RelatonBib
|
|
|
161
161
|
def biblionote_hash_to_bib(ret) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
|
162
162
|
return unless ret[:biblionote]
|
|
163
163
|
|
|
164
|
-
ret[:biblionote] = array(ret[:biblionote])
|
|
164
|
+
ret[:biblionote] = RelatonBib.array(ret[:biblionote])
|
|
165
165
|
.reduce(BiblioNoteCollection.new([])) do |mem, n|
|
|
166
166
|
mem << if n.is_a?(String) then BiblioNote.new content: n
|
|
167
167
|
else BiblioNote.new(**n)
|
|
@@ -194,11 +194,11 @@ module RelatonBib
|
|
|
194
194
|
def contributors_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength,Metrics/PerceivedComplexity
|
|
195
195
|
return unless ret[:contributor]
|
|
196
196
|
|
|
197
|
-
ret[:contributor] = array(ret[:contributor])
|
|
197
|
+
ret[:contributor] = RelatonBib.array(ret[:contributor])
|
|
198
198
|
ret[:contributor]&.each_with_index do |c, i|
|
|
199
|
-
roles = array(ret[:contributor][i][:role]).map do |r|
|
|
199
|
+
roles = RelatonBib.array(ret[:contributor][i][:role]).map do |r|
|
|
200
200
|
if r.is_a? Hash
|
|
201
|
-
{ type: r[:type], description: array(r[:description]) }
|
|
201
|
+
{ type: r[:type], description: RelatonBib.array(r[:description]) }
|
|
202
202
|
# elsif r.is_a? Array
|
|
203
203
|
# { type: r[0], description: r.fetch(1) }
|
|
204
204
|
else
|
|
@@ -219,10 +219,10 @@ module RelatonBib
|
|
|
219
219
|
def org_hash_to_bib(org) # rubocop:disable Metrics/AbcSize
|
|
220
220
|
return nil if org.nil?
|
|
221
221
|
|
|
222
|
-
org[:identifier] = array(org[:identifier])&.map do |a|
|
|
222
|
+
org[:identifier] = RelatonBib.array(org[:identifier])&.map do |a|
|
|
223
223
|
OrgIdentifier.new(a[:type], a[:id])
|
|
224
224
|
end
|
|
225
|
-
org[:subdivision] = array(org[:subdivision]).map do |sd|
|
|
225
|
+
org[:subdivision] = RelatonBib.array(org[:subdivision]).map do |sd|
|
|
226
226
|
LocalizedString.new sd
|
|
227
227
|
end
|
|
228
228
|
org[:contact] = contacts_hash_to_bib(org)
|
|
@@ -241,17 +241,17 @@ module RelatonBib
|
|
|
241
241
|
def fullname_hash_to_bib(person) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
242
242
|
n = person[:name]
|
|
243
243
|
FullName.new(
|
|
244
|
-
forename: array(n[:forename])&.map { |f| localname(f, person) },
|
|
245
|
-
initial: array(n[:initial])&.map { |f| localname(f, person) },
|
|
246
|
-
addition: array(n[:addition])&.map { |f| localname(f, person) },
|
|
247
|
-
prefix: array(n[:prefix])&.map { |f| localname(f, person) },
|
|
244
|
+
forename: RelatonBib.array(n[:forename])&.map { |f| localname(f, person) },
|
|
245
|
+
initial: RelatonBib.array(n[:initial])&.map { |f| localname(f, person) },
|
|
246
|
+
addition: RelatonBib.array(n[:addition])&.map { |f| localname(f, person) },
|
|
247
|
+
prefix: RelatonBib.array(n[:prefix])&.map { |f| localname(f, person) },
|
|
248
248
|
surname: localname(n[:surname], person),
|
|
249
249
|
completename: localname(n[:completename], person),
|
|
250
250
|
)
|
|
251
251
|
end
|
|
252
252
|
|
|
253
253
|
def person_identifiers_hash_to_bib(person)
|
|
254
|
-
array(person[:identifier])&.map do |a|
|
|
254
|
+
RelatonBib.array(person[:identifier])&.map do |a|
|
|
255
255
|
PersonIdentifier.new(a[:type], a[:id])
|
|
256
256
|
end
|
|
257
257
|
end
|
|
@@ -259,8 +259,8 @@ module RelatonBib
|
|
|
259
259
|
def affiliation_hash_to_bib(person) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
260
260
|
return [] unless person[:affiliation]
|
|
261
261
|
|
|
262
|
-
array(person[:affiliation]).map do |a|
|
|
263
|
-
a[:description] = array(a[:description])&.map do |d|
|
|
262
|
+
RelatonBib.array(person[:affiliation]).map do |a|
|
|
263
|
+
a[:description] = RelatonBib.array(a[:description])&.map do |d|
|
|
264
264
|
cnt = if d.is_a?(Hash)
|
|
265
265
|
{ content: d[:content], language: d[:language],
|
|
266
266
|
script: d[:script], format: d[:format] }
|
|
@@ -278,7 +278,7 @@ module RelatonBib
|
|
|
278
278
|
def contacts_hash_to_bib(entity) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
279
279
|
return [] unless entity[:contact]
|
|
280
280
|
|
|
281
|
-
array(entity[:contact]).map do |a|
|
|
281
|
+
RelatonBib.array(entity[:contact]).map do |a|
|
|
282
282
|
if a[:city] || a[:country]
|
|
283
283
|
RelatonBib::Address.new(
|
|
284
284
|
street: Array(a[:street]), city: a[:city], postcode: a[:postcode],
|
|
@@ -294,8 +294,8 @@ module RelatonBib
|
|
|
294
294
|
def copyright_hash_to_bib(ret)
|
|
295
295
|
return unless ret[:copyright]
|
|
296
296
|
|
|
297
|
-
ret[:copyright] = array(ret[:copyright]).map do |c|
|
|
298
|
-
c[:owner] = array(c[:owner])
|
|
297
|
+
ret[:copyright] = RelatonBib.array(ret[:copyright]).map do |c|
|
|
298
|
+
c[:owner] = RelatonBib.array(c[:owner])
|
|
299
299
|
c
|
|
300
300
|
end
|
|
301
301
|
end
|
|
@@ -304,7 +304,7 @@ module RelatonBib
|
|
|
304
304
|
def relations_hash_to_bib(ret)
|
|
305
305
|
return unless ret[:relation]
|
|
306
306
|
|
|
307
|
-
ret[:relation] = array(ret[:relation])
|
|
307
|
+
ret[:relation] = RelatonBib.array(ret[:relation])
|
|
308
308
|
ret[:relation]&.each do |r|
|
|
309
309
|
if r[:description]
|
|
310
310
|
r[:description] = FormattedString.new(**r[:description])
|
|
@@ -334,14 +334,14 @@ module RelatonBib
|
|
|
334
334
|
# @param rel [Hash] relation
|
|
335
335
|
# @return [RelatonBib::LocalityStack]
|
|
336
336
|
def relation_locality_hash_to_bib(rel)
|
|
337
|
-
rel[:locality] = array(rel[:locality])&.map do |bl|
|
|
337
|
+
rel[:locality] = RelatonBib.array(rel[:locality])&.map do |bl|
|
|
338
338
|
LocalityStack.new locality_locality_stack(bl)
|
|
339
339
|
end
|
|
340
340
|
end
|
|
341
341
|
|
|
342
342
|
def locality_locality_stack(lls)
|
|
343
343
|
if lls[:locality_stack]
|
|
344
|
-
array(lls[:locality_stack]).map do |lc|
|
|
344
|
+
RelatonBib.array(lls[:locality_stack]).map do |lc|
|
|
345
345
|
l = lc[:locality] || lc
|
|
346
346
|
Locality.new(l[:type], l[:reference_from], l[:reference_to])
|
|
347
347
|
end
|
|
@@ -352,9 +352,9 @@ module RelatonBib
|
|
|
352
352
|
|
|
353
353
|
# @param rel [Hash] relation
|
|
354
354
|
def relation_source_locality_hash_to_bib(rel) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
355
|
-
rel[:source_locality] = array(rel[:source_locality])&.map do |sl|
|
|
355
|
+
rel[:source_locality] = RelatonBib.array(rel[:source_locality])&.map do |sl|
|
|
356
356
|
sls = if sl[:source_locality_stack]
|
|
357
|
-
array(sl[:source_locality_stack]).map do |l|
|
|
357
|
+
RelatonBib.array(sl[:source_locality_stack]).map do |l|
|
|
358
358
|
SourceLocality.new(l[:type], l[:reference_from],
|
|
359
359
|
l[:reference_to])
|
|
360
360
|
end
|
|
@@ -369,7 +369,7 @@ module RelatonBib
|
|
|
369
369
|
|
|
370
370
|
# @param ret [Hash]
|
|
371
371
|
def series_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
|
372
|
-
ret[:series] = array(ret[:series])&.map do |s|
|
|
372
|
+
ret[:series] = RelatonBib.array(ret[:series])&.map do |s|
|
|
373
373
|
s[:formattedref] && s[:formattedref] = formattedref(s[:formattedref])
|
|
374
374
|
if s[:title]
|
|
375
375
|
s[:title] = { content: s[:title] } unless s[:title].is_a?(Hash)
|
|
@@ -395,7 +395,7 @@ module RelatonBib
|
|
|
395
395
|
# @param ret [Hash]
|
|
396
396
|
def classification_hash_to_bib(ret)
|
|
397
397
|
if ret[:classification]
|
|
398
|
-
ret[:classification] = array(ret[:classification]).map do |cls|
|
|
398
|
+
ret[:classification] = RelatonBib.array(ret[:classification]).map do |cls|
|
|
399
399
|
Classification.new(**cls)
|
|
400
400
|
end
|
|
401
401
|
end
|
|
@@ -429,7 +429,7 @@ module RelatonBib
|
|
|
429
429
|
def editorialgroup_hash_to_bib(ret)
|
|
430
430
|
return unless ret[:editorialgroup]
|
|
431
431
|
|
|
432
|
-
technical_committee = array(ret[:editorialgroup]).map do |wg|
|
|
432
|
+
technical_committee = RelatonBib.array(ret[:editorialgroup]).map do |wg|
|
|
433
433
|
TechnicalCommittee.new WorkGroup.new(**wg)
|
|
434
434
|
end
|
|
435
435
|
ret[:editorialgroup] = EditorialGroup.new technical_committee
|
|
@@ -439,15 +439,15 @@ module RelatonBib
|
|
|
439
439
|
def ics_hash_to_bib(ret)
|
|
440
440
|
return unless ret[:ics]
|
|
441
441
|
|
|
442
|
-
ret[:ics] = array(ret[:ics]).map { |ics| ICS.new(**ics) }
|
|
442
|
+
ret[:ics] = RelatonBib.array(ret[:ics]).map { |ics| ICS.new(**ics) }
|
|
443
443
|
end
|
|
444
444
|
|
|
445
445
|
# @param ret [Hash]
|
|
446
446
|
def structuredidentifier_hash_to_bib(ret)
|
|
447
447
|
return unless ret[:structuredidentifier]
|
|
448
448
|
|
|
449
|
-
sids = array(ret[:structuredidentifier]).map do |si|
|
|
450
|
-
si[:agency] = array si[:agency]
|
|
449
|
+
sids = RelatonBib.array(ret[:structuredidentifier]).map do |si|
|
|
450
|
+
si[:agency] = RelatonBib.array si[:agency]
|
|
451
451
|
StructuredIdentifier.new(**si)
|
|
452
452
|
end
|
|
453
453
|
ret[:structuredidentifier] = StructuredIdentifierCollection.new sids
|
|
@@ -467,15 +467,6 @@ module RelatonBib
|
|
|
467
467
|
end
|
|
468
468
|
end
|
|
469
469
|
|
|
470
|
-
# @param arr [NilClass, Array, #is_a?]
|
|
471
|
-
# @return [Array]
|
|
472
|
-
def array(arr)
|
|
473
|
-
return [] unless arr
|
|
474
|
-
return [arr] unless arr.is_a?(Array)
|
|
475
|
-
|
|
476
|
-
arr
|
|
477
|
-
end
|
|
478
|
-
|
|
479
470
|
# @param name [Hash, String, NilClass]
|
|
480
471
|
# @param person [Hash]
|
|
481
472
|
# @return [RelatonBib::LocalizedString]
|
data/lib/relaton_bib/version.rb
CHANGED
data/lib/relaton_bib.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.12.
|
|
4
|
+
version: 1.12.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: 2022-06-
|
|
11
|
+
date: 2022-06-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: byebug
|