relaton-bib 1.20.7 → 2.0.0.pre.alpha.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.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/README.adoc +183 -154
  4. data/bin/console +1 -1
  5. data/grammars/basicdoc.rng +1516 -645
  6. data/grammars/biblio-standoc.rng +100 -20
  7. data/grammars/biblio.rng +959 -356
  8. data/grammars/versions.json +10 -10
  9. data/lib/relaton/bib/hash_parser_v1.rb +711 -0
  10. data/lib/relaton/bib/item_data.rb +168 -0
  11. data/lib/relaton/bib/model/address.rb +22 -0
  12. data/lib/relaton/bib/model/affiliation.rb +16 -0
  13. data/lib/relaton/bib/model/bibdata.rb +24 -0
  14. data/lib/relaton/bib/model/bibitem.rb +23 -0
  15. data/lib/relaton/bib/model/contact.rb +18 -0
  16. data/lib/relaton/bib/model/contribution_info.rb +16 -0
  17. data/lib/relaton/bib/model/contributor.rb +71 -0
  18. data/lib/relaton/bib/model/copyright.rb +27 -0
  19. data/lib/relaton/bib/model/date.rb +29 -0
  20. data/lib/relaton/bib/model/depiction.rb +14 -0
  21. data/lib/relaton/bib/model/docidentifier.rb +33 -0
  22. data/lib/relaton/bib/model/doctype.rb +14 -0
  23. data/lib/relaton/bib/model/edition.rb +14 -0
  24. data/lib/relaton/bib/model/editorial_group.rb +14 -0
  25. data/lib/relaton/bib/model/ext.rb +29 -0
  26. data/lib/relaton/bib/model/extent.rb +16 -0
  27. data/lib/relaton/bib/model/full_name_type.rb +64 -0
  28. data/lib/relaton/bib/model/fullname.rb +11 -0
  29. data/lib/relaton/bib/model/ics.rb +14 -0
  30. data/lib/relaton/bib/model/image.rb +28 -0
  31. data/lib/relaton/bib/model/item.rb +129 -0
  32. data/lib/relaton/bib/model/item_base.rb +19 -0
  33. data/lib/relaton/bib/model/keyword.rb +30 -0
  34. data/lib/relaton/bib/model/locality.rb +18 -0
  35. data/lib/relaton/bib/model/locality_stack.rb +14 -0
  36. data/lib/relaton/bib/model/localized_string.rb +57 -0
  37. data/lib/relaton/bib/model/localized_string_attrs.rb +24 -0
  38. data/lib/relaton/bib/model/logo.rb +12 -0
  39. data/lib/relaton/bib/model/medium.rb +22 -0
  40. data/lib/relaton/bib/model/note.rb +16 -0
  41. data/lib/relaton/bib/model/organization.rb +13 -0
  42. data/lib/relaton/bib/model/organization_type.rb +42 -0
  43. data/lib/relaton/bib/model/person.rb +36 -0
  44. data/lib/relaton/bib/model/phone.rb +14 -0
  45. data/lib/relaton/bib/model/place.rb +33 -0
  46. data/lib/relaton/bib/model/price.rb +14 -0
  47. data/lib/relaton/bib/model/relation.rb +43 -0
  48. data/lib/relaton/bib/model/series.rb +32 -0
  49. data/lib/relaton/bib/model/size.rb +23 -0
  50. data/lib/relaton/bib/model/source_locality_stack.rb +14 -0
  51. data/lib/relaton/bib/model/status.rb +27 -0
  52. data/lib/relaton/bib/model/structured_identifier.rb +48 -0
  53. data/lib/relaton/bib/model/subdivision.rb +14 -0
  54. data/lib/relaton/bib/model/technical_committee.rb +14 -0
  55. data/lib/relaton/bib/model/title.rb +18 -0
  56. data/lib/relaton/bib/model/uri.rb +18 -0
  57. data/lib/relaton/bib/model/validity.rb +16 -0
  58. data/lib/relaton/bib/model/version.rb +14 -0
  59. data/lib/relaton/bib/model/workgroup.rb +20 -0
  60. data/lib/relaton/bib/parser/rfc_address.rb +60 -0
  61. data/lib/relaton/bib/parser/rfc_contacts.rb +35 -0
  62. data/lib/relaton/bib/parser/rfc_docidentifier.rb +70 -0
  63. data/lib/relaton/bib/parser/rfc_organization.rb +31 -0
  64. data/lib/relaton/bib/parser/rfc_person.rb +42 -0
  65. data/lib/relaton/bib/parser/rfc_reference.rb +143 -0
  66. data/lib/relaton/bib/parser/rfc_referencegroup.rb +45 -0
  67. data/lib/relaton/bib/parser/rfc_shared.rb +23 -0
  68. data/lib/relaton/bib/renderer/bibtex_builder.rb +348 -0
  69. data/lib/relaton/bib/renderer/rfc.rb +297 -0
  70. data/lib/relaton/bib/util.rb +18 -0
  71. data/lib/relaton/bib/version.rb +5 -0
  72. data/lib/{relaton_bib.rb → relaton/bib.rb} +47 -36
  73. data/lib/{relaton_bib → relaton}/bibtex_parser.rb +24 -27
  74. data/lib/{relaton_bib → relaton}/bibxml_parser.rb +43 -46
  75. data/lib/{relaton_bib → relaton}/hit.rb +3 -3
  76. data/lib/{relaton_bib → relaton}/hit_collection.rb +2 -2
  77. data/lib/{relaton_bib → relaton}/workers_pool.rb +1 -1
  78. data/lib/{relaton_bib → relaton}/xml_parser.rb +49 -51
  79. data/relaton-bib.gemspec +8 -8
  80. metadata +95 -74
  81. data/lib/relaton_bib/bib_item_locality.rb +0 -175
  82. data/lib/relaton_bib/biblio_note.rb +0 -72
  83. data/lib/relaton_bib/biblio_version.rb +0 -46
  84. data/lib/relaton_bib/bibliographic_date.rb +0 -119
  85. data/lib/relaton_bib/bibliographic_item.rb +0 -668
  86. data/lib/relaton_bib/bibliographic_size.rb +0 -103
  87. data/lib/relaton_bib/classification.rb +0 -40
  88. data/lib/relaton_bib/config.rb +0 -16
  89. data/lib/relaton_bib/contribution_info.rb +0 -117
  90. data/lib/relaton_bib/contributor.rb +0 -277
  91. data/lib/relaton_bib/copyright_association.rb +0 -79
  92. data/lib/relaton_bib/document_identifier.rb +0 -118
  93. data/lib/relaton_bib/document_relation.rb +0 -95
  94. data/lib/relaton_bib/document_relation_collection.rb +0 -57
  95. data/lib/relaton_bib/document_status.rb +0 -92
  96. data/lib/relaton_bib/document_type.rb +0 -52
  97. data/lib/relaton_bib/edition.rb +0 -55
  98. data/lib/relaton_bib/editorial_group.rb +0 -41
  99. data/lib/relaton_bib/extent.rb +0 -39
  100. data/lib/relaton_bib/forename.rb +0 -65
  101. data/lib/relaton_bib/formatted_ref.rb +0 -17
  102. data/lib/relaton_bib/formatted_string.rb +0 -133
  103. data/lib/relaton_bib/full_name.rb +0 -108
  104. data/lib/relaton_bib/hash_converter.rb +0 -568
  105. data/lib/relaton_bib/ics.rb +0 -42
  106. data/lib/relaton_bib/image.rb +0 -95
  107. data/lib/relaton_bib/localized_string.rb +0 -149
  108. data/lib/relaton_bib/medium.rb +0 -76
  109. data/lib/relaton_bib/organization.rb +0 -165
  110. data/lib/relaton_bib/person.rb +0 -129
  111. data/lib/relaton_bib/place.rb +0 -203
  112. data/lib/relaton_bib/renderer/bibtex_builder.rb +0 -312
  113. data/lib/relaton_bib/renderer/bibxml.rb +0 -296
  114. data/lib/relaton_bib/series.rb +0 -119
  115. data/lib/relaton_bib/structured_identifier.rb +0 -173
  116. data/lib/relaton_bib/technical_committee.rb +0 -34
  117. data/lib/relaton_bib/typed_title_string.rb +0 -191
  118. data/lib/relaton_bib/typed_uri.rb +0 -57
  119. data/lib/relaton_bib/util.rb +0 -16
  120. data/lib/relaton_bib/validity.rb +0 -52
  121. data/lib/relaton_bib/version.rb +0 -3
  122. data/lib/relaton_bib/workgroup.rb +0 -58
  123. /data/lib/{relaton_bib → relaton}/deep_dup.rb +0 -0
@@ -1,33 +1,42 @@
1
1
  require "relaton/logger"
2
2
  require "forwardable"
3
- require "yaml"
4
- require "htmlentities"
5
- require "relaton_bib/version"
6
- require "relaton_bib/deep_dup"
7
- require "relaton_bib/util"
8
- require "relaton_bib/localized_string"
9
- require "relaton_bib/forename"
10
- require "relaton_bib/full_name"
11
- require "relaton_bib/contributor"
12
- require "relaton_bib/document_type"
13
- require "relaton_bib/image"
14
- require "relaton_bib/bibliographic_item"
15
- require "relaton_bib/hit_collection"
16
- require "relaton_bib/hit"
17
- require "relaton_bib/bibxml_parser"
18
- require "relaton_bib/renderer/bibtex_builder"
19
- require "relaton_bib/renderer/bibxml"
3
+ # require "htmlentities"
4
+ require "bibtex"
5
+ require "iso639"
6
+ require "rfcxml"
7
+ require_relative "bib/version"
8
+ require_relative "bib/util"
9
+ require_relative "bib/item_data"
10
+ require_relative "bib/model/item"
11
+ require_relative "bib/model/item_base"
12
+ require_relative "bib/model/bibitem"
13
+ require_relative "bib/model/bibdata"
14
+ require_relative "bibxml_parser"
15
+ require_relative "bib/renderer/bibtex_builder"
16
+ require_relative "bib/renderer/rfc"
17
+ require_relative "bib/parser/rfc_reference"
18
+ require_relative "bib/parser/rfc_referencegroup"
19
+ require_relative "bib/model/relation"
20
20
 
21
- module RelatonBib
22
- class Error < StandardError; end
21
+ module Relaton
22
+ # class Error < StandardError; end
23
23
 
24
24
  class RequestError < StandardError; end
25
25
 
26
26
  class << self
27
+ #
28
+ # Read schema versions from file
29
+ #
30
+ # @return [Hash{String=>String}] schema versions
31
+ #
32
+ def schema_versions
33
+ @@schema_versions ||= JSON.parse File.read(File.join(__dir__, "../../grammars/versions.json"))
34
+ end
35
+
27
36
  # @param date [String, Integer, Date] date
28
37
  # @param str [Boolean] return string or Date
29
38
  # @return [Date, String, nil] date
30
- def parse_date(date, str = true) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity,Metrics/AbcSize
39
+ def parse_date(date, str: true) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength
31
40
  return date if date.is_a?(Date)
32
41
 
33
42
  case date.to_s
@@ -58,7 +67,7 @@ module RelatonBib
58
67
  date = Date.strptime(date, format)
59
68
  str ? date.strftime(outformat || format) : date
60
69
  rescue Date::Error => e
61
- Util.warn "#{date} #{e.message}"
70
+ Bib::Util.warn "#{date} #{e.message}"
62
71
  date
63
72
  end
64
73
 
@@ -90,22 +99,24 @@ module RelatonBib
90
99
  end
91
100
  end
92
101
 
93
- def self.grammar_hash
94
- # gem_path = File.expand_path "..", __dir__
95
- # grammars_path = File.join gem_path, "grammars", "*"
96
- # grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
97
- Digest::MD5.hexdigest RelatonBib::VERSION # grammars
102
+ module Bib
103
+ def self.grammar_hash
104
+ # gem_path = File.expand_path "..", __dir__
105
+ # grammars_path = File.join gem_path, "grammars", "*"
106
+ # grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
107
+ Digest::MD5.hexdigest Relaton::Bib::VERSION # grammars
108
+ end
98
109
  end
99
110
 
100
- private
111
+ # private
101
112
 
102
- # @param array [Array]
103
- # @return [Array<String>, String]
104
- def single_element_array(array)
105
- # if array.size > 1
106
- array.map { |e| e.is_a?(String) ? e : e.to_hash }
107
- # else
108
- # array.first.is_a?(String) ? array[0] : array.first&.to_hash
109
- # end
110
- end
113
+ # # @param array [Array]
114
+ # # @return [Array<String>, String]
115
+ # def single_element_array(array)
116
+ # # if array.size > 1
117
+ # array.map { |e| e.is_a?(String) ? e : e.to_hash }
118
+ # # else
119
+ # # array.first.is_a?(String) ? array[0] : array.first&.to_hash
120
+ # # end
121
+ # end
111
122
  end
@@ -1,15 +1,12 @@
1
- require "bibtex"
2
- require "iso639"
3
-
4
- module RelatonBib
5
- # @todo: move this class to the RelatonBib::Bibtex module
1
+ module Relaton
2
+ # @todo: move this class to the Relaton::Bib::Bibtex module
6
3
  class BibtexParser
7
4
  class << self
8
5
  # @param bibtex [String]
9
- # @return [Hash{String=>RelatonBib::BibliographicItem}]
6
+ # @return [Hash{String=>Relaton::Bib::Item}]
10
7
  def from_bibtex(bibtex) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
11
8
  BibTeX.parse(bibtex).reduce({}) do |h, bt|
12
- h[bt.key] = BibliographicItem.new(
9
+ h[bt.key] = Item.new(
13
10
  id: bt.key,
14
11
  docid: fetch_docid(bt),
15
12
  fetched: fetch_fetched(bt),
@@ -35,12 +32,12 @@ module RelatonBib
35
32
  private
36
33
 
37
34
  # @param bibtex [BibTeX::Entry]
38
- # @return [Array<RelatonBib::DocumentIdentifier>]
35
+ # @return [Array<Relaton::Bib::Docidentifier>]
39
36
  def fetch_docid(bibtex) # rubocop:disable Metrics/AbcSize
40
37
  docid = []
41
- docid << DocumentIdentifier.new(id: bibtex.isbn.to_s, type: "isbn") if bibtex["isbn"]
42
- docid << DocumentIdentifier.new(id: bibtex.lccn.to_s, type: "lccn") if bibtex["lccn"]
43
- docid << DocumentIdentifier.new(id: bibtex.issn.to_s, type: "issn") if bibtex["issn"]
38
+ docid << Docidentifier.new(id: bibtex.isbn.to_s, type: "isbn") if bibtex["isbn"]
39
+ docid << Docidentifier.new(id: bibtex.lccn.to_s, type: "lccn") if bibtex["lccn"]
40
+ docid << Docidentifier.new(id: bibtex.issn.to_s, type: "issn") if bibtex["issn"]
44
41
  docid
45
42
  end
46
43
 
@@ -68,12 +65,12 @@ module RelatonBib
68
65
  end
69
66
 
70
67
  # @param bibtex [BibTeX::Entry]
71
- # @return [RelatonBib::TypedTitleStringCollection]
68
+ # @return [Relaton::Bib::TitleCollection]
72
69
  def fetch_title(bibtex)
73
70
  title = []
74
71
  title << { type: "main", content: bibtex.convert(:latex).title.to_s } if bibtex["title"]
75
72
  title << { type: "main", content: bibtex.convert(:latex).subtitle.to_s } if bibtex["subtitle"]
76
- TypedTitleStringCollection.new title
73
+ TitleCollection.new title
77
74
  end
78
75
 
79
76
  # @param bibtex [BibTeX::Entry]
@@ -113,7 +110,7 @@ module RelatonBib
113
110
  end
114
111
 
115
112
  # @param bibtex [BibTeX::Entry]
116
- # @return [Array<RelatonBib::Person>]
113
+ # @return [Array<Relaton::Bib::Person>]
117
114
  def fetch_person(bibtex, role, &_) # rubocop:disable Metrics/AbcSize
118
115
  bibtex[role]&.each do |name|
119
116
  parts = name.split ", "
@@ -142,7 +139,7 @@ module RelatonBib
142
139
  end
143
140
 
144
141
  # @param bibtex [BibTeX::Entry]
145
- # @return [RelatonBib::BiblioNoteCollection]
142
+ # @return [Relaton::Bib::BiblioNoteCollection]
146
143
  def fetch_note(bibtex) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
147
144
  bibtex.select do |k, _v|
148
145
  %i[annote howpublished comment note content].include? k
@@ -163,9 +160,9 @@ module RelatonBib
163
160
  def fetch_relation(bibtex)
164
161
  return [] unless bibtex["booktitle"]
165
162
 
166
- ttl = TypedTitleString.new(type: "main", content: bibtex.booktitle.to_s)
167
- title = TypedTitleStringCollection.new [ttl]
168
- [{ type: "partOf", bibitem: BibliographicItem.new(title: title) }]
163
+ ttl = Title.new(type: "main", content: bibtex.booktitle.to_s)
164
+ title = TitleCollection.new [ttl]
165
+ [{ type: "partOf", bibitem: Item.new(title: title) }]
169
166
  end
170
167
 
171
168
  # @param bibtex [BibTeX::Entry]
@@ -188,31 +185,31 @@ module RelatonBib
188
185
  end
189
186
 
190
187
  # @param bibtex [BibTeX::Entry]
191
- # @return [Array<RelatonBib::Series>]
188
+ # @return [Array<Relaton::Bib::Series>]
192
189
  def fetch_series(bibtex) # rubocop:disable Metrics/MethodLength
193
190
  series = []
194
191
  if bibtex["journal"]
195
192
  series << Series.new(
196
193
  type: "journal",
197
- title: TypedTitleString.new(content: bibtex.journal.to_s),
198
- number: bibtex["number"]&.to_s
194
+ title: Title.new(content: bibtex.journal.to_s),
195
+ number: bibtex["number"]&.to_s,
199
196
  )
200
197
  end
201
198
 
202
199
  if bibtex["series"]
203
- title = TypedTitleString.new content: bibtex.series.to_s
200
+ title = Title.new content: bibtex.series.to_s
204
201
  series << Series.new(title: title)
205
202
  end
206
203
  series
207
204
  end
208
205
 
209
206
  # @param bibtex [BibTeX::Entry]
210
- # @return [Array<RelatonBib::TypedUri>]
207
+ # @return [Array<Relaton::Bib::Bsource>]
211
208
  def fetch_link(bibtex) # rubocop:disable Metrics/AbcSize
212
209
  link = []
213
- link << TypedUri.new(type: "src", content: bibtex.url.to_s) if bibtex["url"]
214
- link << TypedUri.new(type: "doi", content: bibtex.doi.to_s) if bibtex["doi"]
215
- link << TypedUri.new(type: "file", content: bibtex.file2.to_s) if bibtex["file2"]
210
+ link << Bsource.new(type: "src", content: bibtex.url.to_s) if bibtex["url"]
211
+ link << Bsource.new(type: "doi", content: bibtex.doi.to_s) if bibtex["doi"]
212
+ link << Bsource.new(type: "file", content: bibtex.file2.to_s) if bibtex["file2"]
216
213
  link
217
214
  end
218
215
 
@@ -225,7 +222,7 @@ module RelatonBib
225
222
  end
226
223
 
227
224
  # @param bibtex [BibTeX::Entry]
228
- # @return [RelatonBib::Classification, nil]
225
+ # @return [Relaton::Bib::Classification, nil]
229
226
  def fetch_classification(bibtex)
230
227
  cls = []
231
228
  cls << Classification.new(type: "type", value: bibtex["type"].to_s) if bibtex["type"]
@@ -1,4 +1,4 @@
1
- module RelatonBib
1
+ module Relaton
2
2
  module BibXMLParser
3
3
  # SeriesInfo what should be saved as docidentifiers in the Relaton model.
4
4
  SERIESINFONAMES = ["DOI"].freeze
@@ -31,7 +31,7 @@ module RelatonBib
31
31
  # @param is_relation [Boolean] don't add fetched date for relation if true
32
32
  # @param url [String, nil]
33
33
  # @param ver [String, nil] Internet Draft version
34
- # @return [RelatonBib::BibliographicItem]
34
+ # @return [Relaton::Bib::Item]
35
35
  def fetch_rfc(reference, is_relation: false, url: nil, ver: nil) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
36
36
  return unless reference
37
37
 
@@ -64,10 +64,10 @@ module RelatonBib
64
64
  end
65
65
 
66
66
  # @param attrs [Hash]
67
- # @return [RelatonBib::BibliographicItem]
67
+ # @return [Relaton::Bib::Item]
68
68
  def bib_item(**attrs)
69
69
  # attrs[:place] = ["Fremont, CA"]
70
- BibliographicItem.new(**attrs)
70
+ Item.new(**attrs)
71
71
  end
72
72
 
73
73
  # @param reference [Nokogiri::XML::Element]
@@ -82,7 +82,7 @@ module RelatonBib
82
82
  # @param reference [Nokogiri::XML::Element]
83
83
  # @param ver [String, nil] Internet Draft version
84
84
  #
85
- # @return [Array<RelatonBib::DocumentIdentifier>]
85
+ # @return [Array<Relaton::Bib::Docidentifier>]
86
86
  #
87
87
  def docids(reference, ver) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize
88
88
  ret = []
@@ -91,7 +91,7 @@ module RelatonBib
91
91
  if si
92
92
  id = si[:value]
93
93
  id.sub!(/(?<=-)\d{2}$/, ver) if ver
94
- ret << DocumentIdentifier.new(type: "Internet-Draft", id: id, primary: true)
94
+ ret << Bib::Docidentifier.new(type: "Internet-Draft", id: id, primary: true)
95
95
  else
96
96
  id = reference[:anchor] || reference[:docName] || reference[:number]
97
97
  ret << create_docid(id, ver) if id
@@ -106,7 +106,7 @@ module RelatonBib
106
106
  reference[atr]
107
107
  end
108
108
  type = pubid_type id
109
- ret << DocumentIdentifier.new(id: atrid, type: type, scope: atr)
109
+ ret << Bib::Docidentifier.new(id: atrid, type: type, scope: atr)
110
110
  end
111
111
  end
112
112
 
@@ -115,7 +115,7 @@ module RelatonBib
115
115
 
116
116
  id = si[:value]
117
117
  # id.sub!(/(?<=-)\d{2}$/, ver) if ver && si[:name] == "Internet-Draft"
118
- DocumentIdentifier.new(id: id, type: si[:name])
118
+ Bib::Docidentifier.new(id: id, type: si[:name])
119
119
  end.compact
120
120
  end
121
121
 
@@ -132,7 +132,7 @@ module RelatonBib
132
132
  pid = pref ? "#{pref} #{num}" : id
133
133
  type = pubid_type id
134
134
  end
135
- DocumentIdentifier.new(type: type, id: pid, primary: true)
135
+ Docidentifier.new(type: type, id: pid, primary: true)
136
136
  end
137
137
 
138
138
  def id_to_pref_num(id)
@@ -155,7 +155,7 @@ module RelatonBib
155
155
  # extract status
156
156
  # @param reference [Nokogiri::XML::Element]
157
157
  #
158
- # @return [RelatonBib::DocumentStatus]
158
+ # @return [Relaton::Bib::DocumentStatus]
159
159
  #
160
160
  def status(reference)
161
161
  st = reference.at("./seriesinfo[@status]")
@@ -188,26 +188,24 @@ module RelatonBib
188
188
  end
189
189
 
190
190
  # @param reference [Nokogiri::XML::Element]
191
- # @return [RelatonBib::FormattedRef, nil]
191
+ # @return [Relaton::Bib::Formattedref, nil]
192
192
  def formattedref(reference)
193
193
  return if reference.at "./front/title"
194
194
 
195
- cont = (reference[:anchor] || reference[:docName] || reference[:number])
195
+ cont = reference[:anchor] || reference[:docName] || reference[:number]
196
196
  if cont
197
- FormattedRef.new(
197
+ Formattedref.new(
198
198
  content: cont, language: language(reference), script: "Latn",
199
199
  )
200
200
  end
201
201
  end
202
202
 
203
203
  # @param reference [Nokogiri::XML::Element]
204
- # @return [Array<RelatonBib::FormattedString>]
204
+ # @return [Array<Relaton::Bib::FormattedString>]
205
205
  def abstracts(ref)
206
206
  ref.xpath("./front/abstract").map do |a|
207
- c = a.inner_html.gsub(/\s*(<\/?)t(>)\s*/, '\1p\2')
208
- .gsub(/[\t\n]/, " ").squeeze " "
209
- FormattedString.new(content: c, language: language(ref), script: "Latn",
210
- format: "text/html")
207
+ c = a.inner_html.gsub(/\s*(<\/?)t(>)\s*/, '\1p\2').gsub(/[\t\n]/, " ").squeeze " "
208
+ Bib::FormattedString.new(content: c, language: language(ref), script: "Latn", format: "text/html")
211
209
  end
212
210
  end
213
211
 
@@ -225,17 +223,16 @@ module RelatonBib
225
223
 
226
224
  # @param author [Nokogiri::XML::Element]
227
225
  # @param lang [String]
228
- # @return [RelatonBib::Person, nil]
226
+ # @return [Relaton::Bib::Person, nil]
229
227
  def person(author, lang)
230
228
  return unless author[:fullname] || author[:surname]
231
229
 
232
230
  name = full_name(author[:fullname], author[:surname], author[:initials], lang)
233
- Person.new(name: name, affiliation: affiliation(author),
234
- contact: contacts(author.at("./address")))
231
+ Bib::Person.new(name: name, affiliation: affiliation(author), contact: contacts(author.at("./address")))
235
232
  end
236
233
 
237
234
  # @param contrib [Nokogiri::XML::Element]
238
- # @return [RelatonBib::Organization, nil]
235
+ # @return [Relaton::Bib::Organization, nil]
239
236
  def organization(contrib)
240
237
  org = contrib.at("./organization")
241
238
  return unless org
@@ -251,10 +248,10 @@ module RelatonBib
251
248
  # @param sname [String] surname
252
249
  # @param inits [String] initials
253
250
  # @param lang [String] language
254
- # @return [RelatonBib::FullName]
251
+ # @return [Relaton::Bib::FullName]
255
252
  def full_name(fname, sname, inits, lang)
256
253
  initials = localized_string(inits, lang) if inits
257
- FullName.new(
254
+ Bib::FullName.new(
258
255
  completename: localized_string(fname, lang), initials: initials,
259
256
  forename: forename(inits, lang), surname: localized_string(sname, lang)
260
257
  )
@@ -266,43 +263,43 @@ module RelatonBib
266
263
  # @param [String] initials initials
267
264
  # @param [String] lang language
268
265
  #
269
- # @return [Array<RelatonBib::Forename>] forenames
266
+ # @return [Array<Relaton::Bib::Forename>] forenames
270
267
  #
271
268
  def forename(initials, lang = nil, script = nil)
272
269
  return [] unless initials
273
270
 
274
271
  initials.split(/\.-?\s?|\s/).map do |i|
275
- Forename.new(initial: i, language: lang, script: script)
272
+ Bib::Forename.new(initial: i, language: lang, script: script)
276
273
  end
277
274
  end
278
275
 
279
276
  # @param author [Nokogiri::XML::Element]
280
- # @return [Array<RelatonBib::Affiliation>]
277
+ # @return [Array<Relaton::Bib::Affiliation>]
281
278
  def affiliation(author)
282
279
  o = author.at("./organization")
283
280
  return [] if o.nil? || o.text.empty?
284
281
 
285
282
  org = new_org o.text, o[:abbrev]
286
- [Affiliation.new(organization: org)]
283
+ [Bib::Affiliation.new(organization: org)]
287
284
  end
288
285
 
289
286
  # @param name [String]
290
287
  # @param abbr [String, nil]
291
- # @return [RelatonBib::Organization]
288
+ # @return [Relaton::Bib::Organization]
292
289
  def new_org(name, abbr = nil)
293
- Organization.new name: name, abbreviation: abbr
290
+ Bib::Organization.new name: name, abbreviation: abbr
294
291
  end
295
292
 
296
293
  # @param content [String, nil]
297
294
  # @param lang [String, nil]
298
295
  # @param script [String, nil]
299
- # @return [RelatonBib::LocalizedString, nil]
296
+ # @return [Relaton::Bib::LocalizedString, nil]
300
297
  def localized_string(content, lang, script = nil)
301
- LocalizedString.new(content, lang, script) if content
298
+ Bib::LocalizedString.new(content: content, laguage: lang, script: script) if content
302
299
  end
303
300
 
304
301
  # @param postal [Nokogiri::XML::Element]
305
- # @return [Array<RelatonBib::Address, RelatonBib::Phone>]
302
+ # @return [Array<Relaton::Bib::Address, Relaton::Bib::Phone>]
306
303
  def contacts(addr)
307
304
  conts = []
308
305
  return conts unless addr
@@ -316,10 +313,10 @@ module RelatonBib
316
313
  end
317
314
 
318
315
  # @param postal [Nokogiri::XML::Element]
319
- # @rerurn [RelatonBib::Address]
316
+ # @return [Relaton::Bib::Address]
320
317
  def address(postal) # rubocop:disable Metrics/CyclomaticComplexity
321
318
  street = [postal.at("./postalLine | ./street")&.text].compact
322
- Address.new(
319
+ Bib::Address.new(
323
320
  street: street,
324
321
  city: postal.at("./city")&.text,
325
322
  postcode: postal.at("./code")&.text,
@@ -328,11 +325,11 @@ module RelatonBib
328
325
  )
329
326
  end
330
327
 
331
- # @param conts [Array<RelatonBib::Address, RelatonBib::Contact>]
328
+ # @param conts [Array<Relaton::Bib::Address, Relaton::Bib::Contact>]
332
329
  # @param type [String] allowed "phone", "email" or "uri"
333
330
  # @param value [String]
334
331
  def add_contact(conts, type, value)
335
- conts << Contact.new(type: type, value: value.text) if value
332
+ conts << Bib::Contact.new(type: type, value: value.text) if value
336
333
  end
337
334
 
338
335
  # @param author [Nokogiri::XML::Document]
@@ -353,7 +350,7 @@ module RelatonBib
353
350
  # Extract date from reference.
354
351
  #
355
352
  # @param reference [Nokogiri::XML::Element]
356
- # @return [Array<RelatonBib::BibliographicDate>] published data.
353
+ # @return [Array<Relaton::Bib::Bdate>] published data.
357
354
  #
358
355
  def dates(reference) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
359
356
  date = reference.at "./front/date"
@@ -363,23 +360,23 @@ module RelatonBib
363
360
  d += "-#{month(date[:month])}" if date[:month] && !date[:month].empty?
364
361
  d += "-#{date[:day]}" if date[:day]
365
362
  # date = Time.parse(d).strftime "%Y-%m-%d"
366
- [BibliographicDate.new(type: "published", on: d)]
363
+ [Bib::Date.new(type: "published", on: d)]
367
364
  end
368
365
 
369
366
  # @param reference [Nokogiri::XML::Element]
370
- # @return [RelatonBib::EditorialGroup, nil]
367
+ # @return [Relaton::Bib::EditorialGroup, nil]
371
368
  def editorialgroup(reference)
372
369
  tc = reference.xpath("./front/workgroup").map do |ed|
373
- wg = WorkGroup.new name: ed.text
370
+ wg = Bib::WorkGroup.new name: ed.text
374
371
  committee wg
375
372
  end
376
373
  EditorialGroup.new tc if tc.any?
377
374
  end
378
375
 
379
- # @param [RelatonBib::WorkGroup]
380
- # @return [RelatonBib::TechnicalCommittee]
376
+ # @param [Relaton::Bib::WorkGroup]
377
+ # @return [Relaton::Bib::TechnicalCommittee]
381
378
  def committee(wgr)
382
- TechnicalCommittee.new wgr
379
+ Bib::TechnicalCommittee.new wgr
383
380
  end
384
381
 
385
382
  def month(mon)
@@ -393,13 +390,13 @@ module RelatonBib
393
390
  # Extract series form reference
394
391
  # @param reference [Nokogiri::XML::Element]
395
392
  #
396
- # @return [Array<RelatonBib::Series>]
393
+ # @return [Array<Relaton::Bib::Series>]
397
394
  #
398
395
  def series(reference)
399
396
  reference.xpath("./seriesInfo", "./front/seriesInfo").map do |si|
400
397
  next if SERIESINFONAMES.include?(si[:name]) || si[:stream] || si[:status]
401
398
 
402
- t = TypedTitleString.new(
399
+ t = Title.new(
403
400
  content: si[:name], language: language(reference), script: "Latn",
404
401
  )
405
402
  Series.new(title: t, number: si[:value], type: "main")
@@ -1,15 +1,15 @@
1
1
  require "weakref"
2
2
 
3
- module RelatonBib
3
+ module Relaton
4
4
  class Hit
5
- # @return [RelatonBib::HitCollection]
5
+ # @return [Relaton::HitCollection]
6
6
  attr_accessor :hit_collection
7
7
 
8
8
  # @return [Array<Hash>]
9
9
  attr_reader :hit
10
10
 
11
11
  # @param hit [Hash]
12
- # @param hit_collection [RelatonBib::HitCollection]
12
+ # @param hit_collection [Relaton::HitCollection]
13
13
  def initialize(hit, hit_collection = nil)
14
14
  @hit = hit
15
15
  @hit_collection = WeakRef.new hit_collection if hit_collection
@@ -1,6 +1,6 @@
1
1
  require "forwardable"
2
2
 
3
- module RelatonBib
3
+ module Relaton
4
4
  class HitCollection
5
5
  extend Forwardable
6
6
 
@@ -68,7 +68,7 @@ module RelatonBib
68
68
  #
69
69
  # @param [Proc] &block proc to select hits
70
70
  #
71
- # @return [RelatonBib::HitCollection] new hit collection
71
+ # @return [Relaton::Bib::HitCollection] new hit collection
72
72
  #
73
73
  def select(&block)
74
74
  me = deep_dup
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RelatonBib
3
+ module Relaton
4
4
  # Workers poll.
5
5
  class WorkersPool
6
6
  attr_accessor :nb_hits