relaton-bib 1.19.7 → 1.20.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ebc6362f3e1c7be2b9f67d0d5934c52f5ccfd0f65826121e3ec711739c0a09d
4
- data.tar.gz: 05aec1a9157b2388a81b2ffc8aebe03ad22ea0ce993319a9dd16c088dba1460c
3
+ metadata.gz: 8c8c7845b60e7505d296fadab366bc2bc9246e658e8b5b5635ef241414fb2977
4
+ data.tar.gz: 5229fb3595bee6deaaa651f25caf321d5611922f7613757abb4d7f7802014f49
5
5
  SHA512:
6
- metadata.gz: 1f5edc01c516b194bbac895769575ab076d91f0e7b01114b8646182c2bb361530ccd243c9c43e52df68634783af5d69628cc1cf2f08d9def0aefc6a4fc14c2af
7
- data.tar.gz: 1f3476a58acc6272962db01c979c870c80efa96403158ac2eec77716d776169f15d1a42d81abd1b0658c434c6b16567e720f0c020b29cab23750d424f9b666a1
6
+ metadata.gz: f875889416e4f4d4f6b270db74b3454d7c1c2113915d1a0266a2255c50da32ec3cb458e83c4f7197bcaaef2359840dd16effbaa2776d2977f334bff0733ca0c9
7
+ data.tar.gz: 583e95824c6ebdd832059947fe551c856762c809bb047c1a17ae5e39479494431926f1c65623027bd80d204905396be9bd7afc95903ed7b6fbabd49e59265548
@@ -119,7 +119,12 @@ module RelatonBib
119
119
 
120
120
  # @returnt [Hash]
121
121
  def to_hash
122
- { "locality_stack" => single_element_array(locality) }
122
+ hash = Hash.new { |h, k| h[k] = [] }
123
+ locality.each_with_object(hash) do |l, obj|
124
+ k, v = l.to_hash.first
125
+ obj[k] << v
126
+ end
127
+ { "locality_stack" => hash }
123
128
  end
124
129
 
125
130
  #
@@ -17,6 +17,7 @@ require "relaton_bib/classification"
17
17
  require "relaton_bib/validity"
18
18
  require "relaton_bib/document_relation"
19
19
  require "relaton_bib/bib_item_locality"
20
+ require_relative "extent"
20
21
  require "relaton_bib/xml_parser"
21
22
  require "relaton_bib/bibtex_parser"
22
23
  require "relaton_bib/biblio_note"
@@ -105,7 +106,7 @@ module RelatonBib
105
106
  # @return [Array<RelatonBib::Place>]
106
107
  attr_reader :place
107
108
 
108
- # @return [Array<RelatonBib::Locality, RelatonBib::LocalityStack>]
109
+ # @return [Array<RelatonBib::Extent>]
109
110
  attr_reader :extent
110
111
 
111
112
  # @return [Array<Strig>]
@@ -154,7 +155,7 @@ module RelatonBib
154
155
  # @param series [Array<RelatonBib::Series>]
155
156
  # @param medium [RelatonBib::Medium, nil]
156
157
  # @param place [Array<String, RelatonBib::Place>]
157
- # @param extent [Array<RelatonBib::Locality, RelatonBib::LocalityStack>]
158
+ # @param extent [Array<RelatonBib::Extent>]
158
159
  # @param accesslocation [Array<String>]
159
160
  # @param classification [Array<RelatonBib::Classification>]
160
161
  # @param validity [RelatonBib:Validity, nil]
@@ -417,7 +418,7 @@ module RelatonBib
417
418
  hash["series"] = single_element_array(series) if series&.any?
418
419
  hash["medium"] = medium.to_hash if medium
419
420
  hash["place"] = single_element_array(place) if place&.any?
420
- hash["extent"] = single_element_array(extent) if extent&.any?
421
+ hash["extent"] = extent.map(&:to_hash) if extent&.any?
421
422
  hash["size"] = size.to_hash if size&.any?
422
423
  if accesslocation&.any?
423
424
  hash["accesslocation"] = single_element_array(accesslocation)
@@ -429,16 +430,15 @@ module RelatonBib
429
430
  hash["fetched"] = fetched.to_s if fetched
