relaton-bib 1.12.0 → 1.12.3

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
  SHA256:
3
- metadata.gz: 9eeef3d918b1e4019c727d83fbd3dcaaec3b728b0e5ae20fc060d2f807766d9a
4
- data.tar.gz: 52f1ef6b2878caf82fd057367c86c9559c9b40b28426ab707c195f8d986955fc
3
+ metadata.gz: 3610adb6319fa59f2a67b10146c3e976c7c827d91df441b504de6534cb285020
4
+ data.tar.gz: 75f324998da686277dee651003ba6bb2e0dea57bcb170e8db0e0566f12a45ca3
5
5
  SHA512:
6
- metadata.gz: 976fbcf860048645b33c83a02aa3d93371ec5b03a7e5282a263cbfeede3acc3b869c613edb642157abd14908ff665b63219ee374a8d5ccfc9c0a256b9e224fd7
7
- data.tar.gz: 0fd3bc4e7e8177e84887d65c137add9566bbca0cc317b1b2423fffc37f60b280463e8f6c55b5e1aa67ebb4c4d01cc18e3c5786ff7ac9d9aaffa3e5a2664dc624
6
+ metadata.gz: 4d732c577746afab2468f58404b93ab207999425ab8f9069589622ea3b89172ed9230390bdb033652440c478ab2b723977ec62064e92ce5202cde0dc753ca3c5
7
+ data.tar.gz: 3ac992c12c4dd00a17314a5f49ea79d82f8a66b1e8707087a2e52c17f863ea547d793f5d429fa2d63024ca6f9b22ce258e35fe55c4bfc4c947a81dcb44bd5209
@@ -59,8 +59,8 @@ module RelatonBib
59
59
  # @param count [Integer] number of contributors
60
60
  # 2return [String]
61
61
  def to_asciibib(prefix = "", count = 1)
62
- pref = prefix.empty? ? prefix : prefix + "."
63
- out = count > 1 ? "#{prefix}::\n" : ""
62
+ pref = prefix.empty? ? prefix : "#{prefix}."
63
+ out = count > 1 ? "#{prefix}.role::\n" : ""
64
64
  description.each do |d|
65
65
  out += d.to_asciibib "#{pref}role.description", description.size
66
66
  end
@@ -46,12 +46,12 @@ module RelatonBib
46
46
 
47
47
  # @return [Hash]
48
48
  def to_hash # rubocop:disable Metrics/AbcSize
49
- hash = {}
50
- hash["street"] = street if street&.any?
51
- hash["city"] = city
52
- hash["state"] = state if state
53
- hash["country"] = country
54
- hash["postcode"] = postcode if postcode
49
+ hash = { "address" => {} }
50
+ hash["address"]["street"] = street if street&.any?
51
+ hash["address"]["city"] = city
52
+ hash["address"]["state"] = state if state
53
+ hash["address"]["country"] = country
54
+ hash["address"]["postcode"] = postcode if postcode
55
55
  hash
56
56
  end
57
57
 
@@ -92,7 +92,7 @@ module RelatonBib
92
92
 
93
93
  # @return [Hash]
94
94
  def to_hash
95
- { "type" => type, "value" => value }
95
+ { type => value }
96
96
  end
97
97
 
98
98
  # @param prefix [String]
@@ -101,8 +101,8 @@ module RelatonBib
101
101
  def to_asciibib(prefix = "", count = 1)
102
102
  pref = prefix.empty? ? prefix : "#{prefix}."
103
103
  out = count > 1 ? "#{pref}contact::\n" : ""
104
- out += "#{pref}contact.type:: #{type}\n"
105
- out += "#{pref}contact.value:: #{value}\n"
104
+ # out += "#{pref}contact.type:: #{type}\n"
105
+ out += "#{pref}contact.#{type}:: #{value}\n"
106
106
  out
107
107
  end
108
108
  end
@@ -6,7 +6,7 @@ module RelatonBib
6
6
  extend Forwardable
7
7
 
8
8
  def_delegators :@array, :<<, :[], :first, :last, :empty?, :any?, :size,
9
- :each, :detect, :map, :reduce, :length
9
+ :each, :detect, :map, :reduce, :length, :unshift
10
10
 
11
11
  # @param relation [Array<RelatonBib::DocumentRelation, Hash>]
12
12
  # @option relation [String] :type
@@ -32,7 +32,7 @@ module RelatonBib
32
32
  # @param prefix [String]
33
33
  # @return [String]
