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,379 @@
1
+ module Relaton
2
+ module W3c
3
+ class DataParser
4
+ include Relaton::W3c::SafeRealize
5
+
6
+ USED_TYPES = %w[WD NOTE PER PR REC CR].freeze
7
+
8
+ DOCTYPES = {
9
+ "TR" => "technicalReport",
10
+ "NOTE" => "groupNote",
11
+ }.freeze
12
+
13
+ STAGES = {
14
+ "RET" => "Retired",
15
+ "SPSD" => "Superseded Recommendation",
16
+ "OBSL" => "Obsoleted Recommendation",
17
+ "WD" => "Working Draft",
18
+ "CRD" => "Candidate Recommendation Draft",
19
+ "CR" => "Candidate Recommendation",
20
+ "PR" => "Proposed Recommendation",
21
+ "PER" => "Proposed Edited Recommendation",
22
+ "REC" => "Recommendation",
23
+ }.freeze
24
+
25
+ #
26
+ # Document parser initalization
27
+ #
28
+ # @param [W3cApi::Models::SpecVersion] spec
29
+ #
30
+ ERROR_KEYS = %i[status title doc_uri formattedref series date
31
+ relation contributor doctype].freeze
32
+
33
+ def initialize(spec, errors = {})
34
+ @spec = spec
35
+ @errors = errors
36
+ ERROR_KEYS.each { |k| @errors[k] = true unless @errors.key?(k) }
37
+ end
38
+
39
+ #
40
+ # Initialize document parser and run it
41
+ #
42
+ # @param [W3cApi::Models::SpecVersion] spec
43
+ #
44
+ # @return [Relaton::W3c::ItemData, nil] bibliographic item
45
+ #
46
+ def self.parse(spec, errors = {})
47
+ new(spec, errors).parse
48
+ end
49
+
50
+ #
51
+ # Parse document
52
+ #
53
+ # @return [Relaton::W3c::ItemData] bibliographic item
54
+ #
55
+ def parse # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
56
+ ItemData.new(
57
+ type: "standard",
58
+ language: ["en"],
59
+ script: ["Latn"],
60
+ status: parse_status,
61
+ title: parse_title,
62
+ source: parse_source,
63
+ docidentifier: parse_docid,
64
+ formattedref: parse_formattedref,
65
+ docnumber: identifier,
66
+ series: parse_series,
67
+ date: parse_date,
68
+ relation: parse_relation,
69
+ contributor: parse_contrib,
70
+ ext: parse_ext,
71
+ )
72
+ end
73
+
74
+ #
75
+ # Parse ext with doctype
76
+ #
77
+ # @return [Ext, nil] ext
78
+ #
79
+ def parse_ext
80
+ dt = parse_doctype
81
+ result = Ext.new(doctype: dt, flavor: "w3c")
82
+ result
83
+ end
84
+
85
+ #
86
+ # Extract document status
87
+ #
88
+ # @return [Bib::Status, nil] document status
89
+ #
90
+ def parse_status
91
+ result = if @spec.respond_to?(:status) && @spec.status
92
+ Bib::Status.new(stage: Bib::Status::Stage.new(content: @spec.status))
93
+ end
94
+ @errors[:status] &&= result.nil?
95
+ result
96
+ end
97
+
98
+ #
99
+ # Parse title
100
+ #
101
+ # @return [Array<Bib::Title>] title
102
+ #
103
+ def parse_title(spec = @spec)
104
+ return [] unless spec&.title && spec.title.strip != ""
105
+
106
+ result = [Bib::Title.new(content: spec.title, language: "en", script: "Latn")]
107
+ @errors[:title] &&= result.empty?
108
+ result
109
+ end
110
+
111
+ def doc_uri(spec = @spec)
112
+ result = spec.respond_to?(:uri) ? spec.uri : spec.shortlink
113
+ @errors[:doc_uri] &&= result.nil?
114
+ result
115
+ end
116
+
117
+ #
118
+ # Parse link
119
+ #
120
+ # @return [Array<Bib::Uri>] link
121
+ #
122
+ def parse_source
123
+ [Bib::Uri.new(type: "src", content: doc_uri)]
124
+ end
125
+
126
+ #
127
+ # Parse docidentifier
128
+ #
129
+ # @return [Array<Bib::Docidentifier>] docidentifier
130
+ #
131
+ def parse_docid
132
+ id = pub_id(doc_uri)
133
+ [Bib::Docidentifier.new(type: "W3C", content: id, primary: true)]
134
+ end
135
+
136
+ #
137
+ # Generate PubID
138
+ #
139
+ # @return [String] PubID
140
+ #
141
+ def pub_id(url)
142
+ "W3C #{identifier(url)}"
143
+ end
144
+
145
+ #
146
+ # Generate identifier from URL
147
+ #
148
+ # @param [String] link
149
+ #
150
+ # @return [String] identifier
151
+ #
152
+ def identifier(link = doc_uri)
153
+ self.class.parse_identifier(link)
154
+ end
155
+
156
+ #
157
+ # Parse identifier from URL
158
+ #
159
+ # @param [String] url URL
160
+ #
161
+ # @return [String] identifier
162
+ #
163
+ def self.parse_identifier(url)
164
+ if /.+\/(\w+(?:[-+][\w.]+)+(?:\/\w+)?)/ =~ url.to_s
165
+ $1.to_s
166
+ else url.to_s.split("/").last
167
+ end
168
+ end
169
+
170
+ #
171
+ # Parse series
172
+ #
173
+ # @return [Array<Bib::Series>] series
174
+ #
175
+ def parse_series
176
+ result = if type
177
+ title = Bib::Title.new(content: "W3C #{type}", language: "en", script: "Latn")
178
+ [Bib::Series.new(title: [title], number: identifier)]
179
+ else
180
+ []
181
+ end
182
+ @errors[:series] &&= result.empty?
183
+ result
184
+ end
185
+
186
+ #
187
+ # Extract type
188
+ #
189
+ # @return [String] type
190
+ #
191
+ def type
192
+ @type ||= @spec.respond_to?(:status) ? @spec.status : "technicalReport"
193
+ end
194
+
195
+ #
196
+ # Parse doctype
197
+ #
198
+ # @return [Doctype, nil] doctype
199
+ #
200
+ def parse_doctype
201
+ t = DOCTYPES[type] || DOCTYPES[type_from_link]
202
+ result = Doctype.new(content: t) if t
203
+ @errors[:doctype] &&= result.nil?
204
+ result
205
+ end
206
+
207
+ #
208
+ # Fetch type from link
209
+ #
210
+ # @return [String, nil] type
211
+ #
212
+ def type_from_link
213
+ @spec.shortlink.strip.match(/www\.w3\.org\/(TR)/)&.to_a&.fetch 1
214
+ end
215
+
216
+ #
217
+ # Parse date
218
+ #
219
+ # @return [Array<Bib::Date>] date
220
+ #
221
+ def parse_date
222
+ result = if @spec.respond_to?(:date)
223
+ [Bib::Date.new(type: "published", at: @spec.date.to_date.to_s)]
224
+ else
225
+ []
226
+ end
227
+ @errors[:date] &&= result.empty?
228
+ result
229
+ end
230
+
231
+ #
232
+ # Parse relation
233
+ #
234
+ # @return [Array<Bib::Relation>] relation
235
+ #
236
+ def parse_relation
237
+ result = if @spec.links.respond_to?(:version_history)
238
+ version_history = realize @spec.links.version_history
239
+ version_history&.links&.spec_versions&.map { |version| create_relation(version, "hasEdition") } || []
240
+ else
241
+ relations
242
+ end
243
+ result = result.compact
244
+ @errors[:relation] &&= result.empty?
245
+ result
246
+ end
247
+
248
+ #
249
+ # Create relations
250
+ #
251
+ # @return [Array<Bib::Relation>] relations
252
+ #
253
+ def relations # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
254
+ rels = []
255
+ rels << create_relation(@spec.links.specification, "editionOf") if @spec.links.respond_to?(:specification)
256
+ if @spec.links.respond_to?(:predecessor_versions) && @spec.links.predecessor_versions
257
+ predecessor_versions = realize @spec.links.predecessor_versions
258
+ predecessor_versions&.links&.predecessor_versions&.each do |version|
259
+ rels << create_relation(version, "obsoletes")
260
+ end
261
+ end
262
+ if @spec.links.respond_to?(:successor_versions) && @spec.links.successor_versions
263
+ successor_versions = realize @spec.links.successor_versions
264
+ successor_versions&.links&.successor_versions&.each do |version|
265
+ rels << create_relation(version, "updatedBy", "errata")
266
+ end
267
+ end
268
+ rels.compact
269
+ end
270
+
271
+ #
272
+ # Create relation
273
+ #
274
+ # @param [Object] version version link
275
+ # @param [String] type relation type
276
+ # @param [String, nil] desc relation description
277
+ #
278
+ # @return [Bib::Relation] relation
279
+ #
280
+ def create_relation(version, type, desc = nil)
281
+ version_spec = realize version
282
+ return nil unless version_spec
283
+
284
+ url = doc_uri(version_spec)
285
+ id = pub_id(url)
286
+ title = parse_title(version_spec)
287
+ docid = Bib::Docidentifier.new(type: "W3C", content: id, primary: true)
288
+ link = [Bib::Uri.new(type: "src", content: url)]
289
+ bib = ItemData.new(title: title, docidentifier: [docid], source: link)
290
+ dsc = Bib::LocalizedMarkedUpString.new(content: desc) if desc
291
+ Bib::Relation.new(type: type, bibitem: bib, description: dsc)
292
+ end
293
+
294
+ #
295
+ # Parse formattedref
296
+ #
297
+ # @return [String, nil] formattedref
298
+ #
299
+ def parse_formattedref
300
+ result = if @spec.respond_to?(:uri)
301
+ Bib::Formattedref.new(content: pub_id(@spec.uri))
302
+ end
303
+ @errors[:formattedref] &&= result.nil?
304
+ result
305
+ end
306
+
307
+ #
308
+ # Parse contributor
309
+ #
310
+ # @return [Array<Bib::Contributor>] contributor
311
+ #
312
+ def parse_contrib # rubocop:disable Metrics/MethodLength
313
+ contribs = [Bib::Contributor.new(
314
+ organization: create_w3c_org,
315
+ role: [Bib::Contributor::Role.new(type: "publisher")],
316
+ )]
317
+
318
+ if @spec.links.respond_to?(:editors)
319
+ editors = realize @spec.links.editors
320
+ editors&.links&.editors&.each do |ed|
321
+ editor = create_editor(ed)
322
+ contribs << editor if editor
323
+ end
324
+ end
325
+
326
+ result = contribs + parse_deliverers
327
+ @errors[:contributor] &&= result.empty?
328
+ result
329
+ end
330
+
331
+ def create_editor(unrealized_editor)
332
+ editor = realize unrealized_editor
333
+ return unless editor
334
+
335
+ surname = Bib::LocalizedString.new(content: editor.family, language: "en", script: "Latn")
336
+ forename = Bib::FullNameType::Forename.new(content: editor.given, language: "en", script: "Latn")
337
+ name = Bib::FullName.new(surname: surname, forename: [forename])
338
+ person = Bib::Person.new(name: name)
339
+ Bib::Contributor.new(
340
+ person: person,
341
+ role: [Bib::Contributor::Role.new(type: "editor")],
342
+ )
343
+ end
344
+
345
+ #
346
+ # Parse deliverers as contributors with role "author" and description "committee"
347
+ #
348
+ # @return [Array<Bib::Contributor>] deliverer contributors
349
+ #
350
+ def parse_deliverers # rubocop:disable Metrics/MethodLength
351
+ return [] unless @spec.links.respond_to?(:deliverers)
352
+
353
+ deliverers = realize @spec.links.deliverers
354
+ return [] unless deliverers&.links&.deliverers
355
+
356
+ deliverers.links.deliverers.map do |edg|
357
+ org = create_w3c_org.tap do |o|
358
+ subdiv_name = Bib::TypedLocalizedString.new(content: edg.title)
359
+ subdiv = Bib::Subdivision.new(name: [subdiv_name], type: "technical-committee")
360
+ o.subdivision = [subdiv]
361
+ end
362
+ role = Bib::Contributor::Role.new(
363
+ type: "author",
364
+ description: [Bib::LocalizedMarkedUpString.new(content: "committee")],
365
+ )
366
+ Bib::Contributor.new(organization: org, role: [role])
367
+ end
368
+ end
369
+
370
+ def create_w3c_org
371
+ Bib::Organization.new(
372
+ name: [Bib::TypedLocalizedString.new(content: "World Wide Web Consortium")],
373
+ abbreviation: Bib::LocalizedString.new(content: "W3C"),
374
+ uri: Bib::Uri.new(content: "https://www.w3.org"),
375
+ )
376
+ end
377
+ end
378
+ end
379
+ end
@@ -0,0 +1,7 @@
1
+ module Relaton
2
+ module W3c
3
+ class Doctype < Bib::Doctype
4
+ attribute :content, :string, values: %w[groupNote technicalReport]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ require_relative "doctype"
2
+
3
+ module Relaton
4
+ module W3c
5
+ class Ext < Bib::Ext
6
+ attribute :doctype, Doctype
7
+
8
+ def get_schema_version = Relaton.schema_versions["relaton-model-w3c"]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ require_relative "item_data"
2
+ require_relative "ext"
3
+
4
+ module Relaton
5
+ module W3c
6
+ class Item < Bib::Item
7
+ model ItemData
8
+
9
+ attribute :ext, Ext
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ module Relaton
2
+ module W3c
3
+ class ItemData < Bib::ItemData
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,49 @@
1
+ require "relaton/core/processor"
2
+
3
+ module Relaton
4
+ module W3c
5
+ class Processor < Relaton::Core::Processor
6
+ attr_reader :idtype
7
+
8
+ def initialize # rubocop:disable Lint/MissingSuper
9
+ @short = :relaton_w3c
10
+ @prefix = "W3C"
11
+ @defaultprefix = %r{^W3C\s}
12
+ @idtype = "W3C"
13
+ @datasets = %w[w3c-api]
14
+ end
15
+
16
+ def get(code, date, opts)
17
+ require_relative "../w3c"
18
+ Bibliography.get(code, date, opts)
19
+ end
20
+
21
+ def fetch_data(_source, opts)
22
+ require_relative "data_fetcher"
23
+ DataFetcher.fetch(**opts)
24
+ end
25
+
26
+ def from_xml(xml)
27
+ require_relative "../w3c"
28
+ Item.from_xml(xml)
29
+ end
30
+
31
+ def from_yaml(yaml)
32
+ require_relative "../w3c"
33
+ Item.from_yaml(yaml)
34
+ end
35
+
36
+ def grammar_hash
37
+ require_relative "../w3c"
38
+ @grammar_hash ||= Relaton::W3c.grammar_hash
39
+ end
40
+
41
+ def remove_index_file
42
+ require_relative "../w3c"
43
+ Relaton::Index.find_or_create(
44
+ :W3C, url: true, file: "#{INDEXFILE}.yaml"
45
+ ).remove_file
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,73 @@
1
+ module Relaton
2
+ module W3c
3
+ class PubId
4
+ PARTS = %i[code stage type year date suff].freeze
5
+
6
+ PARTS.each { |part| attr_accessor part }
7
+
8
+ def initialize(**parts)
9
+ PARTS.each { |part| send "#{part}=", parts[part] }
10
+ end
11
+
12
+ #
13
+ # Parse document identifier.
14
+ #
15
+ # @param [String] docnumber document identifier
16
+ #
17
+ # @return [Relaton::W3c::PubId] document identifier parts
18
+ #
19
+ def self.parse(docnumber) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
20
+ %r{
21
+ (?:^|/)(?:(?:(?<stage>WD|CRD|CR|PR|PER|REC|SPSD|OBSL|RET)|(?<type>D?NOTE|TR))[\s/-])?
22
+ (?<code>\w+(?:[+-][\w.]+)*?)
23
+ (?:-(?<year>(?:18|19|20)\d{2}))?
24
+ (?:-(?<date>\d{8}|\d{6}|\d{4}))?
25
+ (?:/(?<suff>\w+))?(?:$|/)
26
+ }xi =~ docnumber
27
+ entry = { code: code }
28
+ entry[:stage] = stage if stage
29
+ entry[:type] = type if type && type != "TR"
30
+ entry[:year] = year if year
31
+ entry[:date] = date if date
32
+ entry[:suff] = suff if suff
33
+ new(**entry)
34
+ end
35
+
36
+ #
37
+ # Compare document identifiers against Hash ID representation.
38
+ #
39
+ # @param [Hash] other hash of document identifier parts
40
+ #
41
+ # @return [Boolean] true if document identifiers are same
42
+ #
43
+ def ==(other) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
44
+ other[:code].casecmp?(code) && other[:stage] == stage && other[:type] == type &&
45
+ (year.nil? || other[:year] == year) && (date.nil? || other[:date] == date) &&
46
+ (suff.nil? || other[:suff]&.casecmp?(suff))
47
+ end
48
+
49
+ #
50
+ # Convert docidentifier identifier to hash.
51
+ #
52
+ # @return [Hash] hash of docidentifier parts
53
+ #
54
+ def to_hash
55
+ PARTS.each_with_object({}) { |part, hash| hash[part] = send part if send part }
56
+ end
57
+
58
+ #
59
+ # Render docidentifier as a string, the inverse of {.parse}.
60
+ #
61
+ # @return [String] document identifier
62
+ #
63
+ def to_s
64
+ prefix = stage || (type if type && type != "TR")
65
+ base = [prefix, code].compact.join("-")
66
+ base = "#{base}-#{year}" if year
67
+ base = "#{base}-#{date}" if date
68
+ base = "#{base}/#{suff}" if suff
69
+ base
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,59 @@
1
+ require "concurrent/map"
2
+
3
+ module Relaton
4
+ module W3c
5
+ # Thin wrapper over lutaml-hal's `realize`. Successful objects are cached by
6
+ # w3c_api (it caches realized objects keyed by URL), so this only remembers
7
+ # resources that failed terminally and returns nil for them — so one broken
8
+ # link doesn't abort the crawl and isn't re-fetched on every reference.
9
+ #
10
+ # Transient failures are retried upstream: w3c_api retries HTTP 403 (the
11
+ # W3C rate-limit signal) and connection/timeout errors, and lutaml-hal
12
+ # retries 429 and 5xx. By the time an error surfaces here it is terminal.
13
+ module SafeRealize
14
+ # Hrefs that failed terminally — one map shared by every includer
15
+ # (DataFetcher and DataParser) since a broken resource is broken for the
16
+ # whole crawl. Initialized eagerly (at load, single-threaded) so the
17
+ # parallel fetcher's first concurrent access can't race a lazy `||=`;
18
+ # Concurrent::Map then handles the concurrent reads/writes.
19
+ @skipped = Concurrent::Map.new
20
+
21
+ def self.skipped
22
+ @skipped
23
+ end
24
+
25
+ # @param parent_resource [Object, nil] the index/page the link came from.
26
+ # When the page was fetched with `embed: true`, its inlined `_embedded`
27
+ # payload lets the link realize from memory instead of issuing an HTTP
28
+ # request. nil (the default) preserves the plain remote-fetch behavior.
29
+ def realize(obj, parent_resource: nil)
30
+ href = resolve_href(obj)
31
+ return nil if SafeRealize.skipped.key?(href)
32
+
33
+ obj.realize(parent_resource: parent_resource)
34
+ rescue Lutaml::Hal::ConnectionError, Lutaml::Hal::TimeoutError, Faraday::Error, Net::OpenTimeout => e
35
+ # Network-level failure (already retried by w3c_api). The resource itself
36
+ # is fine, so don't skip it permanently — a later reference can try again.
37
+ Util.warn "Failed to realize object: #{href}, error: #{e.message}"
38
+ nil
39
+ rescue Lutaml::Hal::NotFoundError
40
+ Util.warn "Object not found: #{href}"
41
+ SafeRealize.skipped[href] = true
42
+ nil
43
+ rescue Lutaml::Hal::Error => e
44
+ # Definitive upstream error (403 rate-limit, 5xx, 429) already retried by
45
+ # w3c_api / lutaml-hal. Skip the broken/unavailable resource rather than
46
+ # re-hitting it for every link that references it.
47
+ Util.warn "Skipping #{href}, upstream error after retries: #{e.message}"
48
+ SafeRealize.skipped[href] = true
49
+ nil
50
+ end
51
+
52
+ private
53
+
54
+ def resolve_href(obj)
55
+ obj.href || obj.links.self.href
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,8 @@
1
+ module Relaton
2
+ module W3c
3
+ module Util
4
+ extend Relaton::Bib::Util
5
+ PROGNAME = "relaton-w3c".freeze
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,25 @@
1
+ require "relaton/bib"
2
+ require "relaton/index"
3
+ require_relative "version"
4
+ require_relative "w3c/util"
5
+ require_relative "w3c/item"
6
+ require_relative "w3c/bibitem"
7
+ require_relative "w3c/bibdata"
8
+ require_relative "w3c/bibliography"
9
+
10
+ module Relaton
11
+ module W3c
12
+ INDEXFILE = "index-v1".freeze
13
+
14
+ class Error < StandardError; end
15
+
16
+ # Returns hash of XML reammar
17
+ # @return [String]
18
+ def self.grammar_hash
19
+ # gem_path = File.expand_path "..", __dir__
20
+ # grammars_path = File.join gem_path, "grammars", "*"
21
+ # grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
22
+ Digest::MD5.hexdigest Relaton::VERSION # grammars
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,8 @@
1
+ module Relaton
2
+ module Xsf
3
+ class Bibdata < Item
4
+ model ItemData
5
+ include Bib::BibdataShared
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Relaton
2
+ module Xsf
3
+ class Bibitem < Item
4
+ model ItemData
5
+ include Bib::BibitemShared
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,24 @@
1
+ module Relaton
2
+ module Xsf
3
+ module Bibliography
4
+ extend self
5
+
6
+ def search(ref)
7
+ HitCollection.new(ref).search
8
+ end
9
+
10
+ def get(code, _year = nil, _opts = {})
11
+ Util.info "Fetching from Relaton repository ...", key: code
12
+ result = search(code)
13
+ if result.empty?
14
+ Util.info "Not found.", key: code
15
+ return
16
+ end
17
+
18
+ bib = result.first.item
19
+ Util.info "Found: `#{bib.docidentifier.first.content}`", key: code
20
+ bib
21
+ end
22
+ end
23
+ end
24
+ end