430
431
  hash["keyword"] = single_element_array(keyword) if keyword&.any?
431
432
  hash["license"] = single_element_array(license) if license&.any?
432
- hash["doctype"] = doctype.to_hash if doctype
433
- hash["subdoctype"] = subdoctype if subdoctype
434
- if editorialgroup&.presence?
435
- hash["editorialgroup"] = editorialgroup.to_hash
433
+ if has_ext?
434
+ hash["ext"] = {}
435
+ hash["ext"]["schema-version"] = ext_schema if !embedded && respond_to?(:ext_schema) && ext_schema
436
+ hash["ext"]["doctype"] = doctype.to_hash if doctype
437
+ hash["ext"]["subdoctype"] = subdoctype if subdoctype
438
+ hash["ext"]["editorialgroup"] = editorialgroup.to_hash if editorialgroup&.presence?
439
+ hash["ext"]["ics"] = single_element_array ics if ics.any?
440
+ hash["ext"]["structuredidentifier"] = structuredidentifier.to_hash if structuredidentifier&.presence?
436
441
  end
437
- hash["ics"] = single_element_array ics if ics.any?
438
- if structuredidentifier&.presence?
439
- hash["structuredidentifier"] = structuredidentifier.to_hash
440
- end
441
- hash["ext"] = { "schema-version" => ext_schema } if !embedded && respond_to?(:ext_schema) && ext_schema
442
442
  hash
443
443
  end
444
444
 
@@ -572,7 +572,7 @@ module RelatonBib
572
572
  link.each { |l| out += l.to_asciibib prefix, link.size }
573
573
  out += medium.to_asciibib prefix if medium
574
574
  place.each { |pl| out += pl.to_asciibib prefix, place.size }
575
- extent.each { |ex| out += ex.to_asciibib "#{pref}extent", extent.size }
575
+ extent.each { |ex| out += ex.to_asciibib prefix, extent.size }
576
576
  out += size.to_asciibib pref if size
577
577
  accesslocation.each { |al| out += "#{pref}accesslocation:: #{al}\n" }
578
578
  classification.each do |cl|
@@ -634,7 +634,7 @@ module RelatonBib
634
634
  series.each { |s| s.to_xml builder }
635
635
  medium&.to_xml builder
636
636
  place.each { |pl| pl.to_xml builder }
637
- extent.each { |e| builder.extent { e.to_xml builder } }
637
+ extent.each { |e| e.to_xml builder }
638
638
  size&.to_xml builder
639
639
  accesslocation.each { |al| builder.accesslocation al }
640
640
  license.each { |l| builder.license l }
@@ -644,10 +644,9 @@ module RelatonBib
644
644
  kwrd.each { |kw| builder.keyword { kw.to_xml(builder) } }
645
645
  validity&.to_xml builder
646
646
  if block_given? then yield builder
647
- elsif opts[:bibdata] && (doctype || editorialgroup || ics&.any? ||
648
- structuredidentifier&.presence?)
647
+ elsif opts[:bibdata] && has_ext?
649
648
  ext = builder.ext do |b|
650
- doctype.to_xml b if doctype
649
+ doctype&.to_xml b
651
650
  b.subdoctype subdoctype if subdoctype
652
651
  editorialgroup&.to_xml b
653
652
  ics.each { |i| i.to_xml b }
@@ -661,5 +660,9 @@ module RelatonBib
661
660
  xml["schema-version"] = schema unless opts[:embedded]
662
661
  xml
663
662
  end
663
+
664
+ def has_ext? # rubocop:disable Metrics/CyclomaticComplexity
665
+ doctype || subdoctype || editorialgroup || ics&.any? || structuredidentifier&.presence?
666
+ end
664
667
  end
665
668
  end
@@ -169,9 +169,9 @@ module RelatonBib
169
169
  end
170
170
 
171
171
  # @param bibtex [BibTeX::Entry]
172
- # @return [Array<RelatonBib::BibItemLocality>]
172
+ # @return [Array<RelatonBib::Extent>]
173
173
  def fetch_extent(bibtex) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
174
- bibtex.select do |k, _v|
174
+ locs = bibtex.select do |k, _v|
175
175
  %i[chapter pages volume].include? k
176
176
  end.reduce([]) do |mem, loc|
177
177
  if loc[0] == :pages
@@ -182,8 +182,9 @@ module RelatonBib
182
182
  from = loc[1].to_s
183
183
  to = nil
184
184
  end
185
- mem << BibItemLocality.new(type, from, to)
185
+ mem << Locality.new(type, from, to)
186
186
  end
187
+ [RelatonBib::Extent.new(locs)]
187
188
  end
188
189
 
189
190
  # @param bibtex [BibTeX::Entry]
@@ -39,24 +39,22 @@ module RelatonBib
39
39
  # @param description [RelatonBib::FormattedString, nil]
40
40
  # @param bibitem [RelatonBib::BibliographicItem,
41
41
  # RelatonIso::IsoBibliographicItem]
42
- # @param locality [Array<RelatonBib::Locality, RelatonBib::LocalityStack>]
42
+ # @param locality [Array<RelatonBib::Locality>]
43
+ # @param locality_stack [Array<RelatonBib::LocalityStack>]
43
44
  # @param source_locality [Array<RelatonBib::SourceLocality,
44
45
  # RelatonBib::SourceLocalityStack>]
45
- def initialize(type:, bibitem:, description: nil, locality: [],
46
- source_locality: [])
46
+ def initialize(type:, bibitem:, **args)
47
47
  type = "obsoletes" if type == "Now withdrawn"
48
48
  unless self.class::TYPES.include? type
49
49
  Util.warn "Invalid relation type: `#{type}`"
50
50
  end
51
51
  @type = type
52
- @description = description
53
- @locality = locality
54
- @source_locality = source_locality
52
+ @description = args[:description]
53
+ @locality = args[:locality] || args[:locality_stack] || []
54
+ @source_locality = args[:source_locality] || args[:source_locality_stack] || []
55
55
  @bibitem = bibitem
56
56
  end
57
57
 
58
- # rubocop:disable Metrics/AbcSize
59
-
60
58
  # @param builder [Nokogiri::XML::Builder]
61
59
  def to_xml(builder, **opts)
62
60
  opts.delete :bibdata
@@ -68,13 +66,16 @@ module RelatonBib
68
66
  source_locality.each { |l| l.to_xml builder }
69
67
  end
70
68
  end
71
- # rubocop:enable Metrics/AbcSize
72
69
 
73
70
  # @return [Hash]
74
71
  def to_hash # rubocop:disable Metrics/AbcSize
75
72
  hash = { "type" => type, "bibitem" => bibitem.to_hash(embedded: true) }
76
73
  hash["description"] = description.to_hash if description
77
- hash["locality"] = single_element_array(locality) if locality&.any?
74
+ locality.each_with_object(hash) do |l, obj|
75
+ k, v = l.to_hash.first
76
+ hash[k] ||= []
77
+ hash[k] << v
78
+ end
78
79
  if source_locality&.any?
79
80
  hash["source_locality"] = single_element_array(source_locality)
80
81
  end
@@ -12,11 +12,9 @@ module RelatonBib
12
12
  # @option relation [String] :type
13
13
  # @option relation [String] :identifier
14
14
  # @option relation [String, NIllClass] :url (nil)
15
- # @option relation [Array<RelatonBib::Locality,
16
- # RelatonBib::LocalityStack>] :locality
17
- # @option relation [Array<RelatonBib::SourceLocality,
18
- # RelatonBib::SourceLocalityStack>] :source_locality
19
- # @option relation [RelatonBib::BibliographicItem, NillClass] :bibitem (nil)
15
+ # @option relation [Array<RelatonBib::Locality, RelatonBib::LocalityStack>] :locality
16
+ # @option relation [Array<RelatonBib::SourceLocality, RelatonBib::SourceLocalityStack>] :source_locality
17
+ # @option relation [RelatonBib::BibliographicItem, nil] :bibitem (nil)
20
18
  def initialize(relation)
21
19
  @array = relation.map { |r| r.is_a?(Hash) ? DocumentRelation.new(**r) : r }
22
20
  end