34
34
  def to_asciibib(prefix = "")
35
- pref = prefix.empty? ? "relation" : prefix + ".relation"
35
+ pref = prefix.empty? ? "relation" : "#{prefix}.relation"
36
36
  out = ""
37
37
  @array.each do |r|
38
38
  out += size > 1 ? "#{pref}::\n" : ""
@@ -56,8 +56,8 @@ module RelatonBib
56
56
  def stage_new(stg)
57
57
  case stg
58
58
  when Stage then stg
59
- when Hash then Stage.new(**stg)
60
- when String then Stage.new(value: stg)
59
+ when Hash then self.class::Stage.new(**stg)
60
+ when String then self.class::Stage.new(value: stg)
61
61
  end
62
62
  end
63
63
 
@@ -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,14 +278,20 @@ 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|
282
- if a[:city] || a[:country]
281
+ RelatonBib.array(entity[:contact]).map do |a|
282
+ if a[:city] || a[:country] # it's for old version compatibility, should be removed in the future
283
283
  RelatonBib::Address.new(
284
284
  street: Array(a[:street]), city: a[:city], postcode: a[:postcode],
285
285
  country: a[:country], state: a[:state]
286
286
  )
287
- else
287
+ elsif a[:address]
288
+ a[:address][:street] = RelatonBib.array(a[:address][:street])
289
+ RelatonBib::Address.new(**a[:address])
290
+ elsif a[:type] # it's for old version compatibility, should be removed in the future
288
291
  RelatonBib::Contact.new(type: a[:type], value: a[:value])
292
+ else
293
+ type, value = a.flatten
294
+ RelatonBib::Contact.new(type: type.to_s, value: value)
289
295
  end
290
296
  end
291
297
  end
@@ -294,8 +300,8 @@ module RelatonBib
294
300
  def copyright_hash_to_bib(ret)
295
301
  return unless ret[:copyright]
296
302
 
297
- ret[:copyright] = array(ret[:copyright]).map do |c|
298
- c[:owner] = array(c[:owner])
303
+ ret[:copyright] = RelatonBib.array(ret[:copyright]).map do |c|
304
+ c[:owner] = RelatonBib.array(c[:owner])
299
305
  c
300
306
  end
301
307
  end
@@ -304,7 +310,7 @@ module RelatonBib
304
310
  def relations_hash_to_bib(ret)
305
311
  return unless ret[:relation]
306
312
 
307
- ret[:relation] = array(ret[:relation])
313
+ ret[:relation] = RelatonBib.array(ret[:relation])
308
314
  ret[:relation]&.each do |r|
309
315
  if r[:description]
310
316
  r[:description] = FormattedString.new(**r[:description])
@@ -334,14 +340,14 @@ module RelatonBib
334
340
  # @param rel [Hash] relation
335
341
  # @return [RelatonBib::LocalityStack]
336
342
  def relation_locality_hash_to_bib(rel)
337
- rel[:locality] = array(rel[:locality])&.map do |bl|
343
+ rel[:locality] = RelatonBib.array(rel[:locality])&.map do |bl|
338
344
  LocalityStack.new locality_locality_stack(bl)
339
345
  end
340
346
  end
341
347
 
342
348
  def locality_locality_stack(lls)
343
349
  if lls[:locality_stack]
344
- array(lls[:locality_stack]).map do |lc|
350
+ RelatonBib.array(lls[:locality_stack]).map do |lc|
345
351
  l = lc[:locality] || lc
346
352
  Locality.new(l[:type], l[:reference_from], l[:reference_to])
347
353
  end
@@ -352,9 +358,9 @@ module RelatonBib
352
358
 
353
359
  # @param rel [Hash] relation
354
360
  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|
361
+ rel[:source_locality] = RelatonBib.array(rel[:source_locality])&.map do |sl|
356
362
  sls = if sl[:source_locality_stack]
357
- array(sl[:source_locality_stack]).map do |l|
363
+ RelatonBib.array(sl[:source_locality_stack]).map do |l|
358
364
  SourceLocality.new(l[:type], l[:reference_from],
359
365
  l[:reference_to])
360
366
  end
@@ -369,7 +375,7 @@ module RelatonBib
369
375
 
370
376
  # @param ret [Hash]
371
377
  def series_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
372
- ret[:series] = array(ret[:series])&.map do |s|
378
+ ret[:series] = RelatonBib.array(ret[:series])&.map do |s|
373
379
  s[:formattedref] && s[:formattedref] = formattedref(s[:formattedref])
