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
data/spec/relaton_spec.rb DELETED
@@ -1,800 +0,0 @@
1
- RSpec.describe Relaton::Db do
2
- before :each do |example|
3
- FileUtils.rm_rf %w(testcache testcache2)
4
- @db = Relaton::Db.new "testcache", "testcache2"
5
- Relaton::Db.instance_variable_set :@configuration, nil
6
-
7
- if example.metadata[:vcr]
8
- require "relaton/index"
9
- allow_any_instance_of(Relaton::Index::Type)
10
- .to receive(:actual?).and_return(false)
11
- allow_any_instance_of(Relaton::Index::FileIO)
12
- .to receive(:check_file).and_return(nil)
13
- end
14
- end
15
-
16
- it "rejects an illegal reference prefix" do
17
- expect { @db.fetch("XYZ XYZ", nil, {}) }.to output(
18
- /\[relaton-db\] INFO: \(XYZ XYZ\) `XYZ XYZ` does not/,
19
- ).to_stderr_from_any_process
20
- end
21
-
22
- context "gets an ISO reference" do
23
- it "and caches it" do
24
- docid = Relaton::Bib::Docidentifier.new(content: "ISO 19115-1",
25
- type: "ISO")
26
- item = Relaton::Iso::ItemData.new(
27
- docid: [docid], fetched: Date.today.to_s,
28
- )
29
- expect(Relaton::Iso::Bibliography).to receive(:get)
30
- .with("ISO 19115-1", nil, {}).and_return item
31
- bib = @db.fetch("ISO 19115-1", nil, {})
32
- expect(bib).to be_instance_of Relaton::Iso::ItemData
33
- bib = @db.fetch("ISO 19115-1", nil, {})
34
- expect(bib).to be_instance_of Relaton::Iso::ItemData
35
- end
36
-
37
- it "with year in code" do
38
- docid = Relaton::Bib::Docidentifier.new(content: "ISO 19133:2005",
39
- type: "ISO", primary: true)
40
- item = Relaton::Iso::ItemData.new(
41
- docidentifier: [docid], fetched: Date.today.to_s, type: "standard",
42
- )
43
- expect(Relaton::Iso::Bibliography).to receive(:get)
44
- .with("ISO 19133:2005", nil, {}).and_return item
45
- bib = @db.fetch("ISO 19133:2005")
46
- expect(bib).to be_instance_of Relaton::Iso::ItemData
47
- xml = bib.to_xml
48
- expect(xml).to include 'id="ISO191332005"'
49
- expect(xml).to include 'type="standard"'
50
- testcache = Relaton::Db::Cache.new "testcache"
51
- expect(
52
- testcache.valid_entry?("ISO(ISO 19133:2005)", Date.today.year.to_s),
53
- ).to eq Date.today.year.to_s
54
- end
55
-
56
- context "all parts" do
57
- let(:all_parts_item) do
58
- docid = Relaton::Bib::Docidentifier.new(
59
- content: "ISO 19115 (all parts)", type: "ISO", primary: true,
60
- )
61
- Relaton::Iso::ItemData.new(docidentifier: [docid],
62
- fetched: Date.today.to_s)
63
- end
64
-
65
- it "implicity" do
66
- expect(Relaton::Iso::Bibliography).to receive(:get)
67
- .with("ISO 19115", nil, { all_parts: true }).and_return all_parts_item
68
- bib = @db.fetch("ISO 19115", nil, all_parts: true)
69
- expect(bib.docidentifier[0].content).to eq "ISO 19115 (all parts)"
70
- end
71
-
72
- it "explicity" do
73
- expect(Relaton::Iso::Bibliography).to receive(:get)
74
- .with("ISO 19115 (all parts)", nil, {}).and_return all_parts_item
75
- bib = @db.fetch("ISO 19115 (all parts)")
76
- expect(bib.docidentifier[0].content).to eq "ISO 19115 (all parts)"
77
- end
78
- end
79
-
80
- it "gets sn ISO/DIS reference" do
81
- docid = Relaton::Bib::Docidentifier.new(content: "ISO/DIS 14460",
82
- type: "ISO")
83
- item = Relaton::Iso::ItemData.new(
84
- docidentifier: [docid], fetched: Date.today.to_s,
85
- )
86
- expect(Relaton::Iso::Bibliography).to receive(:get)
87
- .with("ISO/DIS 14460", nil, {}).and_return item
88
- bib = @db.fetch "ISO/DIS 14460"
89
- expect(bib.docidentifier[0].content).to eq "ISO/DIS 14460"
90
- end
91
- end
92
-
93
- context "IEC" do
94
- before do
95
- require "relaton/iec"
96
- docid = Relaton::Iec::Docidentifier.new(
97
- content: "IEC 60050-102:2007", type: "IEC",
98
- )
99
- item = Relaton::Iec::ItemData.new docidentifier: [docid]
100
- expect(Relaton::Iec::Bibliography).to receive(:get).with(
101
- "IEC 60050-102:2007", nil, {}
102
- ).and_return item
103
- end
104
-
105
- it "get by reference" do
106
- bib = @db.fetch "IEC 60050-102:2007"
107
- expect(bib.docidentifier[0].content).to eq "IEC 60050-102:2007"
108
- end
109
-
110
- it "get by URN" do
111
- bib = @db.fetch "urn:iec:std:iec:60050-102:2007:::"
112
- expect(bib.docidentifier[0].content).to eq "IEC 60050-102:2007"
113
- end
114
- end
115
-
116
- context "NIST references" do
117
- it "gets FISP" do
118
- require "relaton/nist"
119
- docid = Relaton::Bib::Docidentifier.new(content: "NIST FIPS 140",
120
- type: "NIST")
121
- item = Relaton::Nist::ItemData.new docidentifier: [docid]
122
- expect(Relaton::Nist::Bibliography).to receive(:get).with(
123
- "NIST FIPS 140", nil, {}
124
- ).and_return item
125
- bib = @db.fetch "NIST FIPS 140"
126
- expect(bib).to be_instance_of Relaton::Nist::ItemData
127
- expect(bib.docidentifier[0].content).to eq "NIST FIPS 140"
128
- end
129
-
130
- it "gets SP" do
131
- require "relaton/nist"
132
- docid = Relaton::Bib::Docidentifier.new(content: "NIST SP 800-38B",
133
- type: "NIST")
134
- item = Relaton::Nist::ItemData.new docidentifier: [docid]
135
- expect(Relaton::Nist::Bibliography).to receive(:get).with(
136
- "NIST SP 800-38B", nil, {}
137
- ).and_return item
138
- bib = @db.fetch "NIST SP 800-38B"
139
- expect(bib).to be_instance_of Relaton::Nist::ItemData
140
- expect(bib.docidentifier[0].content).to eq "NIST SP 800-38B"
141
- end
142
- end
143
-
144
- it "deals with a non-existant ISO reference" do
145
- VCR.use_cassette "iso_111111119115_1" do
146
- bib = @db.fetch("ISO 111111119115-1", nil, {})
147
- expect(bib).to be_nil
148
- expect(File.exist?("testcache")).to be true
149
- expect(File.exist?("testcache2")).to be true
150
- testcache = Relaton::Db::Cache.new "testcache"
151
- expect(testcache.fetched("ISO(ISO 111111119115-1)")).to eq Date.today.to_s
152
- expect(testcache["ISO(ISO 111111119115-1)"]).to include "not_found"
153
- testcache = Relaton::Db::Cache.new "testcache2"
154
- expect(testcache.fetched("ISO(ISO 111111119115-1)")).to eq Date.today.to_s
155
- expect(testcache["ISO(ISO 111111119115-1)"]).to include "not_found"
156
- end
157
- end
158
-
159
- it "list all elements as a serialization" do
160
- %w[ISO\ 19115-1 ISO\ 19115-2].each do |code|
161
- docid = Relaton::Bib::Docidentifier.new(content: code, type: "ISO",
162
- primary: true)
163
- item = Relaton::Iso::ItemData.new(docidentifier: [docid],
164
- fetched: Date.today.to_s)
165
- expect(Relaton::Iso::Bibliography).to receive(:get)
166
- .with(code, nil, {}).and_return item
167
- end
168
- @db.fetch "ISO 19115-1", nil, {}
169
- @db.fetch "ISO 19115-2", nil, {}
170
- # file = "spec/support/list_entries.xml"
171
- # File.write file, @db.to_xml unless File.exist? file
172
- docs = Nokogiri::XML @db.to_xml
173
- expect(docs.xpath("/documents/bibdata").size).to eq 2
174
- end
175
-
176
- it "save/load/delete entry" do
177
- @db.save_entry "test key", "test value"
178
- expect(@db.load_entry("test key")).to eq "test value"
179
- expect(@db.load_entry("not existed key")).to be_nil
180
- @db.save_entry "test key", nil
181
- expect(@db.load_entry("test key")).to be_nil
182
- testcache = Relaton::Db::Cache.new "testcache"
183
- testcache.delete("test_key")
184
- testcache2 = Relaton::Db::Cache.new "testcache2"
185
- testcache2.delete("test_key")
186
- expect(@db.load_entry("test key")).to be_nil
187
- end
188
-
189
- context "get GB reference" do
190
- it "and cache it" do
191
- VCR.use_cassette "gb_t_20223_2006" do
192
- bib = @db.fetch "CN(GB/T 20223)", "2006", {}
193
- expect(bib).to be_instance_of Relaton::Gb::ItemData
194
- expect(bib.to_xml(bibdata: true)).to include <<~XML
195
- <project-number origyr="2006">GB/T 20223-2006</project-number>
196
- XML
197
- expect(File.exist?("testcache")).to be true
198
- expect(File.exist?("testcache2")).to be true
199
- testcache = Relaton::Db::Cache.new "testcache"
200
- expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
201
- <project-number origyr="2006">GB/T 20223-2006</project-number>
202
- XML
203
- testcache = Relaton::Db::Cache.new "testcache2"
204
- expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
205
- <project-number origyr="2006">GB/T 20223-2006</project-number>
206
- XML
207
- end
208
- end
209
-
210
- it "with year" do
211
- VCR.use_cassette "gb_t_20223_2006" do
212
- bib = @db.fetch "CN(GB/T 20223-2006)", nil, {}
213
- expect(bib).to be_instance_of Relaton::Gb::ItemData
214
- expect(bib.to_xml(bibdata: true)).to include <<~XML
215
- <project-number origyr="2006">GB/T 20223-2006</project-number>
216
- XML
217
- expect(File.exist?("testcache")).to be true
218
- expect(File.exist?("testcache2")).to be true
219
- testcache = Relaton::Db::Cache.new "testcache"
220
- expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
221
- <project-number origyr="2006">GB/T 20223-2006</project-number>
222
- XML
223
- testcache = Relaton::Db::Cache.new "testcache2"
224
- expect(testcache["CN(GB/T 20223-2006)"]).to include <<~XML
225
- <project-number origyr="2006">GB/T 20223-2006</project-number>
226
- XML
227
- end
228
- end
229
- end
230
-
231
- it "get RFC reference and cache it" do
232
- VCR.use_cassette "rfc_8341" do
233
- bib = @db.fetch "RFC 8341", nil, {}
234
- expect(bib).to be_instance_of Relaton::Ietf::ItemData
235
- expect(bib.to_xml).to match(
236
- /<bibitem id="RFC8341" type="standard" schema-version="v[\d.]+">/,
237
- )
238
- expect(File.exist?("testcache")).to be true
239
- expect(File.exist?("testcache2")).to be true
240
- testcache = Relaton::Db::Cache.new "testcache"
241
- expect(testcache["IETF(RFC 8341)"]).to include(
242
- '<docidentifier type="IETF" primary="true">RFC 8341</docidentifier>',
243
- )
244
- testcache = Relaton::Db::Cache.new "testcache2"
245
- expect(testcache["IETF(RFC 8341)"]).to include(
246
- '<docidentifier type="IETF" primary="true">RFC 8341</docidentifier>',
247
- )
248
- end
249
- end
250
-
251
- it "get OGC refrence and cache it" do
252
- cc_fr = /\.relaton\/ogc\/bibliography\.json/
253
- allow(File).to receive(:exist?).with(cc_fr).and_return false
254
- allow(File).to receive(:exist?).with(/etag\.txt/).and_return false
255
- expect(File).to receive(:exist?).and_call_original.at_least :once
256
- expect(File).to receive(:write).with(cc_fr, kind_of(String), kind_of(Hash))
257
- .at_most :once
258
- allow(File).to receive(:write).and_call_original
259
- VCR.use_cassette "ogc_19_025r1" do
260
- ogc_bib = "/Users/andrej/.relaton/ogc/bibliography.json"
261
- expect(File).to receive(:exist?).with(ogc_bib)
262
- .and_return(false).at_most :once
263
- ogc_etag = "/Users/andrej/.relaton/ogc/etag.txt"
264
- expect(File).to receive(:exist?).with(ogc_etag)
265
- .and_return(false).at_most :once
266
- allow(File).to receive(:exist?).and_call_original
267
- bib = @db.fetch "OGC 19-025r1", nil, {}
268
- expect(bib).to be_instance_of Relaton::Ogc::ItemData
269
- end
270
- end
271
-
272
- it "get Calconnect refrence and cache it" do
273
- VCR.use_cassette "cc_dir_10005_2019", match_requests_on: [:path] do
274
- bib = @db.fetch "CC/DIR 10005:2019", nil, {}
275
- expect(bib).to be_instance_of Relaton::Calconnect::ItemData
276
- end
277
- end
278
-
279
- it "get OMG reference" do
280
- VCR.use_cassette "omg_ami4ccm_1_0" do
281
- bib = @db.fetch "OMG AMI4CCM 1.0", nil, {}
282
- expect(bib).to be_instance_of Relaton::Omg::ItemData
283
- end
284
- end
285
-
286
- # it "get UN reference" do
287
- # docid = RelatonBib::DocumentIdentifier.new(
288
- # id: "UN TRADE/CEFACT/2004/32", type: "UN",
289
- # )
290
- # item = RelatonUn::UnBibliographicItem.new(
291
- # docid: [docid],
292
- # session: RelatonUn::Session.new(session_number: "1"),
293
- # )
294
- # expect(RelatonUn::UnBibliography).to receive(:get)
295
- # .with("UN TRADE/CEFACT/2004/32", nil, {})
296
- # .and_return item
297
- # bib = @db.fetch "UN TRADE/CEFACT/2004/32", nil, {}
298
- # expect(bib).to be_instance_of(
299
- # RelatonUn::UnBibliographicItem,
300
- # )
301
- # expect(bib.docidentifier.first.id)
302
- # .to eq "UN TRADE/CEFACT/2004/32"
303
- # end
304
-
305
- it "get W3C reference" do
306
- require "relaton/w3c"
307
- docid = Relaton::Bib::Docidentifier.new(
308
- content: "W3C REC-json-ld11-20200716", type: "W3C",
309
- )
310
- item = Relaton::W3c::ItemData.new docidentifier: [docid]
311
- expect(Relaton::W3c::Bibliography).to receive(:get).with(
312
- "W3C REC-json-ld11-20200716", nil, {}
313
- ).and_return item
314
- bib = @db.fetch "W3C REC-json-ld11-20200716", nil, {}
315
- expect(bib).to be_instance_of Relaton::W3c::ItemData
316
- expect(bib.docidentifier.first.content).to eq "W3C REC-json-ld11-20200716"
317
- end
318
-
319
- it "get CCSDS reference" do
320
- require "relaton/ccsds"
321
- docid = Relaton::Bib::Docidentifier.new content: "CCSDS 230.2-G-1",
322
- type: "CCSDS"
323
- item = Relaton::Ccsds::ItemData.new docidentifier: [docid]
324
- expect(Relaton::Ccsds::Bibliography).to receive(:get).with(
325
- "CCSDS 230.2-G-1", nil, {}
326
- ).and_return item
327
- bib = @db.fetch "CCSDS 230.2-G-1", nil, {}
328
- expect(bib).to be_instance_of Relaton::Ccsds::ItemData
329
- expect(bib.docidentifier.first.content).to eq "CCSDS 230.2-G-1"
330
- end
331
-
332
- it "get IEEE reference" do
333
- require "relaton/ieee"
334
- docid = Relaton::Bib::Docidentifier.new(content: "IEEE Std 528-2019",
335
- type: "IEEE")
336
- item = Relaton::Ieee::ItemData.new docidentifier: [docid]
337
- expect(Relaton::Ieee::Bibliography).to receive(:get)
338
- .with("IEEE Std 528-2019", nil, {}).and_return item
339
- bib = @db.fetch "IEEE Std 528-2019"
340
- expect(bib).to be_instance_of Relaton::Ieee::ItemData
341
- end
342
-
343
- it "get IHO reference" do
344
- require "relaton/iho"
345
- docid = Relaton::Bib::Docidentifier.new(content: "IHO B-11", type: "IHO")
346
- item = Relaton::Iho::ItemData.new docidentifier: [docid]
347
- expect(Relaton::Iho::Bibliography).to receive(:get).with("IHO B-11", nil,
348
- {}).and_return item
349
- bib = @db.fetch "IHO B-11"
350
- expect(bib).to be_instance_of Relaton::Iho::ItemData
351
- expect(bib.docidentifier.first.content).to eq "IHO B-11"
352
- end
353
-
354
- it "get ECMA reference" do
355
- require "relaton/ecma"
356
- docid = Relaton::Bib::Docidentifier.new(content: "ECMA-6", type: "ECMA")
357
- item = Relaton::Ecma::ItemData.new docidentifier: [docid]
358
- expect(Relaton::Ecma::Bibliography).to receive(:get)
359
- .with("ECMA-6", nil, {}).and_return item
360
- bib = @db.fetch "ECMA-6"
361
- expect(bib).to be_instance_of Relaton::Ecma::ItemData
362
- end
363
-
364
- it "get CIE reference" do
365
- require "relaton/cie"
366
- docid = Relaton::Bib::Docidentifier.new(content: "CIE 001-1980", type: "CIE")
367
- item = Relaton::Cie::ItemData.new docidentifier: [docid]
368
- expect(Relaton::Cie::Bibliography).to receive(:get)
369
- .with("CIE 001-1980", nil, {}).and_return item
370
- bib = @db.fetch "CIE 001-1980"
371
- expect(bib).to be_instance_of Relaton::Cie::ItemData
372
- end
373
-
374
- it "get BSI reference" do
375
- require "relaton/bsi"
376
- docid = Relaton::Bib::Docidentifier.new(content: "BSI BS EN ISO 8848",
377
- type: "BSI")
378
- item = Relaton::Bsi::ItemData.new docidentifier: [docid]
379
- expect(Relaton::Bsi::Bibliography).to receive(:get).with(
380
- "BSI BS EN ISO 8848", nil, {}
381
- ).and_return item
382
- bib = @db.fetch "BSI BS EN ISO 8848"
383
- expect(bib).to be_instance_of Relaton::Bsi::ItemData
384
- end
385
-
386
- it "get CEN reference" do
387
- require "relaton/cen"
388
- docid = Relaton::Bib::Docidentifier.new(content: "EN 10160:1999", type: "CEN")
389
- item = Relaton::Cen::ItemData.new docidentifier: [docid]
390
- expect(Relaton::Cen::Bibliography).to receive(:get)
391
- .with("EN 10160:1999", nil, {}).and_return item
392
- bib = @db.fetch "EN 10160:1999"
393
- expect(bib).to be_instance_of Relaton::Cen::ItemData
394
- end
395
-
396
- it "get IANA reference" do
397
- require "relaton/iana"
398
- docid = Relaton::Bib::Docidentifier.new(
399
- content: "IANA service-names-port-numbers", type: "IANA",
400
- )
401
- item = Relaton::Iana::ItemData.new docidentifier: [docid]
402
- expect(Relaton::Iana::Bibliography).to receive(:get).with(
403
- "IANA service-names-port-numbers", nil, {}
404
- ).and_return item
405
- bib = @db.fetch "IANA service-names-port-numbers"
406
- expect(bib).to be_instance_of Relaton::Iana::ItemData
407
- end
408
-
409
- it "get 3GPP reference" do
410
- require "relaton/3gpp"
411
- docid = Relaton::Bib::Docidentifier.new(
412
- content: "3GPP TR 00.01U:UMTS/3.0.0", type: "3GPP",
413
- )
414
- item = Relaton::ThreeGpp::ItemData.new docidentifier: [docid]
415
- expect(Relaton::ThreeGpp::Bibliography).to receive(:get)
416
- .with("3GPP TR 00.01U:UMTS/3.0.0", nil, {}).and_return item
417
- bib = @db.fetch "3GPP TR 00.01U:UMTS/3.0.0"
418
- expect(bib).to be_instance_of Relaton::ThreeGpp::ItemData
419
- end
420
-
421
- it "get OASIS reference" do
422
- require "relaton/oasis"
423
- docid = Relaton::Bib::Docidentifier.new(
424
- content: "OASIS amqp-core-types-v1.0-Pt1", type: "OASIS",
425
- )
426
- item = Relaton::Oasis::ItemData.new docidentifier: [docid]
427
- expect(Relaton::Oasis::Bibliography).to receive(:get).with(
428
- "OASIS amqp-core-types-v1.0-Pt1", nil, {}
429
- ).and_return item
430
- bib = @db.fetch "OASIS amqp-core-types-v1.0-Pt1"
431
- expect(bib).to be_instance_of Relaton::Oasis::ItemData
432
- end
433
-
434
- it "get BIPM reference" do
435
- require "relaton/bipm"
436
- docid = Relaton::Bib::Docidentifier.new(
437
- content: "BIPM Metrologia 29 6 373", type: "BIPM",
438
- )
439
- item = Relaton::Bipm::ItemData.new docidentifier: [docid]
440
- expect(Relaton::Bipm::Bibliography).to receive(:get).with(
441
- "BIPM Metrologia 29 6 373", nil, {}
442
- ).and_return item
443
- bib = @db.fetch "BIPM Metrologia 29 6 373"
444
- expect(bib).to be_instance_of Relaton::Bipm::ItemData
445
- expect(bib.docidentifier.first.content).to eq "BIPM Metrologia 29 6 373"
446
- end
447
-
448
- it "get DOI reference" do
449
- require "relaton/doi"
450
- docid = Relaton::Bib::Docidentifier.new(
451
- content: "10.6028/nist.ir.8245", type: "DOI",
452
- )
453
- item = Relaton::Bib::ItemData.new docidentifier: [docid]
454
- expect(Relaton::Doi::Crossref).to receive(:get)
455
- .with("doi:10.6028/nist.ir.8245").and_return item
456
- bib = @db.fetch "doi:10.6028/nist.ir.8245"
457
- expect(bib).to be_instance_of Relaton::Bib::ItemData
458
- end
459
-
460
- it "get JIS reference" do
461
- require "relaton/jis"
462
- docid = Relaton::Bib::Docidentifier.new(content: "JIS X 0001", type: "JIS")
463
- item = Relaton::Jis::ItemData.new docidentifier: [docid]
464
- expect(Relaton::Jis::Bibliography).to receive(:get).with("JIS X 0001", nil,
465
- {}).and_return item
466
- bib = @db.fetch "JIS X 0001"
467
- expect(bib).to be_instance_of Relaton::Jis::ItemData
468
- expect(bib.docidentifier.first.content).to eq "JIS X 0001"
469
- end
470
-
471
- it "get XSF reference" do
472
- require "relaton/xsf"
473
- docid = Relaton::Bib::Docidentifier.new(content: "XEP 0001", type: "XSF")
474
- item = Relaton::Bib::ItemData.new docidentifier: [docid]
475
- expect(Relaton::Xsf::Bibliography).to receive(:get).with("XEP 0001", nil,
476
- {}).and_return item
477
- bib = @db.fetch "XEP 0001"
478
- expect(bib).to be_instance_of Relaton::Xsf::ItemData
479
- expect(bib.docidentifier.first.content).to eq "XEP 0001"
480
- end
481
-
482
- it "get ETSI reference" do
483
- require "relaton/etsi"
484
- docid = Relaton::Bib::Docidentifier.new(content: "ETSI EN 300 175-8",
485
- type: "ETSI")
486
- item = Relaton::Etsi::ItemData.new docidentifier: [docid]
487
- expect(Relaton::Etsi::Bibliography).to receive(:get).with(
488
- "ETSI EN 300 175-8", nil, {}
489
- ).and_return item
490
- bib = @db.fetch "ETSI EN 300 175-8"
491
- expect(bib).to be_instance_of Relaton::Etsi::ItemData
492
- expect(bib.docidentifier.first.content).to eq "ETSI EN 300 175-8"
493
- end
494
-
495
- it "get ISBN reference" do
496
- require "relaton/isbn"
497
- docid = Relaton::Bib::Docidentifier.new(content: "ISBN 978-0-580-50101-4",
498
- type: "ISBN")
499
- item = Relaton::Bib::ItemData.new docidentifier: [docid]
500
- expect(Relaton::Isbn::OpenLibrary).to receive(:get).with(
501
- "ISBN 978-0-580-50101-4", nil, {}
502
- ).and_return item
503
- bib = @db.fetch "ISBN 978-0-580-50101-4"
504
- expect(bib).to be_instance_of Relaton::Bib::ItemData
505
- expect(bib.docidentifier.first.content).to eq "ISBN 978-0-580-50101-4"
506
- end
507
-
508
- it "get PLATEAU reference" do
509
- require "relaton/plateau"
510
- docid = Relaton::Bib::Docidentifier.new(content: "PLATEAU Hanbook #01",
511
- type: "PLATEAU")
512
- item = Relaton::Plateau::ItemData.new docidentifier: [docid]
513
- expect(Relaton::Plateau::Bibliography).to receive(:get).with(
514
- "PLATEAU Hanbook #01", nil, {}
515
- ).and_return item
516
- bib = @db.fetch "PLATEAU Hanbook #01"
517
- expect(bib).to be_instance_of Relaton::Plateau::ItemData
518
- expect(bib.docidentifier.first.content).to eq "PLATEAU Hanbook #01"
519
- end
520
-
521
- context "get combined documents" do
522
- context "ISO" do
523
- # combine_doc (Db's own logic) fetches the base + amendment separately
524
- # and assembles the relation graph; only the per-part lookups are stubbed,
525
- # so the relation types/descriptions assembled here stay fully exercised.
526
- def iso_item(content)
527
- docid = Relaton::Bib::Docidentifier.new(content: content, type: "ISO",
528
- primary: true)
529
- Relaton::Iso::ItemData.new(docidentifier: [docid],
530
- fetched: Date.today.to_s)
531
- end
532
-
533
- before do
534
- expect(Relaton::Iso::Bibliography).to receive(:get)
535
- .with("ISO 19115-1:2014", nil, {})
536
- .and_return iso_item("ISO 19115-1:2014")
537
- expect(Relaton::Iso::Bibliography).to receive(:get)
538
- .with("ISO 19115-1:2014/Amd 1", nil, {})
539
- .and_return iso_item("ISO 19115-1:2014/Amd 1:2018")
540
- end
541
-
542
- it "included" do
543
- bib = @db.fetch "ISO 19115-1:2014 + Amd 1"
544
- expect(bib.docidentifier[0].content)
545
- .to eq "ISO 19115-1:2014 + Amd 1"
546
- expect(bib.relation[0].type).to eq "updates"
547
- rel0 = bib.relation[0].bibitem
548
- expect(rel0.docidentifier[0].content)
549
- .to eq "ISO 19115-1:2014"
550
- expect(bib.relation[1].type).to eq "derivedFrom"
551
- expect(bib.relation[1].description).to be_nil
552
- rel1 = bib.relation[1].bibitem
553
- expect(rel1.docidentifier[0].content)
554
- .to eq "ISO 19115-1:2014/Amd 1:2018"
555
- end
556
-
557
- it "applied" do
558
- bib = @db.fetch "ISO 19115-1:2014, Amd 1"
559
- expect(bib.docidentifier[0].content)
560
- .to eq "ISO 19115-1:2014, Amd 1"
561
- expect(bib.relation[0].type).to eq "updates"
562
- rel0 = bib.relation[0].bibitem
563
- expect(rel0.docidentifier[0].content)
564
- .to eq "ISO 19115-1:2014"
565
- expect(bib.relation[1].type).to eq "complements"
566
- expect(bib.relation[1].description.content)
567
- .to eq "amendment"
568
- rel1 = bib.relation[1].bibitem
569
- expect(rel1.docidentifier[0].content)
570
- .to eq "ISO 19115-1:2014/Amd 1:2018"
571
- end
572
- end
573
-
574
- context "IEC" do
575
- it "included" do
576
- require "relaton/iec"
577
- docid = Relaton::Iec::Docidentifier.new(
578
- content: "IEC 60027-1", type: "IEC",
579
- )
580
- item = Relaton::Iec::ItemData.new(
581
- docidentifier: [docid],
582
- )
583
- expect(Relaton::Iec::Bibliography).to receive(:get)
584
- .with("IEC 60027-1", nil, {}).and_return item
585
- docid1 = Relaton::Iec::Docidentifier.new(
586
- content: "IEC 60027-1/AMD1:1997", type: "IEC",
587
- )
588
- item1 = Relaton::Iec::ItemData.new(
589
- docidentifier: [docid1],
590
- )
591
- expect(Relaton::Iec::Bibliography).to receive(:get)
592
- .with("IEC 60027-1/Amd 1", nil, {})
593
- .and_return item1
594
- docid2 = Relaton::Iec::Docidentifier.new(
595
- content: "IEC 60027-1/AMD2:2005", type: "IEC",
596
- )
597
- item2 = Relaton::Iec::ItemData.new(
598
- docidentifier: [docid2],
599
- )
600
- expect(Relaton::Iec::Bibliography).to receive(:get)
601
- .with("IEC 60027-1/Amd 2", nil, {})
602
- .and_return item2
603
- bib = @db.fetch "IEC 60027-1, Amd 1, Amd 2"
604
- expect(bib.docidentifier[0].content)
605
- .to eq "IEC 60027-1, Amd 1, Amd 2"
606
- expect(bib.relation[0].type).to eq "updates"
607
- rel0 = bib.relation[0].bibitem
608
- expect(rel0.docidentifier[0].content)
609
- .to eq "IEC 60027-1"
610
- expect(bib.relation[1].type).to eq "complements"
611
- expect(bib.relation[1].description.content)
612
- .to eq "amendment"
613
- rel1 = bib.relation[1].bibitem
614
- expect(rel1.docidentifier[0].content)
615
- .to eq "IEC 60027-1/AMD1:1997"
616
- expect(bib.relation[2].type).to eq "complements"
617
- expect(bib.relation[2].description.content)
618
- .to eq "amendment"
619
- rel2 = bib.relation[2].bibitem
620
- expect(rel2.docidentifier[0].content)
621
- .to eq "IEC 60027-1/AMD2:2005"
622
- end
623
- end
624
-
625
- context "ITU" do
626
- it "included" do
627
- require "relaton/itu"
628
- docid = Relaton::Bib::Docidentifier.new(content: "ITU-T G.989.2",
629
- type: "ITU")
630
- org = Relaton::Bib::Organization.new(
631
- name: [Relaton::Bib::TypedLocalizedString.new(
632
- content: "International Telecommunication Union",
633
- )],
634
- abbreviation: Relaton::Bib::LocalizedString.new(content: "ITU-T"),
635
- subdivision: [Relaton::Bib::Subdivision.new(
636
- type: "technical-committee",
637
- subtype: "study-group",
638
- name: [Relaton::Bib::TypedLocalizedString.new(content: "Group")],
639
- )],
640
- )
641
- role = Relaton::Bib::Contributor::Role.new(
642
- type: "author",
643
- description: [Relaton::Bib::LocalizedMarkedUpString.new(
644
- content: "committee",
645
- )],
646
- )
647
- contrib = Relaton::Bib::Contributor.new(organization: org, role: [role])
648
- item = Relaton::Itu::ItemData.new(
649
- docidentifier: [docid], contributor: [contrib],
650
- )
651
- expect(Relaton::Itu::Bibliography).to receive(:get).with(
652
- "ITU-T G.989.2", nil, {}
653
- ).and_return item
654
- docid1 = Relaton::Bib::Docidentifier.new(
655
- content: "ITU-T G.989.2 Amd 1", type: "ITU",
656
- )
657
- item1 = Relaton::Itu::ItemData.new(
658
- docidentifier: [docid1], contributor: [contrib],
659
- )
660
- expect(Relaton::Itu::Bibliography).to receive(:get).with(
661
- "ITU-T G.989.2 Amd 1", nil, {}
662
- ).and_return item1
663
- docid2 = Relaton::Bib::Docidentifier.new(
664
- content: "ITU-T G.989.2 Amd 2", type: "ITU",
665
- )
666
- item2 = Relaton::Itu::ItemData.new(
667
- docidentifier: [docid2], contributor: [contrib],
668
- )
669
- expect(Relaton::Itu::Bibliography).to receive(:get).with(
670
- "ITU-T G.989.2 Amd 2", nil, {}
671
- ).and_return item2
672
- bib = @db.fetch "ITU-T G.989.2, Amd 1, Amd 2"
673
- expect(bib.docidentifier[0].content)
674
- .to eq "ITU-T G.989.2, Amd 1, Amd 2"
675
- expect(bib.relation[0].type).to eq "updates"
676
- rel0 = bib.relation[0].bibitem
677
- expect(rel0.docidentifier[0].content)
678
- .to eq "ITU-T G.989.2"
679
- expect(bib.relation[1].type).to eq "complements"
680
- expect(bib.relation[1].description.content)
681
- .to eq "amendment"
682
- rel1 = bib.relation[1].bibitem
683
- expect(rel1.docidentifier[0].content)
684
- .to eq "ITU-T G.989.2 Amd 1"
685
- expect(bib.relation[2].type).to eq "complements"
686
- expect(bib.relation[2].description.content)
687
- .to eq "amendment"
688
- rel2 = bib.relation[2].bibitem
689
- expect(rel2.docidentifier[0].content)
690
- .to eq "ITU-T G.989.2 Amd 2"
691
- end
692
- end
693
-
694
- context "NIST" do
695
- it "included" do
696
- # VCR.use_cassette "nist_combined_included" do
697
- require "relaton/nist"
698
- doci = Relaton::Bib::Docidentifier.new(content: "SP 800-38A",
699
- type: "NIST")
700
- item = Relaton::Nist::ItemData.new docidentifier: [doci]
701
- expect(Relaton::Nist::Bibliography).to receive(:get).with(
702
- "NIST SP 800-38A", nil, {}
703
- ).and_return item
704
- docid1 = Relaton::Bib::Docidentifier.new(content: "SP 800-38A-Add",
705
- type: "NIST")
706
- item1 = Relaton::Nist::ItemData.new docidentifier: [docid1]
707
- expect(Relaton::Nist::Bibliography).to receive(:get).with(
708
- "NIST SP 800-38A/Add", nil, {}
709
- ).and_return item1
710
- bib = @db.fetch "NIST SP 800-38A, Add"
711
- expect(bib.docidentifier[0].content).to eq "NIST SP 800-38A, Add"
712
- expect(bib.relation[0].type).to eq "updates"
713
- rel0 = bib.relation[0].bibitem
714
- expect(rel0.docidentifier[0].content)
715
- .to eq "SP 800-38A"
716
- expect(bib.relation[1].type).to eq "complements"
717
- expect(bib.relation[1].description.content)
718
- .to eq "amendment"
719
- rel1 = bib.relation[1].bibitem
720
- expect(rel1.docidentifier[0].content)
721
- .to eq "SP 800-38A-Add"
722
- # end
723
- end
724
- end
725
- end
726
-
727
- context "version control" do
728
- before(:each) do
729
- @db.save_entry "iso(test_key)",
730
- "<bibitem><title>test_value</title></bibitem>"
731
- end
732
-
733
- it "shoudn't clear cache if version isn't changed" do
734
- testcache = @db.instance_variable_get :@db
735
- expect(testcache.all).to be_any
736
- testcache = @db.instance_variable_get :@local_db
737
- expect(testcache.all).to be_any
738
- end
739
-
740
- it "should clear cache if version is changed" do
741
- expect(File.read("testcache/iso/version",
742
- encoding: "UTF-8")).not_to eq "new_version"
743
- expect(File.read("testcache2/iso/version",
744
- encoding: "UTF-8")).not_to eq "new_version"
745
- processor = double "processor", short: :relaton_iso
746
- expect(processor).to receive(:grammar_hash)
747
- .and_return("new_version").exactly(2).times
748
- expect(Relaton::Db::Registry.instance)
749
- .to receive(:by_type)
750
- .and_return(processor).exactly(2).times
751
- Relaton::Db.new "testcache", "testcache2"
752
- expect(File.exist?("testcache/iso/version")).to eq false
753
- expect(File.exist?("testcache2/iso/version")).to eq false
754
- end
755
- end
756
-
757
- context "api.relaton.org" do
758
- before(:each) do
759
- Relaton::Db.configure do |config|
760
- config.use_api = true
761
- # config.api_host = "http://0.0.0.0:9292"
762
- end
763
- end
764
-
765
- after(:each) do
766
- Relaton::Db.configure do |config|
767
- config.use_api = false
768
- end
769
- end
770
-
771
- it "get document" do
772
- VCR.use_cassette "api_relaton_org" do
773
- bib = @db.fetch "ISO 19115-2", "2019"
774
- expect(bib).to be_instance_of Relaton::Iso::ItemData
775
- end
776
- end
777
-
778
- it "if unavailable then get document directly" do
779
- docid = Relaton::Bib::Docidentifier.new(content: "ISO 19115-2:2019",
780
- type: "ISO", primary: true)
781
- item = Relaton::Iso::ItemData.new(docidentifier: [docid],
782
- fetched: Date.today.to_s)
783
- # api.relaton.org is refused below, so the fetch must fall back to the
784
- # flavor's direct lookup -- stub that so the fallback path is exercised
785
- # without depending on the live ISO index.
786
- expect(Relaton::Iso::Bibliography).to receive(:get)
787
- .with("ISO 19115-2", "2019", {}).and_return item
788
- expect(Net::HTTP).to receive(:get_response)
789
- .and_wrap_original do |m, *args|
790
- raise Errno::ECONNREFUSED if args[0].host == "api.relaton.org"
791
-
792
- m.call(*args)
793
- end.at_least :once
794
- VCR.use_cassette "api_relaton_org_unavailable" do
795
- bib = @db.fetch "ISO 19115-2", "2019"
796
- expect(bib).to be_instance_of Relaton::Iso::ItemData
797
- end
798
- end
799
- end
800
- end