@@ -0,0 +1,39 @@
1
+ module RelatonBib
2
+ class Extent
3
+ attr_accessor :locality
4
+
5
+ #
6
+ # @param [Array<RelatonBib::Locality, RelatonBib::LocalityStack>] locality
7
+ #
8
+ def initialize(locality)
9
+ @locality = locality
10
+ end
11
+
12
+ def to_xml(builder)
13
+ builder.extent do |b|
14
+ locality.each { |l| l.to_xml(b) }
15
+ end
16
+ end
17
+
18
+ def to_hash
19
+ hash = Hash.new { |h, k| h[k] = [] }
20
+ locality.each_with_object(hash) do |l, obj|
21
+ k, v = l.to_hash.first
22
+ obj[k] << v
23
+ end
24
+ end
25
+
26
+ def to_asciibib(prefix = "", count = 1)
27
+ pref = prefix.empty? ? "extent" : "#{prefix}.extent"
28
+ out = count > 1 ? "#{pref}::\n" : ""
29
+ locality.each do |l|
30
+ out += l.to_asciibib(pref, locality.size)
31
+ end
32
+ out
33
+ end
34
+
35
+ def to_bibtex(item)
36
+ locality.map { |l| l.to_bibtex(item) }.join
37
+ end
38
+ end
39
+ end
@@ -126,7 +126,7 @@ module RelatonBib
126
126
  str.gsub(/(?<=<)\w+:(?=\w+>)/, "").gsub(/(?<=<\/)\w+:(?=\w+>)/, "")
127
127
  .gsub(/<i>/, "<em>").gsub(/<\/i>/, "</em>")
128
128
  .gsub(/<b>/, "<strong>").gsub(/<\/b>/, "</strong>")
129
- .gsub(/<(?!\/?(em|strong|stem|sup|sub|tt|br\s?\/|p))[^\s!]\/?.*?>/, "")
129
+ .gsub(/<(?!\/?(em|strong|stem|sup|sub|tt|br\s?\/|p|ol|ul|li))[^\s!]\/?.*?>/i, "")
130
130
  .gsub(/\s+([.,:;!?<])/, "\\1").strip.squeeze(" ")
131
131
  end
132
132
  end
@@ -1,11 +1,9 @@
1
1
  module RelatonBib
2
2
  module HashConverter
3
3
  extend self
4
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
5
-
6
4
  # @param args [Hash]
7
5
  # @return [Hash]
8
- def hash_to_bib(args)
6
+ def hash_to_bib(args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
9
7
  return nil unless args.is_a?(Hash)
10
8
 
11
9
  ret = Marshal.load(Marshal.dump(symbolize(args))) # deep copy
@@ -34,13 +32,21 @@ module RelatonBib
34
32
  keyword_hash_to_bib(ret)
35
33
  # ret[:keyword] = RelatonBib.array(ret[:keyword])
36
34
  ret[:license] = RelatonBib.array(ret[:license])
35
+ # editorialgroup_hash_to_bib ret
36
+ # ics_hash_to_bib ret
37
+ # structuredidentifier_hash_to_bib ret
38
+ # doctype_hash_to_bib ret
39
+ ext_has_to_bib ret
40
+ ret
41
+ end
42
+
43
+ def ext_has_to_bib(ret)
44
+ doctype_hash_to_bib ret
45
+ ret[:subdoctype] = ret[:ext][:subdoctype] if ret.dig(:ext, :subdoctype)
37
46
  editorialgroup_hash_to_bib ret
38
47
  ics_hash_to_bib ret
39
48
  structuredidentifier_hash_to_bib ret
40
- doctype_hash_to_bib ret
41
- ret
42
49
  end
43
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
44
50
 
45
51
  def keyword_hash_to_bib(ret)
46
52
  ret[:keyword] = RelatonBib.array(ret[:keyword]).map do |keyword|
@@ -52,18 +58,19 @@ module RelatonBib
52
58
  return unless ret[:extent]
53
59
 
54
60
  ret[:extent] = RelatonBib.array(ret[:extent]).map do |e|
55
- locality e
56
- # ret[:extent][i] = Locality.new(e[:type], e[:reference_from],
57
- # e[:reference_to])
61
+ RelatonBib::Extent.new locality(e)
58
62
  end
59
63
  end
60
64
 
61
65
  def locality(loc)
62
66
  if loc[:locality_stack]
63
- LocalityStack.new(loc[:locality_stack].map { |l| locality(l) })
67
+ RelatonBib.array(loc[:locality_stack]).map do |l|
68
+ LocalityStack.new locality(l)
69
+ end
64
70
  else
65
- l = loc[:locality]
66
- Locality.new(l[:type], l[:reference_from], l[:reference_to])
71
+ RelatonBib.array(loc[:locality]).map do |l|
72
+ Locality.new(l[:type], l[:reference_from], l[:reference_to])
73
+ end
67
74
  end
68
75
  end
69
76
 
@@ -339,17 +346,17 @@ module RelatonBib
339
346
  end
340
347
 
341
348
  # @param ret [Hash]
342
- def relations_hash_to_bib(ret)
349
+ def relations_hash_to_bib(ret) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
343
350
  return unless ret[:relation]
344
351
 
345
352
  ret[:relation] = RelatonBib.array(ret[:relation])
346
- ret[:relation]&.each do |r|
347
- if r[:description]
348
- r[:description] = FormattedString.new(**r[:description])
349
- end
350
- relation_bibitem_hash_to_bib(r)
351
- relation_locality_hash_to_bib(r)
352
- relation_source_locality_hash_to_bib(r)
353
+ ret[:relation]&.each do |rel|
354
+ rel[:description] = FormattedString.new(**rel[:description]) if rel[:description]
355
+ relation_bibitem_hash_to_bib(rel)
356
+ relation_locality_hash_to_bib(rel)
357
+ relation_locality_stack_hash_to_bib(rel)
358
+ relation_source_locality_hash_to_bib(rel)
359
+ relaton_source_locality_stack_hash_to_bib(rel)
353
360
  end
354
361
  end
355
362
 
@@ -372,36 +379,54 @@ module RelatonBib
372
379
  # @param rel [Hash] relation
373
380
  # @return [RelatonBib::LocalityStack]
374
381
  def relation_locality_hash_to_bib(rel)
375
- rel[:locality] = RelatonBib.array(rel[:locality])&.map do |bl|
376
- LocalityStack.new locality_locality_stack(bl)
382
+ return unless rel[:locality]&.any?
383
+
384
+ rel[:locality] = RelatonBib.array(rel[:locality]).map do |bl|
385
+ Locality.new(bl[:type], bl[:reference_from], bl[:reference_to])
377
386
  end
378
387
  end
379
388
 
380
- def locality_locality_stack(lls)
381
- if lls[:locality_stack]
382
- RelatonBib.array(lls[:locality_stack]).map do |lc|
383
- l = lc[:locality] || lc
384
- Locality.new(l[:type], l[:reference_from], l[:reference_to])
385
- end
386
- else
387
- [Locality.new(lls[:type], lls[:reference_from], lls[:reference_to])]
389
+ def relation_locality_stack_hash_to_bib(rel)
390
+ return unless rel[:locality_stack]&.any?
391
+
392
+ rel[:locality_stack] = RelatonBib.array(rel[:locality_stack]).map do |ls|
393
+ LocalityStack.new relation_locality_hash_to_bib(ls)
388
394
  end
389
395
  end
390
396
 
397
+ # def locality_locality_stack(lls)
398
+ # if lls[:locality_stack]
399
+ # RelatonBib.array(lls[:locality_stack]).map do |lc|
400
+ # l = lc[:locality] || lc
401
+ # Locality.new(l[:type], l[:reference_from], l[:reference_to])
402
+ # end
403
+ # else
404
+ # [Locality.new(lls[:type], lls[:reference_from], lls[:reference_to])]
405
+ # end
406
+ # end
407
+
391
408
  # @param rel [Hash] relation
392
409
  def relation_source_locality_hash_to_bib(rel) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
393
- rel[:source_locality] = RelatonBib.array(rel[:source_locality])&.map do |sl|
394
- sls = if sl[:source_locality_stack]
395
- RelatonBib.array(sl[:source_locality_stack]).map do |l|
396
- SourceLocality.new(l[:type], l[:reference_from],
397
- l[:reference_to])
398
- end
399
- else
400
- l = SourceLocality.new(sl[:type], sl[:reference_from],
401
- sl[:reference_to])
402
- [l]
403
- end
404
- SourceLocalityStack.new sls
410
+ return unless rel[:source_locality]&.any?
411
+
412
+ rel[:source_locality] = RelatonBib.array(rel[:source_locality])&.map do |loc|
413
+ # sls = if sl[:source_locality_stack]
414
+ # RelatonBib.array(sl[:source_locality_stack]).map do |l|
415
+ # SourceLocality.new(l[:type], l[:reference_from], l[:reference_to])
416
+ # end
417
+ # else
418
+ # l = SourceLocality.new(sl[:type], sl[:reference_from], sl[:reference_to])
419
+ # [l]
420
+ # end
421
+ SourceLocality.new loc[:type], loc[:reference_from], loc[:reference_to]
422
+ end
423
+ end
424
+
425
+ def relaton_source_locality_stack_hash_to_bib(rel)
426
+ return unless rel[:source_locality_stack]&.any?
427
+
428
+ rel[:source_locality_stack] = RelatonBib.array(rel[:source_locality_stack]).map do |loc|
429
+ SourceLocalityStack.new relation_source_locality_hash_to_bib(loc)
405
430
  end
406
431
  end
407
432
 
@@ -465,9 +490,10 @@ module RelatonBib
465
490
 
466
491
  # @param ret [Hash]
467
492
  def editorialgroup_hash_to_bib(ret)
468
- return unless ret[:editorialgroup]
493
+ eg = ret.dig(:ext, :editorialgroup) || ret[:editorialgroup] # @todo remove ret[:editorialgroup] in the future
494
+ return unless eg
469
495
 
470
- technical_committee = RelatonBib.array(ret[:editorialgroup]).map do |wg|
496
+ technical_committee = RelatonBib.array(eg).map do |wg|
471
497
  TechnicalCommittee.new WorkGroup.new(**wg)
472
498
  end
473
499
  ret[:editorialgroup] = EditorialGroup.new technical_committee
@@ -475,16 +501,18 @@ module RelatonBib
475
501
 
476
502
  # @param ret [Hash]
477
503
  def ics_hash_to_bib(ret)
478
- return unless ret[:ics]
504
+ ics = ret.dig(:ext, :ics) || ret[:ics] # @todo remove ret[:ics] in the future
505
+ return unless ics
479
506
 
480
- ret[:ics] = RelatonBib.array(ret[:ics]).map { |ics| ICS.new(**ics) }
507
+ ret[:ics] = RelatonBib.array(ics).map { |item| ICS.new(**item) }
481
508
  end
482
509
 
483
510
  # @param ret [Hash]
484
511
  def structuredidentifier_hash_to_bib(ret)
485
- return unless ret[:structuredidentifier]
512
+ struct_id = ret.dig(:ext, :structuredidentifier) || ret[:structuredidentifier] # @todo remove ret[:structuredidentifier] in the future
513
+ return unless struct_id
486
514
 
487
- sids = RelatonBib.array(ret[:structuredidentifier]).map do |si|
515
+ sids = RelatonBib.array(struct_id).map do |si|
488
516
  si[:agency] = RelatonBib.array si[:agency]
489
517
  StructuredIdentifier.new(**si)
490
518
  end
@@ -527,12 +555,10 @@ module RelatonBib
527
555
  end
528
556
 
529
557
  def doctype_hash_to_bib(ret)
530
- return unless ret[:doctype]
558
+ doctype = ret.dig(:ext, :doctype) || ret[:doctype] # @todo remove ret[:doctype] in the future
559
+ return unless doctype
531
560
 
532
- ret[:doctype] = if ret[:doctype].is_a?(String)
533
- create_doctype(type: ret[:doctype])
534
- else create_doctype(**ret[:doctype])
535
- end
561
+ ret[:doctype] = doctype.is_a?(String) ? create_doctype(type: doctype) : create_doctype(**doctype)
536
562
  end
537
563
 
538
564
  def create_doctype(**args)
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "1.19.7".freeze
2
+ VERSION = "1.20.0".freeze
3
3
  end
@@ -219,11 +219,11 @@ module RelatonBib
219
219
  #
220
220
  # @param [Nokogiri::XML::Element] item item element
221
221
  #
222
- # @return [Array<RelatonBib::Locality, RelatonBib::LocalityStack>] extent
222
+ # @return [Array<RelatonBib::Extent>] extent
223
223
  #
224
224
  def fetch_extent(item)
225
- item.xpath("./extent").reduce([]) do |a, ex|
226
- a + localities(ex)
225
+ item.xpath("./extent").map do |ex|
226
+ RelatonBib::Extent.new localities(ex)
227
227
  end
228
228
  end
229
229
 
@@ -290,7 +290,7 @@ module RelatonBib
290
290
  def fetch_docid(item)
291
291
  item.xpath("./docidentifier").map do |id|
292
292
  args = id.to_h.transform_keys(&:to_sym)
293
- args[:id] = id.children.map { |n| n.text? ? n.content : n.to_xml }.join
293
+ args[:id] = id.text
294
294
  args[:primary] = id[:primary] == "true" ? true : nil
295
295
  create_docid(**args)
296
296
  end
@@ -644,13 +644,13 @@ module RelatonBib
644
644
  # @return [Array<RelatonBib::SourceLocality,
645
645
  # RelatonBib::SourceLocalityStack>]
646
646
  def source_localities(rel)
647
- rel.xpath("./sourceLocality|./sourceLocalityStack").map do |lc|
648
- if lc[:type]
649
- SourceLocalityStack.new [locality(lc, SourceLocality)]
647
+ rel.xpath("./sourceLocality|./sourceLocalityStack").map do |loc|
648
+ if loc.name == "sourceLocality"
649
+ # src_locs = loc.xapth("./sourceLocality").map { |sl| locality(sl, SourceLocality) }
650
+ # SourceLocalityStack.new src_locs
651
+ locality loc, SourceLocality
650
652
  else
651
- sls = lc.xpath("./sourceLocality").map do |l|
652
- locality l, SourceLocality
653
- end
653
+ sls = loc.xpath("./sourceLocality").map { |l| locality l, SourceLocality }
654
654
  SourceLocalityStack.new sls
655
655
  end
656
656
  end
data/relaton-bib.gemspec CHANGED
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "bibtex-ruby"
28
28
  spec.add_dependency "htmlentities"
29
29
  spec.add_dependency "iso639"
30
- spec.add_dependency "nokogiri", "~> 1.16"
30
+ spec.add_dependency "nokogiri", "~> 1.16.0"
31
31
  spec.add_dependency "relaton-logger", "~> 0.2.0"
32
32
  end
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.19.7
4
+ version: 1.20.0
5
5
  platform: ruby
6
- original_platform: ''
7
6
  authors:
8
7
  - Ribose Inc.
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-19 00:00:00.000000000 Z
11
+ date: 2024-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.16'
75
+ version: 1.16.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.16'
82
+ version: 1.16.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: relaton-logger
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -144,6 +144,7 @@ files:
144
144
  - lib/relaton_bib/document_type.rb
145
145
  - lib/relaton_bib/edition.rb
146
146
  - lib/relaton_bib/editorial_group.rb
147
+ - lib/relaton_bib/extent.rb
147
148
  - lib/relaton_bib/forename.rb
148
149
  - lib/relaton_bib/formatted_ref.rb
149
150
  - lib/relaton_bib/formatted_string.rb
@@ -176,6 +177,7 @@ homepage: https://github.com/relaton/relaton-bib
176
177
  licenses:
177
178
  - BSD-2-Clause
178
179
  metadata: {}
180
+ post_install_message:
179
181
  rdoc_options: []
180
182
  require_paths:
181
183
  - lib
@@ -190,7 +192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
192
  - !ruby/object:Gem::Version
191
193
  version: '0'
192
194
  requirements: []
193
- rubygems_version: 3.6.0
195
+ rubygems_version: 3.3.27
196
+ signing_key:
194
197
  specification_version: 4
195
198
  summary: 'RelatonBib: Ruby XMLDOC impementation.'
196
199
  test_files: []