374
380
  if s[:title]
375
381
  s[:title] = { content: s[:title] } unless s[:title].is_a?(Hash)
@@ -395,7 +401,7 @@ module RelatonBib
395
401
  # @param ret [Hash]
396
402
  def classification_hash_to_bib(ret)
397
403
  if ret[:classification]
398
- ret[:classification] = array(ret[:classification]).map do |cls|
404
+ ret[:classification] = RelatonBib.array(ret[:classification]).map do |cls|
399
405
  Classification.new(**cls)
400
406
  end
401
407
  end
@@ -429,7 +435,7 @@ module RelatonBib
429
435
  def editorialgroup_hash_to_bib(ret)
430
436
  return unless ret[:editorialgroup]
431
437
 
432
- technical_committee = array(ret[:editorialgroup]).map do |wg|
438
+ technical_committee = RelatonBib.array(ret[:editorialgroup]).map do |wg|
433
439
  TechnicalCommittee.new WorkGroup.new(**wg)
434
440
  end
435
441
  ret[:editorialgroup] = EditorialGroup.new technical_committee
@@ -439,15 +445,15 @@ module RelatonBib
439
445
  def ics_hash_to_bib(ret)
440
446
  return unless ret[:ics]
441
447
 
442
- ret[:ics] = array(ret[:ics]).map { |ics| ICS.new(**ics) }
448
+ ret[:ics] = RelatonBib.array(ret[:ics]).map { |ics| ICS.new(**ics) }
443
449
  end
444
450
 
445
451
  # @param ret [Hash]
446
452
  def structuredidentifier_hash_to_bib(ret)
447
453
  return unless ret[:structuredidentifier]
448
454
 
449
- sids = array(ret[:structuredidentifier]).map do |si|
450
- si[:agency] = array si[:agency]
455
+ sids = RelatonBib.array(ret[:structuredidentifier]).map do |si|
456
+ si[:agency] = RelatonBib.array si[:agency]
451
457
  StructuredIdentifier.new(**si)
452
458
  end
453
459
  ret[:structuredidentifier] = StructuredIdentifierCollection.new sids
@@ -467,15 +473,6 @@ module RelatonBib
467
473
  end
468
474
  end
469
475
 
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
476
  # @param name [Hash, String, NilClass]
480
477
  # @param person [Hash]
481
478
  # @return [RelatonBib::LocalizedString]
@@ -37,7 +37,7 @@ module RelatonBib
37
37
  # @param run [String, nil]
38
38
  def initialize(**args)
39
39
  unless args[:title].is_a?(RelatonBib::TypedTitleString)
40
- raise ArgumentError, "argument `title` should present"
40
+ raise ArgumentError, "argument `title` should present in series"
41
41
  end
42
42
 
43
43
  # if args[:type] && !TYPES.include?(args[:type])
@@ -12,9 +12,7 @@ module RelatonBib
12
12
 
13
13
  # @param builder [Nokogiri::XML::Builder]
14
14
  def to_xml(builder)
15
- builder.send "technical-committee" do |b|
16
- workgroup.to_xml b
17
- end
15
+ builder.send(:"technical-committee") { |b| workgroup.to_xml b }
18
16
  end
19
17
 
20
18
  # @return [Hash]
@@ -26,7 +24,7 @@ module RelatonBib
26
24
  # @param count [Integer] number of technical committees
27
25
  # @return [String]
28
26
  def to_asciibib(prefix = "", count = 1)
29
- pref = prefix.empty? ? prefix : prefix + "."
27
+ pref = prefix.empty? ? prefix : "#{prefix}."
30
28
  pref += "technical_committee"
31
29
  out = count > 1 ? "#{pref}::\n" : ""
32
30
  out += workgroup.to_asciibib pref
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "1.12.0".freeze
2
+ VERSION = "1.12.3".freeze
3
3
  end
data/lib/relaton_bib.rb CHANGED
@@ -37,6 +37,15 @@ module RelatonBib
37
37
  end
38
38
  end
39
39
 
40
+ # @param arr [NilClass, Array, #is_a?]
41
+ # @return [Array]
42
+ def array(arr)
43
+ return [] unless arr
44
+ return [arr] unless arr.is_a?(Array)
45
+
46
+ arr
47
+ end
48
+
40
49
  #
41
50
  # Parse yaml content
42
51
  #
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.0
4
+ version: 1.12.3
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-25 00:00:00.000000000 Z
11
+ date: 2022-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug