relaton 2.2.0.pre.alpha.1 → 3.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 (610) hide show
  1. checksums.yaml +4 -4
  2. data/{docs/README.adoc → README.adoc} +109 -38
  3. data/lib/relaton/3gpp/bibdata.rb +9 -0
  4. data/lib/relaton/3gpp/bibitem.rb +9 -0
  5. data/lib/relaton/3gpp/bibliography.rb +48 -0
  6. data/lib/relaton/3gpp/data_fetcher.rb +255 -0
  7. data/lib/relaton/3gpp/doctype.rb +9 -0
  8. data/lib/relaton/3gpp/ext.rb +31 -0
  9. data/lib/relaton/3gpp/item.rb +12 -0
  10. data/lib/relaton/3gpp/item_data.rb +15 -0
  11. data/lib/relaton/3gpp/parser.rb +400 -0
  12. data/lib/relaton/3gpp/processor.rb +68 -0
  13. data/lib/relaton/3gpp/release.rb +34 -0
  14. data/lib/relaton/3gpp/util.rb +8 -0
  15. data/lib/relaton/3gpp.rb +25 -0
  16. data/lib/relaton/bib/converter/asciibib/to_asciibib.rb +663 -0
  17. data/lib/relaton/bib/converter/asciibib.rb +13 -0
  18. data/lib/relaton/bib/converter/bibtex/from_bibtex.rb +245 -0
  19. data/lib/relaton/bib/converter/bibtex/to_bibtex.rb +341 -0
  20. data/lib/relaton/bib/converter/bibtex.rb +23 -0
  21. data/lib/relaton/bib/converter/bibxml/from_rfcxml.rb +386 -0
  22. data/lib/relaton/bib/converter/bibxml/from_rfcxml_referencegroup.rb +71 -0
  23. data/lib/relaton/bib/converter/bibxml/to_rfcxml.rb +308 -0
  24. data/lib/relaton/bib/converter/bibxml/to_rfcxml_referencegroup.rb +52 -0
  25. data/lib/relaton/bib/converter/bibxml.rb +51 -0
  26. data/lib/relaton/bib/hash_parser_v1.rb +767 -0
  27. data/lib/relaton/bib/item_data.rb +229 -0
  28. data/lib/relaton/bib/model/abstract.rb +16 -0
  29. data/lib/relaton/bib/model/address.rb +22 -0
  30. data/lib/relaton/bib/model/affiliation.rb +16 -0
  31. data/lib/relaton/bib/model/bibdata.rb +11 -0
  32. data/lib/relaton/bib/model/bibdata_shared.rb +12 -0
  33. data/lib/relaton/bib/model/bibitem.rb +11 -0
  34. data/lib/relaton/bib/model/bibitem_shared.rb +12 -0
  35. data/lib/relaton/bib/model/contact.rb +18 -0
  36. data/lib/relaton/bib/model/contribution_info.rb +15 -0
  37. data/lib/relaton/bib/model/contributor.rb +29 -0
  38. data/lib/relaton/bib/model/copyright.rb +27 -0
  39. data/lib/relaton/bib/model/date.rb +31 -0
  40. data/lib/relaton/bib/model/depiction.rb +16 -0
  41. data/lib/relaton/bib/model/docidentifier.rb +34 -0
  42. data/lib/relaton/bib/model/doctype.rb +14 -0
  43. data/lib/relaton/bib/model/edition.rb +14 -0
  44. data/lib/relaton/bib/model/ext.rb +39 -0
  45. data/lib/relaton/bib/model/extent.rb +16 -0
  46. data/lib/relaton/bib/model/formattedref.rb +43 -0
  47. data/lib/relaton/bib/model/full_name_type.rb +64 -0
  48. data/lib/relaton/bib/model/fullname.rb +11 -0
  49. data/lib/relaton/bib/model/ics.rb +49 -0
  50. data/lib/relaton/bib/model/image.rb +28 -0
  51. data/lib/relaton/bib/model/item.rb +96 -0
  52. data/lib/relaton/bib/model/item_base.rb +20 -0
  53. data/lib/relaton/bib/model/item_shared.rb +88 -0
  54. data/lib/relaton/bib/model/keyword.rb +30 -0
  55. data/lib/relaton/bib/model/locality.rb +18 -0
  56. data/lib/relaton/bib/model/locality_stack.rb +14 -0
  57. data/lib/relaton/bib/model/localized_string.rb +48 -0
  58. data/lib/relaton/bib/model/localized_string_attrs.rb +24 -0
  59. data/lib/relaton/bib/model/logo.rb +14 -0
  60. data/lib/relaton/bib/model/medium.rb +22 -0
  61. data/lib/relaton/bib/model/note.rb +16 -0
  62. data/lib/relaton/bib/model/organization.rb +13 -0
  63. data/lib/relaton/bib/model/organization_type.rb +42 -0
  64. data/lib/relaton/bib/model/person.rb +36 -0
  65. data/lib/relaton/bib/model/phone.rb +14 -0
  66. data/lib/relaton/bib/model/place.rb +33 -0
  67. data/lib/relaton/bib/model/price.rb +14 -0
  68. data/lib/relaton/bib/model/relation.rb +43 -0
  69. data/lib/relaton/bib/model/series.rb +34 -0
  70. data/lib/relaton/bib/model/size.rb +23 -0
  71. data/lib/relaton/bib/model/source_locality_stack.rb +14 -0
  72. data/lib/relaton/bib/model/status.rb +27 -0
  73. data/lib/relaton/bib/model/structured_identifier.rb +48 -0
  74. data/lib/relaton/bib/model/subdivision.rb +16 -0
  75. data/lib/relaton/bib/model/title.rb +56 -0
  76. data/lib/relaton/bib/model/type/plain_date.rb +16 -0
  77. data/lib/relaton/bib/model/type/string_date.rb +48 -0
  78. data/lib/relaton/bib/model/uri.rb +18 -0
  79. data/lib/relaton/bib/model/validity.rb +16 -0
  80. data/lib/relaton/bib/model/version.rb +43 -0
  81. data/lib/relaton/bib/namespace_helper.rb +21 -0
  82. data/lib/relaton/bib/sanitizer.rb +68 -0
  83. data/lib/relaton/bib/util.rb +18 -0
  84. data/lib/relaton/bib/versions.json +35 -0
  85. data/lib/relaton/bib.rb +48 -0
  86. data/lib/relaton/bipm/bibliography.rb +82 -0
  87. data/lib/relaton/bipm/converter/asciibib.rb +64 -0
  88. data/lib/relaton/bipm/data_fetcher.rb +57 -0
  89. data/lib/relaton/bipm/data_outcomes_parser.rb +657 -0
  90. data/lib/relaton/bipm/id_parser.rb +277 -0
  91. data/lib/relaton/bipm/item_data.rb +47 -0
  92. data/lib/relaton/bipm/model/bibdata.rb +9 -0
  93. data/lib/relaton/bipm/model/bibitem.rb +9 -0
  94. data/lib/relaton/bipm/model/comment_period.rb +13 -0
  95. data/lib/relaton/bipm/model/doctype.rb +12 -0
  96. data/lib/relaton/bipm/model/ext.rb +38 -0
  97. data/lib/relaton/bipm/model/item.rb +11 -0
  98. data/lib/relaton/bipm/model/structured_identifier.rb +15 -0
  99. data/lib/relaton/bipm/processor.rb +69 -0
  100. data/lib/relaton/bipm/rawdata_bipm_metrologia/affiliations.rb +111 -0
  101. data/lib/relaton/bipm/rawdata_bipm_metrologia/fetcher.rb +174 -0
  102. data/lib/relaton/bipm/rawdata_bipm_metrologia/niso_jats_parser.rb +353 -0
  103. data/lib/relaton/bipm/si_brochure_parser.rb +186 -0
  104. data/lib/relaton/bipm/util.rb +8 -0
  105. data/lib/relaton/bipm.rb +32 -0
  106. data/lib/relaton/bsi/bibliography.rb +124 -0
  107. data/lib/relaton/bsi/hit.rb +14 -0
  108. data/lib/relaton/bsi/hit_collection.rb +114 -0
  109. data/lib/relaton/bsi/item_data.rb +13 -0
  110. data/lib/relaton/bsi/model/bibdata.rb +8 -0
  111. data/lib/relaton/bsi/model/bibitem.rb +8 -0
  112. data/lib/relaton/bsi/model/docidentifier.rb +9 -0
  113. data/lib/relaton/bsi/model/doctype.rb +14 -0
  114. data/lib/relaton/bsi/model/ext.rb +17 -0
  115. data/lib/relaton/bsi/model/item.rb +17 -0
  116. data/lib/relaton/bsi/model/item_base.rb +22 -0
  117. data/lib/relaton/bsi/model/relation.rb +9 -0
  118. data/lib/relaton/bsi/processor.rb +42 -0
  119. data/lib/relaton/bsi/schema.json +24882 -0
  120. data/lib/relaton/bsi/scraper.rb +288 -0
  121. data/lib/relaton/bsi/util.rb +8 -0
  122. data/lib/relaton/bsi.rb +25 -0
  123. data/lib/relaton/calconnect/bibliography.rb +95 -0
  124. data/lib/relaton/calconnect/data_fetcher.rb +106 -0
  125. data/lib/relaton/calconnect/hit.rb +14 -0
  126. data/lib/relaton/calconnect/hit_collection.rb +84 -0
  127. data/lib/relaton/calconnect/item_data.rb +12 -0
  128. data/lib/relaton/calconnect/model/bibdata.rb +8 -0
  129. data/lib/relaton/calconnect/model/bibitem.rb +8 -0
  130. data/lib/relaton/calconnect/model/doctype.rb +11 -0
  131. data/lib/relaton/calconnect/model/ext.rb +11 -0
  132. data/lib/relaton/calconnect/model/item.rb +13 -0
  133. data/lib/relaton/calconnect/processor.rb +66 -0
  134. data/lib/relaton/calconnect/scraper.rb +87 -0
  135. data/lib/relaton/calconnect/util.rb +8 -0
  136. data/lib/relaton/calconnect.rb +26 -0
  137. data/lib/relaton/ccsds/bibliography.rb +63 -0
  138. data/lib/relaton/ccsds/data/fetcher.rb +247 -0
  139. data/lib/relaton/ccsds/data/iso_references.rb +30 -0
  140. data/lib/relaton/ccsds/data/parser.rb +194 -0
  141. data/lib/relaton/ccsds/hit.rb +24 -0
  142. data/lib/relaton/ccsds/hit_collection.rb +42 -0
  143. data/lib/relaton/ccsds/item_data.rb +9 -0
  144. data/lib/relaton/ccsds/model/bibdata.rb +8 -0
  145. data/lib/relaton/ccsds/model/bibitem.rb +8 -0
  146. data/lib/relaton/ccsds/model/doctype.rb +9 -0
  147. data/lib/relaton/ccsds/model/ext.rb +19 -0
  148. data/lib/relaton/ccsds/model/item.rb +13 -0
  149. data/lib/relaton/ccsds/processor.rb +68 -0
  150. data/lib/relaton/ccsds/util.rb +10 -0
  151. data/lib/relaton/ccsds.rb +33 -0
  152. data/lib/relaton/cen/bibliography.rb +121 -0
  153. data/lib/relaton/cen/committees.yaml +66 -0
  154. data/lib/relaton/cen/hit.rb +16 -0
  155. data/lib/relaton/cen/hit_collection.rb +68 -0
  156. data/lib/relaton/cen/item_data.rb +7 -0
  157. data/lib/relaton/cen/model/bibdata.rb +8 -0
  158. data/lib/relaton/cen/model/bibitem.rb +8 -0
  159. data/lib/relaton/cen/model/docidentifier.rb +9 -0
  160. data/lib/relaton/cen/model/ext.rb +11 -0
  161. data/lib/relaton/cen/model/item.rb +14 -0
  162. data/lib/relaton/cen/model/structured_identifier.rb +9 -0
  163. data/lib/relaton/cen/processor.rb +40 -0
  164. data/lib/relaton/cen/scraper.rb +210 -0
  165. data/lib/relaton/cen/util.rb +8 -0
  166. data/lib/relaton/cen.rb +29 -0
  167. data/lib/relaton/cie/bibdata.rb +8 -0
  168. data/lib/relaton/cie/bibitem.rb +8 -0
  169. data/lib/relaton/cie/bibliography.rb +31 -0
  170. data/lib/relaton/cie/data_fetcher.rb +355 -0
  171. data/lib/relaton/cie/ext.rb +7 -0
  172. data/lib/relaton/cie/item.rb +11 -0
  173. data/lib/relaton/cie/item_data.rb +6 -0
  174. data/lib/relaton/cie/processor.rb +66 -0
  175. data/lib/relaton/cie/scrapper.rb +39 -0
  176. data/lib/relaton/cie/util.rb +8 -0
  177. data/lib/relaton/cie.rb +28 -0
  178. data/lib/relaton/core/array_wrapper.rb +20 -0
  179. data/lib/relaton/core/data_fetcher.rb +97 -0
  180. data/lib/relaton/core/date_parser.rb +42 -0
  181. data/lib/relaton/core/hash_keys_sybolizer.rb +19 -0
  182. data/lib/relaton/core/hit.rb +49 -0
  183. data/lib/relaton/core/hit_collection.rb +118 -0
  184. data/lib/relaton/core/processor.rb +48 -0
  185. data/lib/relaton/core/workers_pool.rb +45 -0
  186. data/lib/relaton/core.rb +9 -0
  187. data/lib/relaton/db/registry.rb +4 -4
  188. data/lib/relaton/db.rb +0 -1
  189. data/lib/relaton/doi/crossref.rb +72 -0
  190. data/lib/relaton/doi/parser.rb +827 -0
  191. data/lib/relaton/doi/processor.rb +65 -0
  192. data/lib/relaton/doi/util.rb +8 -0
  193. data/lib/relaton/doi.rb +20 -0
  194. data/lib/relaton/ecma/bibdata.rb +8 -0
  195. data/lib/relaton/ecma/bibitem.rb +8 -0
  196. data/lib/relaton/ecma/bibliography.rb +81 -0
  197. data/lib/relaton/ecma/data_fetcher.rb +103 -0
  198. data/lib/relaton/ecma/data_parser.rb +49 -0
  199. data/lib/relaton/ecma/edition_parser.rb +80 -0
  200. data/lib/relaton/ecma/ext.rb +7 -0
  201. data/lib/relaton/ecma/item.rb +11 -0
  202. data/lib/relaton/ecma/item_data.rb +6 -0
  203. data/lib/relaton/ecma/memento_parser.rb +60 -0
  204. data/lib/relaton/ecma/page_fetcher.rb +27 -0
  205. data/lib/relaton/ecma/parser_common.rb +33 -0
  206. data/lib/relaton/ecma/processor.rb +66 -0
  207. data/lib/relaton/ecma/standard_parser.rb +134 -0
  208. data/lib/relaton/ecma/util.rb +8 -0
  209. data/lib/relaton/ecma.rb +24 -0
  210. data/lib/relaton/etsi/bibdata.rb +10 -0
  211. data/lib/relaton/etsi/bibitem.rb +10 -0
  212. data/lib/relaton/etsi/bibliography.rb +46 -0
  213. data/lib/relaton/etsi/data_fetcher.rb +128 -0
  214. data/lib/relaton/etsi/data_parser.rb +208 -0
  215. data/lib/relaton/etsi/doctype.rb +30 -0
  216. data/lib/relaton/etsi/ext.rb +31 -0
  217. data/lib/relaton/etsi/item.rb +15 -0
  218. data/lib/relaton/etsi/item_data.rb +6 -0
  219. data/lib/relaton/etsi/processor.rb +69 -0
  220. data/lib/relaton/etsi/pubid.rb +37 -0
  221. data/lib/relaton/etsi/status.rb +13 -0
  222. data/lib/relaton/etsi/util.rb +8 -0
  223. data/lib/relaton/etsi.rb +25 -0
  224. data/lib/relaton/gb/bibdata.rb +8 -0
  225. data/lib/relaton/gb/bibitem.rb +8 -0
  226. data/lib/relaton/gb/bibliography.rb +145 -0
  227. data/lib/relaton/gb/ccs.rb +14 -0
  228. data/lib/relaton/gb/committee.rb +13 -0
  229. data/lib/relaton/gb/docidentifier.rb +23 -0
  230. data/lib/relaton/gb/doctype.rb +9 -0
  231. data/lib/relaton/gb/ext.rb +36 -0
  232. data/lib/relaton/gb/gb_scraper.rb +61 -0
  233. data/lib/relaton/gb/gb_type.rb +20 -0
  234. data/lib/relaton/gb/hit.rb +48 -0
  235. data/lib/relaton/gb/hit_collection.rb +19 -0
  236. data/lib/relaton/gb/item.rb +13 -0
  237. data/lib/relaton/gb/item_data.rb +6 -0
  238. data/lib/relaton/gb/processor.rb +46 -0
  239. data/lib/relaton/gb/project_number.rb +38 -0
  240. data/lib/relaton/gb/scraper.rb +204 -0
  241. data/lib/relaton/gb/sec_scraper.rb +92 -0
  242. data/lib/relaton/gb/stage_name.rb +13 -0
  243. data/lib/relaton/gb/structured_identifier.rb +26 -0
  244. data/lib/relaton/gb/t_scraper.rb +126 -0
  245. data/lib/relaton/gb/util.rb +8 -0
  246. data/lib/relaton/gb/yaml/prefixes.yaml +200 -0
  247. data/lib/relaton/gb.rb +33 -0
  248. data/lib/relaton/iana/bibdata.rb +8 -0
  249. data/lib/relaton/iana/bibitem.rb +8 -0
  250. data/lib/relaton/iana/bibliography.rb +47 -0
  251. data/lib/relaton/iana/data_fetcher.rb +71 -0
  252. data/lib/relaton/iana/item.rb +7 -0
  253. data/lib/relaton/iana/item_data.rb +6 -0
  254. data/lib/relaton/iana/parser.rb +146 -0
  255. data/lib/relaton/iana/processor.rb +68 -0
  256. data/lib/relaton/iana/util.rb +8 -0
  257. data/lib/relaton/iana.rb +29 -0
  258. data/lib/relaton/iec/bibliography.rb +283 -0
  259. data/lib/relaton/iec/data_fetcher.rb +216 -0
  260. data/lib/relaton/iec/data_parser.rb +391 -0
  261. data/lib/relaton/iec/hit.rb +26 -0
  262. data/lib/relaton/iec/hit_collection.rb +138 -0
  263. data/lib/relaton/iec/item_data.rb +7 -0
  264. data/lib/relaton/iec/model/bibdata.rb +8 -0
  265. data/lib/relaton/iec/model/bibitem.rb +8 -0
  266. data/lib/relaton/iec/model/docidentifier.rb +131 -0
  267. data/lib/relaton/iec/model/doctype.rb +12 -0
  268. data/lib/relaton/iec/model/ext.rb +53 -0
  269. data/lib/relaton/iec/model/item.rb +20 -0
  270. data/lib/relaton/iec/model/item_base.rb +12 -0
  271. data/lib/relaton/iec/model/relation.rb +7 -0
  272. data/lib/relaton/iec/model/stage_name.rb +13 -0
  273. data/lib/relaton/iec/processor.rb +73 -0
  274. data/lib/relaton/iec/statuses.yml +199 -0
  275. data/lib/relaton/iec/util.rb +8 -0
  276. data/lib/relaton/iec.rb +98 -0
  277. data/lib/relaton/ieee/balloting_group.rb +13 -0
  278. data/lib/relaton/ieee/bibdata.rb +8 -0
  279. data/lib/relaton/ieee/bibitem.rb +8 -0
  280. data/lib/relaton/ieee/bibliography.rb +51 -0
  281. data/lib/relaton/ieee/converter/bibxml/from_rfcxml.rb +10 -0
  282. data/lib/relaton/ieee/converter/bibxml/from_rfcxml_referencegroup.rb +10 -0
  283. data/lib/relaton/ieee/converter/bibxml.rb +20 -0
  284. data/lib/relaton/ieee/data_fetcher.rb +630 -0
  285. data/lib/relaton/ieee/doctype.rb +9 -0
  286. data/lib/relaton/ieee/editorial_group.rb +19 -0
  287. data/lib/relaton/ieee/ext.rb +36 -0
  288. data/lib/relaton/ieee/idams_parser.rb +323 -0
  289. data/lib/relaton/ieee/item.rb +11 -0
  290. data/lib/relaton/ieee/item_data.rb +7 -0
  291. data/lib/relaton/ieee/processor.rb +68 -0
  292. data/lib/relaton/ieee/pub_id.rb +161 -0
  293. data/lib/relaton/ieee/rawbib_id_parser.rb +548 -0
  294. data/lib/relaton/ieee/util.rb +8 -0
  295. data/lib/relaton/ieee.rb +29 -0
  296. data/lib/relaton/ietf/bibdata.rb +8 -0
  297. data/lib/relaton/ietf/bibitem.rb +8 -0
  298. data/lib/relaton/ietf/bibliography.rb +35 -0
  299. data/lib/relaton/ietf/bibxml_parser.rb +232 -0
  300. data/lib/relaton/ietf/data_fetcher.rb +278 -0
  301. data/lib/relaton/ietf/doctype.rb +9 -0
  302. data/lib/relaton/ietf/ext.rb +63 -0
  303. data/lib/relaton/ietf/item.rb +16 -0
  304. data/lib/relaton/ietf/item_base.rb +18 -0
  305. data/lib/relaton/ietf/item_data.rb +6 -0
  306. data/lib/relaton/ietf/processing_instructions.rb +79 -0
  307. data/lib/relaton/ietf/processor.rb +68 -0
  308. data/lib/relaton/ietf/relation.rb +9 -0
  309. data/lib/relaton/ietf/rfc/abstract.rb +19 -0
  310. data/lib/relaton/ietf/rfc/author.rb +21 -0
  311. data/lib/relaton/ietf/rfc/entry.rb +410 -0
  312. data/lib/relaton/ietf/rfc/entry_date.rb +21 -0
  313. data/lib/relaton/ietf/rfc/format.rb +19 -0
  314. data/lib/relaton/ietf/rfc/index.rb +46 -0
  315. data/lib/relaton/ietf/rfc/is_also.rb +21 -0
  316. data/lib/relaton/ietf/rfc/keywords.rb +19 -0
  317. data/lib/relaton/ietf/rfc/rfc_index_namespace.rb +11 -0
  318. data/lib/relaton/ietf/scraper.rb +68 -0
  319. data/lib/relaton/ietf/util.rb +8 -0
  320. data/lib/relaton/ietf/wg_name_resolver.rb +42 -0
  321. data/lib/relaton/ietf.rb +27 -0
  322. data/lib/relaton/iho/bibdata.rb +8 -0
  323. data/lib/relaton/iho/bibitem.rb +8 -0
  324. data/lib/relaton/iho/bibliography.rb +114 -0
  325. data/lib/relaton/iho/comment_period.rb +13 -0
  326. data/lib/relaton/iho/docidentifier.rb +31 -0
  327. data/lib/relaton/iho/doctype.rb +10 -0
  328. data/lib/relaton/iho/ext.rb +20 -0
  329. data/lib/relaton/iho/hash_parser_v1.rb +144 -0
  330. data/lib/relaton/iho/item.rb +20 -0
  331. data/lib/relaton/iho/item_base.rb +18 -0
  332. data/lib/relaton/iho/item_data.rb +6 -0
  333. data/lib/relaton/iho/processor.rb +54 -0
  334. data/lib/relaton/iho/relation.rb +9 -0
  335. data/lib/relaton/iho/structured_identifier.rb +20 -0
  336. data/lib/relaton/iho/util.rb +8 -0
  337. data/lib/relaton/iho.rb +27 -0
  338. data/lib/relaton/index/config.rb +52 -0
  339. data/lib/relaton/index/file_io.rb +305 -0
  340. data/lib/relaton/index/file_storage.rb +61 -0
  341. data/lib/relaton/index/id_number.rb +30 -0
  342. data/lib/relaton/index/pool.rb +41 -0
  343. data/lib/relaton/index/type.rb +159 -0
  344. data/lib/relaton/index/util.rb +18 -0
  345. data/lib/relaton/index.rb +60 -0
  346. data/lib/relaton/isbn/isbn.rb +61 -0
  347. data/lib/relaton/isbn/open_library.rb +43 -0
  348. data/lib/relaton/isbn/parser.rb +88 -0
  349. data/lib/relaton/isbn/processor.rb +48 -0
  350. data/lib/relaton/isbn/util.rb +8 -0
  351. data/lib/relaton/isbn.rb +19 -0
  352. data/lib/relaton/iso/bibliography.rb +407 -0
  353. data/lib/relaton/iso/data_fetcher.rb +338 -0
  354. data/lib/relaton/iso/data_parser.rb +444 -0
  355. data/lib/relaton/iso/hash_parser_v1.rb +177 -0
  356. data/lib/relaton/iso/hit.rb +57 -0
  357. data/lib/relaton/iso/hit_collection.rb +184 -0
  358. data/lib/relaton/iso/item_data.rb +28 -0
  359. data/lib/relaton/iso/model/bibdata.rb +10 -0
  360. data/lib/relaton/iso/model/bibitem.rb +8 -0
  361. data/lib/relaton/iso/model/contributor.rb +6 -0
  362. data/lib/relaton/iso/model/contributor_info.rb +9 -0
  363. data/lib/relaton/iso/model/docidentifier.rb +134 -0
  364. data/lib/relaton/iso/model/doctype.rb +13 -0
  365. data/lib/relaton/iso/model/ext.rb +35 -0
  366. data/lib/relaton/iso/model/item.rb +17 -0
  367. data/lib/relaton/iso/model/item_base.rb +22 -0
  368. data/lib/relaton/iso/model/organization.rb +9 -0
  369. data/lib/relaton/iso/model/project_number.rb +22 -0
  370. data/lib/relaton/iso/model/relation.rb +9 -0
  371. data/lib/relaton/iso/model/stagename.rb +14 -0
  372. data/lib/relaton/iso/model/structured_identifier.rb +31 -0
  373. data/lib/relaton/iso/processor.rb +84 -0
  374. data/lib/relaton/iso/scraper.rb +619 -0
  375. data/lib/relaton/iso/type/pubid.rb +50 -0
  376. data/lib/relaton/iso/util.rb +8 -0
  377. data/lib/relaton/iso.rb +30 -0
  378. data/lib/relaton/itu/bibliography.rb +90 -0
  379. data/lib/relaton/itu/data_fetcher.rb +104 -0
  380. data/lib/relaton/itu/data_parser_r.rb +140 -0
  381. data/lib/relaton/itu/hit.rb +22 -0
  382. data/lib/relaton/itu/hit_collection.rb +127 -0
  383. data/lib/relaton/itu/item_data.rb +6 -0
  384. data/lib/relaton/itu/model/approval_stage.rb +13 -0
  385. data/lib/relaton/itu/model/bibdata.rb +8 -0
  386. data/lib/relaton/itu/model/bibitem.rb +8 -0
  387. data/lib/relaton/itu/model/docidentifier.rb +9 -0
  388. data/lib/relaton/itu/model/doctype.rb +13 -0
  389. data/lib/relaton/itu/model/ext.rb +47 -0
  390. data/lib/relaton/itu/model/item.rb +13 -0
  391. data/lib/relaton/itu/model/meeting.rb +13 -0
  392. data/lib/relaton/itu/model/meeting_date.rb +15 -0
  393. data/lib/relaton/itu/model/question.rb +13 -0
  394. data/lib/relaton/itu/model/recommendation_status.rb +11 -0
  395. data/lib/relaton/itu/model/structured_identifier.rb +19 -0
  396. data/lib/relaton/itu/processor.rb +66 -0
  397. data/lib/relaton/itu/pubid.rb +177 -0
  398. data/lib/relaton/itu/radio_regulations_parser.rb +70 -0
  399. data/lib/relaton/itu/recommendation_parser.rb +161 -0
  400. data/lib/relaton/itu/scraper.rb +193 -0
  401. data/lib/relaton/itu/util.rb +8 -0
  402. data/lib/relaton/itu.rb +33 -0
  403. data/lib/relaton/jis/bibdata.rb +8 -0
  404. data/lib/relaton/jis/bibitem.rb +8 -0
  405. data/lib/relaton/jis/bibliography.rb +75 -0
  406. data/lib/relaton/jis/data_fetcher.rb +181 -0
  407. data/lib/relaton/jis/docidentifier.rb +21 -0
  408. data/lib/relaton/jis/doctype.rb +9 -0
  409. data/lib/relaton/jis/ext.rb +13 -0
  410. data/lib/relaton/jis/hit.rb +93 -0
  411. data/lib/relaton/jis/hit_collection.rb +127 -0
  412. data/lib/relaton/jis/item.rb +22 -0
  413. data/lib/relaton/jis/item_base.rb +26 -0
  414. data/lib/relaton/jis/item_data.rb +8 -0
  415. data/lib/relaton/jis/processor.rb +55 -0
  416. data/lib/relaton/jis/relation.rb +11 -0
  417. data/lib/relaton/jis/scraper.rb +232 -0
  418. data/lib/relaton/jis/structured_identifier.rb +13 -0
  419. data/lib/relaton/jis/util.rb +8 -0
  420. data/lib/relaton/jis.rb +33 -0
  421. data/lib/relaton/logger/channels/gh_issue.rb +78 -0
  422. data/lib/relaton/logger/config.rb +34 -0
  423. data/lib/relaton/logger/formatter_json.rb +8 -0
  424. data/lib/relaton/logger/formatter_string.rb +12 -0
  425. data/lib/relaton/logger/log.rb +64 -0
  426. data/lib/relaton/logger/log_device.rb +27 -0
  427. data/lib/relaton/logger/pool.rb +24 -0
  428. data/lib/relaton/logger.rb +18 -0
  429. data/lib/relaton/nist/bibdata.rb +8 -0
  430. data/lib/relaton/nist/bibitem.rb +8 -0
  431. data/lib/relaton/nist/bibliography.rb +191 -0
  432. data/lib/relaton/nist/comment_period.rb +15 -0
  433. data/lib/relaton/nist/data_fetcher.rb +84 -0
  434. data/lib/relaton/nist/date.rb +7 -0
  435. data/lib/relaton/nist/doctype.rb +7 -0
  436. data/lib/relaton/nist/ext.rb +16 -0
  437. data/lib/relaton/nist/hit.rb +18 -0
  438. data/lib/relaton/nist/hit_collection.rb +362 -0
  439. data/lib/relaton/nist/item.rb +17 -0
  440. data/lib/relaton/nist/item_data.rb +6 -0
  441. data/lib/relaton/nist/mods_parser.rb +276 -0
  442. data/lib/relaton/nist/processor.rb +68 -0
  443. data/lib/relaton/nist/pubs_export.rb +69 -0
  444. data/lib/relaton/nist/relation.rb +7 -0
  445. data/lib/relaton/nist/scraper.rb +290 -0
  446. data/lib/relaton/nist/series.yaml +49 -0
  447. data/lib/relaton/nist/util.rb +8 -0
  448. data/lib/relaton/nist.rb +34 -0
  449. data/lib/relaton/oasis/bibdata.rb +8 -0
  450. data/lib/relaton/oasis/bibitem.rb +8 -0
  451. data/lib/relaton/oasis/bibliography.rb +60 -0
  452. data/lib/relaton/oasis/browser_agent.rb +71 -0
  453. data/lib/relaton/oasis/data_fetcher.rb +94 -0
  454. data/lib/relaton/oasis/data_parser.rb +305 -0
  455. data/lib/relaton/oasis/data_parser_utils.rb +296 -0
  456. data/lib/relaton/oasis/data_part_parser.rb +239 -0
  457. data/lib/relaton/oasis/doctype.rb +7 -0
  458. data/lib/relaton/oasis/ext.rb +19 -0
  459. data/lib/relaton/oasis/item.rb +11 -0
  460. data/lib/relaton/oasis/item_data.rb +6 -0
  461. data/lib/relaton/oasis/processor.rb +68 -0
  462. data/lib/relaton/oasis/util.rb +8 -0
  463. data/lib/relaton/oasis.rb +28 -0
  464. data/lib/relaton/ogc/bibdata.rb +8 -0
  465. data/lib/relaton/ogc/bibitem.rb +8 -0
  466. data/lib/relaton/ogc/bibliography.rb +64 -0
  467. data/lib/relaton/ogc/data_fetcher.rb +110 -0
  468. data/lib/relaton/ogc/docidentifier.rb +6 -0
  469. data/lib/relaton/ogc/doctype.rb +12 -0
  470. data/lib/relaton/ogc/ext.rb +15 -0
  471. data/lib/relaton/ogc/hit.rb +18 -0
  472. data/lib/relaton/ogc/hit_collection.rb +36 -0
  473. data/lib/relaton/ogc/item.rb +13 -0
  474. data/lib/relaton/ogc/item_data.rb +6 -0
  475. data/lib/relaton/ogc/processor.rb +58 -0
  476. data/lib/relaton/ogc/scraper.rb +225 -0
  477. data/lib/relaton/ogc/util.rb +8 -0
  478. data/lib/relaton/ogc.rb +26 -0
  479. data/lib/relaton/oiml/bibdata.rb +8 -0
  480. data/lib/relaton/oiml/bibitem.rb +8 -0
  481. data/lib/relaton/oiml/bibliography.rb +94 -0
  482. data/lib/relaton/oiml/docidentifier.rb +33 -0
  483. data/lib/relaton/oiml/doctype.rb +13 -0
  484. data/lib/relaton/oiml/ext.rb +42 -0
  485. data/lib/relaton/oiml/item.rb +20 -0
  486. data/lib/relaton/oiml/item_base.rb +18 -0
  487. data/lib/relaton/oiml/item_data.rb +6 -0
  488. data/lib/relaton/oiml/processor.rb +54 -0
  489. data/lib/relaton/oiml/relation.rb +9 -0
  490. data/lib/relaton/oiml/util.rb +8 -0
  491. data/lib/relaton/oiml.rb +24 -0
  492. data/lib/relaton/omg/bibdata.rb +8 -0
  493. data/lib/relaton/omg/bibitem.rb +8 -0
  494. data/lib/relaton/omg/bibliography.rb +31 -0
  495. data/lib/relaton/omg/ext.rb +7 -0
  496. data/lib/relaton/omg/item.rb +8 -0
  497. data/lib/relaton/omg/item_data.rb +6 -0
  498. data/lib/relaton/omg/processor.rb +34 -0
  499. data/lib/relaton/omg/scraper.rb +141 -0
  500. data/lib/relaton/omg/util.rb +8 -0
  501. data/lib/relaton/omg.rb +24 -0
  502. data/lib/relaton/plateau/bibdata.rb +8 -0
  503. data/lib/relaton/plateau/bibitem.rb +8 -0
  504. data/lib/relaton/plateau/bibliography.rb +24 -0
  505. data/lib/relaton/plateau/data_fetcher.rb +153 -0
  506. data/lib/relaton/plateau/doctype.rb +7 -0
  507. data/lib/relaton/plateau/ext.rb +23 -0
  508. data/lib/relaton/plateau/handbook_parser.rb +95 -0
  509. data/lib/relaton/plateau/hit.rb +13 -0
  510. data/lib/relaton/plateau/hit_collection.rb +59 -0
  511. data/lib/relaton/plateau/item.rb +12 -0
  512. data/lib/relaton/plateau/item_data.rb +6 -0
  513. data/lib/relaton/plateau/parser.rb +101 -0
  514. data/lib/relaton/plateau/processor.rb +49 -0
  515. data/lib/relaton/plateau/technical_report_parser.rb +91 -0
  516. data/lib/relaton/plateau/util.rb +8 -0
  517. data/lib/relaton/plateau.rb +28 -0
  518. data/lib/relaton/un/bibdata.rb +8 -0
  519. data/lib/relaton/un/bibitem.rb +8 -0
  520. data/lib/relaton/un/bibliography.rb +48 -0
  521. data/lib/relaton/un/doctype.rb +10 -0
  522. data/lib/relaton/un/ext.rb +30 -0
  523. data/lib/relaton/un/hit.rb +56 -0
  524. data/lib/relaton/un/hit_collection.rb +61 -0
  525. data/lib/relaton/un/item.rb +11 -0
  526. data/lib/relaton/un/item_data.rb +6 -0
  527. data/lib/relaton/un/parser.rb +108 -0
  528. data/lib/relaton/un/processor.rb +38 -0
  529. data/lib/relaton/un/session.rb +25 -0
  530. data/lib/relaton/un/token_generator.rb +105 -0
  531. data/lib/relaton/un/util.rb +8 -0
  532. data/lib/relaton/un/wasm/decoder.rb +434 -0
  533. data/lib/relaton/un/wasm/instance.rb +101 -0
  534. data/lib/relaton/un/wasm/interpreter.rb +613 -0
  535. data/lib/relaton/un/wasm/memory.rb +112 -0
  536. data/lib/relaton/un/wasm/module.rb +47 -0
  537. data/lib/relaton/un/wasm.rb +17 -0
  538. data/lib/relaton/un/wasm_v_bg.wasm +0 -0
  539. data/lib/relaton/un.rb +28 -0
  540. data/lib/relaton/version.rb +1 -1
  541. data/lib/relaton/w3c/bibdata.rb +8 -0
  542. data/lib/relaton/w3c/bibitem.rb +8 -0
  543. data/lib/relaton/w3c/bibliography.rb +54 -0
  544. data/lib/relaton/w3c/data_fetcher.rb +309 -0
  545. data/lib/relaton/w3c/data_parser.rb +379 -0
  546. data/lib/relaton/w3c/doctype.rb +7 -0
  547. data/lib/relaton/w3c/ext.rb +11 -0
  548. data/lib/relaton/w3c/item.rb +12 -0
  549. data/lib/relaton/w3c/item_data.rb +6 -0
  550. data/lib/relaton/w3c/processor.rb +49 -0
  551. data/lib/relaton/w3c/pubid.rb +73 -0
  552. data/lib/relaton/w3c/safe_realize.rb +59 -0
  553. data/lib/relaton/w3c/util.rb +8 -0
  554. data/lib/relaton/w3c.rb +25 -0
  555. data/lib/relaton/xsf/bibdata.rb +8 -0
  556. data/lib/relaton/xsf/bibitem.rb +8 -0
  557. data/lib/relaton/xsf/bibliography.rb +24 -0
  558. data/lib/relaton/xsf/data_fetcher.rb +56 -0
  559. data/lib/relaton/xsf/hit.rb +17 -0
  560. data/lib/relaton/xsf/hit_collection.rb +24 -0
  561. data/lib/relaton/xsf/item.rb +7 -0
  562. data/lib/relaton/xsf/item_data.rb +6 -0
  563. data/lib/relaton/xsf/processor.rb +50 -0
  564. data/lib/relaton/xsf/util.rb +9 -0
  565. data/lib/relaton/xsf.rb +30 -0
  566. data/lib/relaton-core.rb +1 -0
  567. data/lib/relaton.rb +43 -0
  568. metadata +673 -170
  569. data/.github/workflows/rake.yml +0 -14
  570. data/.github/workflows/release.yml +0 -24
  571. data/.github/workflows/rubocop.yml +0 -48
  572. data/.gitignore +0 -12
  573. data/.rspec +0 -3
  574. data/CLAUDE.md +0 -78
  575. data/Gemfile +0 -29
  576. data/Rakefile +0 -6
  577. data/docs/CHANGELOG.adoc +0 -16
  578. data/docs/VERSIONING_POLICY.adoc +0 -38
  579. data/docs/navigation.adoc +0 -6
  580. data/lib/relaton/db/version.rb +0 -5
  581. data/relaton.gemspec +0 -72
  582. data/spec/relaton/config_spec.rb +0 -10
  583. data/spec/relaton/db_cache_spec.rb +0 -51
  584. data/spec/relaton/db_spec.rb +0 -567
  585. data/spec/relaton/registry_spec.rb +0 -178
  586. data/spec/relaton/util_spec.rb +0 -3
  587. data/spec/relaton_meta_spec.rb +0 -25
  588. data/spec/relaton_spec.rb +0 -800
  589. data/spec/spec_helper.rb +0 -45
  590. data/spec/support/gb_t_20223_2006.xml +0 -33
  591. data/spec/support/iso_111111119115_1.xml +0 -0
  592. data/spec/support/iso_19115_1.xml +0 -115
  593. data/spec/support/iso_19115_2.xml +0 -95
  594. data/spec/support/rfc_8341.xml +0 -46
  595. data/spec/vcr_cassetes/api_relaton_org.yml +0 -121
  596. data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +0 -140
  597. data/spec/vcr_cassetes/cc_dir_10005_2019.yml +0 -202
  598. data/spec/vcr_cassetes/cipm_meeting_43.yml +0 -1505
  599. data/spec/vcr_cassetes/gb_t_20223_2006.yml +0 -729
  600. data/spec/vcr_cassetes/iso_111111119115_1.yml +0 -12951
  601. data/spec/vcr_cassetes/iso_19115_1.yml +0 -17334
  602. data/spec/vcr_cassetes/iso_19115_1_2.yml +0 -322
  603. data/spec/vcr_cassetes/iso_19115_1_std.yml +0 -17334
  604. data/spec/vcr_cassetes/iso_19115_all_parts.yml +0 -185
  605. data/spec/vcr_cassetes/iso_19133_2005.yml +0 -144
  606. data/spec/vcr_cassetes/iso_combined_applied.yml +0 -318
  607. data/spec/vcr_cassetes/iso_combined_included.yml +0 -318
  608. data/spec/vcr_cassetes/ogc_19_025r1.yml +0 -374
  609. data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +0 -317
  610. data/spec/vcr_cassetes/rfc_8341.yml +0 -1278
@@ -0,0 +1,767 @@
1
+ require_relative "../bib"
2
+
3
+ module Relaton
4
+ module Bib
5
+ module HashParserV1
6
+ include Core::ArrayWrapper
7
+ include Core::DateParser
8
+ extend self
9
+
10
+ # @param args [Hash]
11
+ # @return [Hash]
12
+ def hash_to_bib(args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
13
+ return nil unless args.is_a?(Hash)
14
+
15
+ ret = Marshal.load(Marshal.dump(symbolize(args))) # deep copy
16
+ ret[:fetched] &&= ::Date.parse(ret[:fetched])
17
+ ret.delete(:"schema-version")
18
+ ret.delete(:schema_version)
19
+ id_hash_to_bib ret
20
+ title_hash_to_bib(ret)
21
+ link_hash_to_bib(ret)
22
+ language_hash_to_bib(ret)
23
+ script_hash_to_bib(ret)
24
+ dates_hash_to_bib(ret)
25
+ docid_hash_to_bib(ret)
26
+ version_hash_to_bib(ret)
27
+ biblionote_hash_to_bib(ret)
28
+ abstract_hash_to_bib(ret)
29
+ formattedref_hash_to_bib(ret)
30
+ docstatus_hash_to_bib(ret)
31
+ contributors_hash_to_bib(ret)
32
+ editorialgroup_hash_to_bib(ret)
33
+ edition_hash_to_bib(ret)
34
+ copyright_hash_to_bib(ret)
35
+ relations_hash_to_bib(ret)
36
+ series_hash_to_bib(ret)
37
+ medium_hash_to_bib(ret)
38
+ place_hash_to_bib(ret)
39
+ extent_hash_to_bib(ret)
40
+ size_hash_to_bib(ret)
41
+ accesslocation_hash_to_bib(ret)
42
+ classification_hash_to_bib(ret)
43
+ validity_hash_to_bib(ret)
44
+ keyword_hash_to_bib(ret)
45
+ ret[:license] = array(ret[:license])
46
+ ext_hash_to_bib ret
47
+ ret
48
+ end
49
+
50
+ def id_hash_to_bib(ret)
51
+ return unless ret[:id]
52
+
53
+ ret[:id] = ret[:id].gsub(/\W+/, "")
54
+ end
55
+
56
+ def ext_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize
57
+ ret[:ext] ||= {}
58
+ doctype_hash_to_bib ret
59
+ ret[:ext][:subdoctype] = ret.delete(:subdoctype) if ret[:subdoctype]
60
+ ret[:ext][:flavor] ||= flavor(ret)
61
+ ics_hash_to_bib ret
62
+ structuredidentifier_hash_to_bib ret
63
+ ret[:ext] = Bib::Ext.new(**ret[:ext])
64
+ end
65
+
66
+ def flavor(ret)
67
+ return unless ret[:docid]
68
+
69
+ docid = ret[:docidentifier].find(&:primary)
70
+ return unless docid
71
+
72
+ docid.type.downcase
73
+ end
74
+
75
+ def keyword_hash_to_bib(ret)
76
+ ret[:keyword] = array(ret[:keyword]).map do |keyword|
77
+ Bib::Keyword.new vocab: localizedstring(keyword)
78
+ end
79
+ end
80
+
81
+ def extent_hash_to_bib(ret)
82
+ return unless ret[:extent]
83
+
84
+ ret[:extent] = array(ret[:extent]).map do |e|
85
+ Relaton::Bib::Extent.new locality: locality(e[:locality]),
86
+ locality_stack: locality_stack(e[:locality_stack])
87
+ end
88
+ end
89
+
90
+ def locality(locality)
91
+ array(locality).map { |l| Bib::Locality.new(**l) }
92
+ end
93
+
94
+ def locality_stack(locality_stack)
95
+ array(locality_stack).map { |l| Bib::LocalityStack.new locality: locality(l[:locality]) }
96
+ end
97
+
98
+ def size_hash_to_bib(ret)
99
+ return unless ret[:size]
100
+
101
+ ret[:size] = array(ret[:size])
102
+ value = ret[:size]&.map do |val|
103
+ val[:content] = val.delete(:value)
104
+ Bib::Size::Value.new(**val)
105
+ end
106
+ ret[:size] = Bib::Size.new(value: value)
107
+ end
108
+
109
+ def title_hash_to_bib(ret)
110
+ # return unless ret[:title]
111
+
112
+ # ret[:title] = array(ret[:title]).reduce(Bib::TitleCollection.new) do |m, t|
113
+ # m << (t.is_a?(Hash) ? Bib::Title.new(**t) : Bib::Title.new(content: t))
114
+ # end
115
+ ret[:title] &&= title_collection(ret[:title])
116
+ end
117
+
118
+ def language_hash_to_bib(ret)
119
+ return unless ret[:language]
120
+
121
+ ret[:language] = array(ret[:language])
122
+ end
123
+
124
+ def script_hash_to_bib(ret)
125
+ return unless ret[:script]
126
+
127
+ ret[:script] = array(ret[:script])
128
+ end
129
+
130
+ def abstract_hash_to_bib(ret)
131
+ ret[:abstract] &&= array(ret[:abstract]).map do |a|
132
+ a = { content: a } if a.is_a?(String)
133
+ lang_scrip_array_to_string(a)
134
+ Bib::Abstract.new(**a)
135
+ end
136
+ end
137
+
138
+ def link_hash_to_bib(ret)
139
+ return unless ret[:link]
140
+
141
+ ret[:source] = array(ret[:link]).map do |l|
142
+ Bib::Uri.new(**l)
143
+ end
144
+ end
145
+
146
+ def place_hash_to_bib(ret)
147
+ ret[:place] &&= array(ret[:place]).map { |pl| create_place(pl) }
148
+ end
149
+
150
+ def create_place(place)
151
+ if place.is_a?(String)
152
+ Bib::Place.new(formatted_place: place)
153
+ else
154
+ place[:region] &&= create_region(place[:region])
155
+ place[:country] &&= create_region(place[:country])
156
+ Bib::Place.new(**place)
157
+ end
158
+ end
159
+
160
+ def create_region(region)
161
+ array(region).map do |r|
162
+ r[:content] ||= r.delete(:name)
163
+ r[:iso] ||= r.delete(:code)
164
+ Bib::Place::RegionType.new(**r)
165
+ end
166
+ end
167
+
168
+ def accesslocation_hash_to_bib(ret)
169
+ return unless ret[:accesslocation]
170
+
171
+ ret[:accesslocation] = array(ret[:accesslocation])
172
+ end
173
+
174
+ def dates_hash_to_bib(ret)
175
+ ret[:date] &&= array(ret[:date]).map do |d|
176
+ # `at` is synonym of `on`, which is reserved word in YAML
177
+ d[:at] = d.delete(:value) if d[:value]
178
+ Bib::Date.new(**d)
179
+ end
180
+ end
181
+
182
+ def docid_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize
183
+ return unless ret[:docid]
184
+
185
+ ret[:docidentifier] = array(ret[:docid]).map do |id|
186
+ id[:type] ||= id[:id].match(/^\w+(?=\s)/)&.to_s
187
+ id[:content] = id[:id]
188
+ create_docid(**id)
189
+ end
190
+ end
191
+
192
+ def create_docid(**args)
193
+ Bib::Docidentifier.new(**args)
194
+ end
195
+
196
+ def version_hash_to_bib(ret)
197
+ return unless ret[:version]
198
+
199
+ ret[:version] = array(ret[:version]).map { |v| version_entry(v) }
200
+ end
201
+
202
+ def version_entry(hash)
203
+ return Bib::Version.new(**hash) if hash[:content]
204
+
205
+ attrs = { content: legacy_version_content(hash) }
206
+ attrs[:type] = hash[:type] if hash[:type]
207
+ Bib::Version.new(**attrs)
208
+ end
209
+
210
+ def legacy_version_content(hash)
211
+ draft = hash[:draft]
212
+ revdate = hash[:revision_date]
213
+ return "#{draft} (#{revdate})" if draft && revdate
214
+
215
+ draft || revdate
216
+ end
217
+
218
+ def biblionote_hash_to_bib(ret)
219
+ ret[:note] = array(ret.delete(:biblionote)).map do |n|
220
+ n.is_a?(String) ? Bib::Note.new(content: n) : Bib::Note.new(**n)
221
+ end
222
+ end
223
+
224
+ def formattedref_hash_to_bib(ret)
225
+ ret[:formattedref] &&
226
+ ret[:formattedref] = formattedref(ret[:formattedref])
227
+ end
228
+
229
+ def docstatus_hash_to_bib(ret)
230
+ ret[:docstatus] && ret[:status]= Bib::Status.new(
231
+ stage: stage(ret[:docstatus][:stage]),
232
+ substage: stage(ret[:docstatus][:substage]),
233
+ iteration: ret[:docstatus][:iteration],
234
+ )
235
+ end
236
+
237
+ # @param stg [Hash]
238
+ # @return [Relaton::Bib::DocumentStatus::Stage]
239
+ def stage(stg)
240
+ return unless stg
241
+
242
+ args = stg.is_a?(String) ? { content: stg } : stg
243
+ args[:content] ||= args.delete(:value)
244
+ Bib::Status::Stage.new(**args)
245
+ end
246
+
247
+ def contributors_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength,Metrics/PerceivedComplexity
248
+ ret[:contributor] &&= array(ret[:contributor]).map do |c|
249
+ roles = array(c[:role]).map do |r|
250
+ if r.is_a? Hash
251
+ desc = array(r[:description]).map { |d| localized_marked_up_string d }
252
+ Bib::Contributor::Role.new(type: r[:type], description: desc)
253
+ else
254
+ Bib::Contributor::Role.new(type: r)
255
+ end
256
+ end
257
+ c[:role] = roles
258
+ (c[:person] &&= create_person(c[:person])) ||
259
+ (c[:organization] &&= create_organization(c[:organization]))
260
+ Bib::Contributor.new(**c)
261
+ end
262
+ end
263
+
264
+ def edition_hash_to_bib(ret)
265
+ ret[:edition] &&= if ret[:edition].is_a?(Hash)
266
+ Bib::Edition.new(**ret[:edition])
267
+ else
268
+ Bib::Edition.new(content: ret[:edition])
269
+ end
270
+ end
271
+
272
+ def create_organization(org)
273
+ return nil if org.nil?
274
+
275
+ Bib::Organization.new(**org_hash_to_bib(org))
276
+ end
277
+
278
+ def org_hash_to_bib(org) # rubocop:disable Metrics/AbcSize
279
+ org[:identifier] = create_org_identifier(org[:identifier])
280
+ org[:subdivision] = create_org_subdivision(org[:subdivision])
281
+ org[:address] = address_hash_to_bib(org[:contact])
282
+ org[:phone] = phone_hash_to_bib(org[:contact])
283
+ org[:email] = email_hash_to_bib(org[:contact])
284
+ org[:uri] = uri_hash_to_bib(org[:contact] || org)
285
+ org[:logo] = array(org[:logo]).map do |l|
286
+ Bib::Logo.new(image: Bib::Image.new(**l[:image]))
287
+ end
288
+ org[:name] = typed_localized_string(org[:name])
289
+ org[:abbreviation] &&= localizedstring(org[:abbreviation])
290
+ org
291
+ end
292
+
293
+ def create_org_identifier(identifier)
294
+ array(identifier).map do |id|
295
+ Bib::Organization::Identifier.new(type: id[:type], content: id[:id])
296
+ end
297
+ end
298
+
299
+ def create_org_subdivision(subdivision)
300
+ array(subdivision).map do |sub|
301
+ if sub.is_a? String
302
+ orgname = Bib::TypedLocalizedString.new(content: sub)
303
+ Bib::Subdivision.new(name: [orgname])
304
+ elsif sub.is_a?(Hash) && sub[:content]
305
+ sub[:name] = sub.delete(:content)
306
+ Bib::Subdivision.new(**org_hash_to_bib(sub))
307
+ end
308
+ end.compact
309
+ end
310
+
311
+ def typed_localized_string(typed_strs)
312
+ array(typed_strs).map do |args|
313
+ if args.is_a? String
314
+ Bib::TypedLocalizedString.new(content: args)
315
+ elsif args.is_a? Hash
316
+ Bib::TypedLocalizedString.new(**args)
317
+ end
318
+ end
319
+ end
320
+
321
+ # def create_org_name(name)
322
+ # array(name).map do |nm|
323
+ # if nm.is_a?(Hash)
324
+ # Bib::Organization::Name.new(**nm)
325
+ # else
326
+ # Bib::Organization::Name.new(content: nm)
327
+ # end
328
+ # end
329
+ # end
330
+
331
+ def create_person(person)
332
+ Bib::Person.new(
333
+ name: fullname_hash_to_bib(person),
334
+ credential: array(person[:credential]),
335
+ affiliation: affiliation_hash_to_bib(person),
336
+ address: address_hash_to_bib(person[:contact]),
337
+ phone: phone_hash_to_bib(person[:contact]),
338
+ email: email_hash_to_bib(person[:contact]),
339
+ uri: uri_hash_to_bib(person[:contact]),
340
+ identifier: person_identifiers_hash_to_bib(person),
341
+ )
342
+ end
343
+
344
+ def fullname_hash_to_bib(person) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
345
+ n = person[:name]
346
+ fname = given_hash_to_bib n[:given] || n # `n` is for backward compatibility
347
+ Bib::FullName.new(
348
+ abbreviation: localizedstring(n[:abbreviation]),
349
+ forename: fname,
350
+ formatted_initials: localizedstring(n.dig(:given, :formatted_initials)),
351
+ addition: array(n[:addition])&.map { |f| localizedstring(f) },
352
+ prefix: array(n[:prefix])&.map { |f| localizedstring(f) },
353
+ surname: localizedstring(n[:surname]),
354
+ completename: localizedstring(n[:completename]),
355
+ )
356
+ end
357
+
358
+ def given_hash_to_bib(given)
359
+ return unless given
360
+
361
+ array(given[:forename])&.map { |f| forename_hash_to_bib(f) }
362
+ end
363
+
364
+ def forename_hash_to_bib(fname)
365
+ case fname
366
+ when Hash
367
+ lang_scrip_array_to_string fname
368
+ FullNameType::Forename.new(**fname)
369
+ when String then FullNameType::Forename.new(content: fname)
370
+ end
371
+ end
372
+
373
+ def person_identifiers_hash_to_bib(person)
374
+ array(person[:identifier])&.map do |a|
375
+ Bib::Person::Identifier.new(type: a[:type], content: a[:id])
376
+ end
377
+ end
378
+
379
+ def affiliation_hash_to_bib(person) # rubocop:disable Metrics/AbcSize
380
+ return [] unless person[:affiliation]
381
+
382
+ array(person[:affiliation]).map do |a|
383
+ a[:description] = array(a[:description]).map do |d|
384
+ localized_marked_up_string d
385
+ end
386
+ Bib::Affiliation.new(
387
+ organization: create_organization(a[:organization]),
388
+ description: a[:description], name: localizedstring(a[:name])
389
+ )
390
+ end
391
+ end
392
+
393
+ def address_hash_to_bib(contact)
394
+ array(contact).reduce([]) do |a, c|
395
+ next a unless c[:address]
396
+
397
+ a << create_address(c[:address])
398
+ end
399
+ end
400
+
401
+ def phone_hash_to_bib(contact)
402
+ array(contact).reduce([]) do |a, c|
403
+ next a unless c[:phone]
404
+
405
+ c[:type] ||= "work"
406
+ a << Bib::Phone.new(type: c[:type], content: c[:phone])
407
+ end
408
+ end
409
+
410
+ def email_hash_to_bib(contact)
411
+ array(contact).reduce([]) do |a, c|
412
+ next a unless c[:email]
413
+
414
+ a << c[:email]
415
+ end
416
+ end
417
+
418
+ def uri_hash_to_bib(contact)
419
+ array(contact).reduce([]) do |a, c|
420
+ next a unless c[:uri] || c[:url]
421
+
422
+ a << Bib::Uri.new(content: c[:uri] || c[:url])
423
+ end
424
+ end
425
+
426
+ # def contacts_hash_to_bib(entity) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity
427
+ # return [] unless entity[:contact]
428
+
429
+ # Relaton.array(entity[:contact]).map do |a|
430
+ # type, value = a.reject { |k, _| k == :type }.flatten
431
+ # case type
432
+ # when :street, :city, :state, :country, :postcode # it's for old version compatibility, should be removed in the future
433
+ # a[:street] = Relaton.array(a[:street])
434
+ # Bib::Address.new(**a)
435
+ # when :address then create_address(a[:address])
436
+ # when :phone, :email, :uri
437
+ # Bib::Contact.new(type: type.to_s, value: value, subtype: a[:type])
438
+ # else # it's for old version compatibility, should be removed in the future
439
+ # Bib::Contact.new(**a)
440
+ # end
441
+ # end
442
+ # end
443
+
444
+ def create_address(adr)
445
+ if adr.is_a?(Hash)
446
+ adr[:street] = array(adr[:street])
447
+ Bib::Address.new(**adr)
448
+ else
449
+ Bib::Address.new(formatted_address: adr)
450
+ end
451
+ end
452
+
453
+ # @param ret [Hash]
454
+ def copyright_hash_to_bib(ret)
455
+ ret[:copyright] &&= array(ret[:copyright]).map do |c|
456
+ c[:owner] = array(c[:owner]).map do |o|
457
+ create_contribution_info(o)
458
+ end
459
+ Bib::Copyright.new(**c)
460
+ end
461
+ end
462
+
463
+ def create_contribution_info(contrib)
464
+ if contrib[:name].is_a?(Hash) && (contrib[:name].keys & %i[prefix forename addition surname completename]).any?
465
+ Bib::ContributionInfo.new person: create_person(contrib)
466
+ else
467
+ Bib::ContributionInfo.new organization: create_organization(contrib)
468
+ end
469
+ end
470
+
471
+ # @param ret [Hash]
472
+ def relations_hash_to_bib(ret) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
473
+ return unless ret[:relation]
474
+
475
+ ret[:relation] &&= array(ret[:relation]).map do |rel|
476
+ rel[:description] = LocalizedMarkedUpString.new(**rel[:description]) if rel[:description]
477
+ relation_bibitem_hash_to_bib(rel)
478
+ relation_locality_hash_to_bib(rel)
479
+ relation_locality_stack_hash_to_bib(rel)
480
+ relaton_source_locality_stack_hash_to_bib(rel)
481
+ relation_source_locality_hash_to_bib(rel)
482
+ create_relation rel
483
+ end
484
+ end
485
+
486
+ def create_relation(rel)
487
+ Bib::Relation.new(**rel)
488
+ end
489
+
490
+ # @param rel [Hash] relation
491
+ def relation_bibitem_hash_to_bib(rel)
492
+ if rel[:bibitem]
493
+ rel[:bibitem] = bib_item hash_to_bib(rel[:bibitem])
494
+ else
495
+ Util.warn "Bibitem missing: `#(rel)`"
496
+ rel[:bibitem] = nil
497
+ end
498
+ end
499
+
500
+ # @param item_hash [Hash]
501
+ # @return [Relaton::Bib::Item]
502
+ def bib_item(item_hash)
503
+ ItemData.new(**item_hash)
504
+ end
505
+
506
+ # @param rel [Hash] relation
507
+ # @return [Relaton::Bib::LocalityStack]
508
+ def relation_locality_hash_to_bib(rel)
509
+ return unless rel[:locality]&.any?
510
+
511
+ rel[:locality] = array(rel[:locality]).map do |bl|
512
+ Bib::Locality.new(**bl)
513
+ end
514
+ end
515
+
516
+ def relation_locality_stack_hash_to_bib(rel)
517
+ return unless rel[:locality_stack]&.any?
518
+
519
+ rel[:locality_stack] = array(rel[:locality_stack]).map do |ls|
520
+ Bib::LocalityStack.new locality: relation_locality_hash_to_bib(ls)
521
+ end
522
+ end
523
+
524
+ # def locality_locality_stack(lls)
525
+ # if lls[:locality_stack]
526
+ # RelatonBib.array(lls[:locality_stack]).map do |lc|
527
+ # l = lc[:locality] || lc
528
+ # Locality.new(l[:type], l[:reference_from], l[:reference_to])
529
+ # end
530
+ # else
531
+ # [Locality.new(lls[:type], lls[:reference_from], lls[:reference_to])]
532
+ # end
533
+ # end
534
+
535
+ # @param rel [Hash] relation
536
+ def relation_source_locality_hash_to_bib(rel)
537
+ rel[:source_locality] = array(rel[:source_locality]).map do |loc|
538
+ Bib::Locality.new(**loc)
539
+ end
540
+ end
541
+
542
+ def relaton_source_locality_stack_hash_to_bib(rel) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
543
+ sls = array(rel[:source_locality_stack])
544
+ array(rel[:source_locality]).each do |loc|
545
+ sls << array(loc[:source_locality_stack]) if loc[:source_locality_stack]
546
+ end
547
+
548
+ case rel[:source_locality]
549
+ when Hash then rel[:source_locality].delete(:source_locality_stack)
550
+ when Array then rel[:source_locality].delete_if { |loc| loc[:source_locality_stack] }
551
+ end
552
+
553
+ rel[:source_locality_stack] = sls.map do |loc|
554
+ SourceLocalityStack.new source_locality: relation_source_locality_hash_to_bib(source_locality: loc)
555
+ end
556
+ end
557
+
558
+ # @param ret [Hash]
559
+ def series_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
560
+ ret[:series] &&= array(ret[:series]).map do |s|
561
+ s[:formattedref] && s[:formattedref] = formattedref(s[:formattedref])
562
+ s[:title] &&= title_collection(s[:title])
563
+ s[:place] &&= create_place(s[:place])
564
+ s[:abbreviation] &&= localizedstring(s[:abbreviation])
565
+ s[:from] &&= s[:from].to_s
566
+ s[:to] &&= s[:to].to_s
567
+ Bib::Series.new(**s)
568
+ end
569
+ end
570
+
571
+ #
572
+ # @param title [Hash, Strinbg, Array<Hash, String>]
573
+ #
574
+ # @return [Relaton::Bib::TitleCollection]
575
+ #
576
+ def title_collection(title)
577
+ array(title).map do |t|
578
+ if t.is_a?(Hash)
579
+ lang_scrip_array_to_string t
580
+ Bib::Title.new(**t)
581
+ elsif t.is_a?(String)
582
+ Bib::Title.new(content: t)
583
+ end
584
+ end
585
+ end
586
+
587
+ # @param ret [Hash]
588
+ def medium_hash_to_bib(ret)
589
+ ret[:medium] = Bib::Medium.new(**ret[:medium]) if ret[:medium]
590
+ end
591
+
592
+ # @param ret [Hash]
593
+ def classification_hash_to_bib(ret)
594
+ if ret[:classification]
595
+ ret[:classification] = array(ret[:classification]).map do |cls|
596
+ cls[:content] ||= cls.delete(:value)
597
+ Docidentifier.new(**cls)
598
+ end
599
+ end
600
+ end
601
+
602
+ # @param ret [Hash]
603
+ def validity_hash_to_bib(ret)
604
+ return unless ret[:validity]
605
+
606
+ b = parse_validity_time(ret[:validity], :begins)
607
+ e = parse_validity_time(ret[:validity], :ends)
608
+ r = parse_validity_time(ret[:validity], :revision)
609
+ ret[:validity] = Bib::Validity.new(begins: b, ends: e, revision: r)
610
+ end
611
+
612
+ def parse_validity_time(val, period)
613
+ t = val[period]&.to_s
614
+ return unless t
615
+
616
+ p = period == :ends ? -1 : 1
617
+ case t
618
+ when /^\d{4}$/
619
+ ::Date.new(t.to_i, p, p).to_datetime.to_time.utc
620
+ when /^(?<year>\d{4})-(?<month>\d{1,2})$/
621
+ ::Date.new($~[:year].to_i, $~[:month].to_i, p).to_datetime.to_time.utc
622
+ else
623
+ # Default to UTC when no timezone is specified
624
+ t += " UTC" unless t.match?(/[+-]\d{2}:?\d{2}\s*$|Z\s*$/i)
625
+ ::Time.parse t
626
+ end
627
+ end
628
+
629
+ # @param ret [Hash]
630
+ def editorialgroup_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
631
+ eg = ret.dig(:ext, :editorialgroup) || ret[:editorialgroup]
632
+ return unless eg
633
+
634
+ ret[:ext]&.delete(:editorialgroup)
635
+ ret.delete(:editorialgroup)
636
+ ret[:contributor] ||= []
637
+ array(eg).each do |wg|
638
+ wg[:content] ||= wg.delete(:name)
639
+ ret[:contributor] << Bib::Contributor.new(
640
+ role: [Bib::Contributor::Role.new(
641
+ type: "author",
642
+ description: [Bib::LocalizedMarkedUpString.new(content: "committee")],
643
+ )],
644
+ organization: Bib::Organization.new(
645
+ name: wg[:prefix] ? [Bib::TypedLocalizedString.new(content: wg[:prefix])] : [],
646
+ subdivision: [Bib::Subdivision.new(
647
+ type: "technical-committee",
648
+ subtype: wg[:type],
649
+ name: [Bib::TypedLocalizedString.new(content: wg[:content])],
650
+ identifier: eg_identifiers(wg),
651
+ )],
652
+ abbreviation: wg[:prefix] ? Bib::LocalizedString.new(content: wg[:prefix]) : nil,
653
+ ),
654
+ )
655
+ end
656
+ end
657
+
658
+ def eg_identifiers(workgroup) # rubocop:disable Metrics/MethodLength
659
+ ids = []
660
+ if workgroup[:number]
661
+ ids << Bib::OrganizationType::Identifier.new(
662
+ content: workgroup[:number].to_s,
663
+ )
664
+ end
665
+ if workgroup[:identifier]
666
+ ids << Bib::OrganizationType::Identifier.new(
667
+ content: workgroup[:identifier],
668
+ )
669
+ end
670
+ ids
671
+ end
672
+
673
+ # @param ret [Hash]
674
+ def ics_hash_to_bib(ret)
675
+ ics = ret.dig(:ext, :ics) || ret[:ics] # @todo remove ret[:ics] in the future
676
+ return unless ics
677
+
678
+ ret[:ext][:ics] = array(ics).map { |item| Bib::ICS.new(**item) }
679
+ end
680
+
681
+ # @param ret [Hash]
682
+ def structuredidentifier_hash_to_bib(ret)
683
+ struct_id = ret.dig(:ext, :structuredidentifier) || ret[:structuredidentifier] # @todo remove ret[:structuredidentifier] in the future
684
+ return unless struct_id
685
+
686
+ sids = array(struct_id).map do |si|
687
+ si[:agency] = array si[:agency]
688
+ si[:klass] = si.delete(:class)
689
+ Bib::StructuredIdentifier.new(**si)
690
+ end
691
+ ret[:ext][:structuredidentifier] = sids
692
+ end
693
+
694
+ # @param ogj [Hash, Array, String]
695
+ # @return [Hash, Array, String]
696
+ def symbolize(obj)
697
+ case obj
698
+ when Hash
699
+ obj.reduce({}) do |memo, (k, v)|
700
+ memo[k.to_sym] = symbolize(v)
701
+ memo
702
+ end
703
+ when Array then obj.reduce([]) { |memo, v| memo << symbolize(v) }
704
+ else obj
705
+ end
706
+ end
707
+
708
+ # @param lst [Hash, Array<Relaton::Bib::LocalizedString>, String]
709
+ # @return [Relaton::Bib::LocalizedString]
710
+ def localizedstring(lst)
711
+ return unless lst
712
+
713
+ if lst.is_a?(Hash)
714
+ lang_scrip_array_to_string lst
715
+ Bib::LocalizedString.new(**lst)
716
+ else Bib::LocalizedString.new(content: lst)
717
+ end
718
+ end
719
+
720
+ def lang_scrip_array_to_string(lst)
721
+ lst[:language] = lst[:language][0] if lst[:language].is_a?(Array)
722
+ lst[:script] = lst[:script][0] if lst[:script].is_a?(Array)
723
+ end
724
+
725
+ def localized_marked_up_string(lst)
726
+ return unless lst
727
+
728
+ if lst.is_a?(Hash)
729
+ lang_scrip_array_to_string lst
730
+ LocalizedMarkedUpString.new(**lst)
731
+ else LocalizedMarkedUpString.new(content: lst)
732
+ end
733
+ end
734
+
735
+ # @param frf [Hash, String]
736
+ # @return [Relaton::Bib::Formattedref]
737
+ def formattedref(frf)
738
+ if frf.is_a?(Hash)
739
+ lang_scrip_array_to_string(frf)
740
+ Relaton::Bib::Formattedref.new(**frf)
741
+ else
742
+ Relaton::Bib::Formattedref.new(content: frf)
743
+ end
744
+ end
745
+
746
+ def doctype_hash_to_bib(ret)
747
+ doctype = ret.dig(:ext, :doctype) || ret[:doctype] # @todo remove ret[:doctype] in the future
748
+ return unless doctype
749
+
750
+ ret[:ext][:doctype] = create_doctype(doctype_args(doctype))
751
+ end
752
+
753
+ def doctype_args(args)
754
+ if args.is_a?(String)
755
+ { content: args }
756
+ else
757
+ args[:content] = args.delete(:type)
758
+ args
759
+ end
760
+ end
761
+
762
+ def create_doctype(args)
763
+ Bib::Doctype.new(**args)
764
+ end
765
+ end
766
+ end
767
+ end