relaton 2.2.0.pre.alpha.1 → 3.0.0.pre.alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{docs/README.adoc → README.adoc} +165 -38
- data/bin/console +0 -1
- data/lib/relaton/3gpp/bibdata.rb +9 -0
- data/lib/relaton/3gpp/bibitem.rb +9 -0
- data/lib/relaton/3gpp/bibliography.rb +123 -0
- data/lib/relaton/3gpp/data_fetcher.rb +303 -0
- data/lib/relaton/3gpp/docidentifier.rb +114 -0
- data/lib/relaton/3gpp/doctype.rb +9 -0
- data/lib/relaton/3gpp/ext.rb +31 -0
- data/lib/relaton/3gpp/item.rb +18 -0
- data/lib/relaton/3gpp/item_data.rb +15 -0
- data/lib/relaton/3gpp/parser.rb +400 -0
- data/lib/relaton/3gpp/processor.rb +71 -0
- data/lib/relaton/3gpp/release.rb +34 -0
- data/lib/relaton/3gpp/util.rb +8 -0
- data/lib/relaton/3gpp.rb +29 -0
- data/lib/relaton/adobe/bibdata.rb +8 -0
- data/lib/relaton/adobe/bibitem.rb +8 -0
- data/lib/relaton/adobe/bibliography.rb +92 -0
- data/lib/relaton/adobe/docidentifier.rb +49 -0
- data/lib/relaton/adobe/doctype.rb +14 -0
- data/lib/relaton/adobe/ext.rb +32 -0
- data/lib/relaton/adobe/item.rb +15 -0
- data/lib/relaton/adobe/item_base.rb +18 -0
- data/lib/relaton/adobe/item_data.rb +6 -0
- data/lib/relaton/adobe/processor.rb +45 -0
- data/lib/relaton/adobe/util.rb +8 -0
- data/lib/relaton/adobe.rb +37 -0
- data/lib/relaton/bib/converter/asciibib/to_asciibib.rb +663 -0
- data/lib/relaton/bib/converter/asciibib.rb +13 -0
- data/lib/relaton/bib/converter/bibtex/from_bibtex.rb +245 -0
- data/lib/relaton/bib/converter/bibtex/to_bibtex.rb +341 -0
- data/lib/relaton/bib/converter/bibtex.rb +23 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml.rb +386 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml_referencegroup.rb +71 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml.rb +308 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml_referencegroup.rb +52 -0
- data/lib/relaton/bib/converter/bibxml.rb +51 -0
- data/lib/relaton/bib/hash_parser_v1.rb +767 -0
- data/lib/relaton/bib/item_data.rb +229 -0
- data/lib/relaton/bib/model/abstract.rb +16 -0
- data/lib/relaton/bib/model/address.rb +22 -0
- data/lib/relaton/bib/model/affiliation.rb +16 -0
- data/lib/relaton/bib/model/bibdata.rb +11 -0
- data/lib/relaton/bib/model/bibdata_shared.rb +12 -0
- data/lib/relaton/bib/model/bibitem.rb +11 -0
- data/lib/relaton/bib/model/bibitem_shared.rb +12 -0
- data/lib/relaton/bib/model/contact.rb +18 -0
- data/lib/relaton/bib/model/contribution_info.rb +15 -0
- data/lib/relaton/bib/model/contributor.rb +29 -0
- data/lib/relaton/bib/model/copyright.rb +27 -0
- data/lib/relaton/bib/model/date.rb +31 -0
- data/lib/relaton/bib/model/depiction.rb +16 -0
- data/lib/relaton/bib/model/docidentifier.rb +49 -0
- data/lib/relaton/bib/model/doctype.rb +14 -0
- data/lib/relaton/bib/model/edition.rb +14 -0
- data/lib/relaton/bib/model/ext.rb +39 -0
- data/lib/relaton/bib/model/extent.rb +16 -0
- data/lib/relaton/bib/model/formattedref.rb +43 -0
- data/lib/relaton/bib/model/full_name_type.rb +64 -0
- data/lib/relaton/bib/model/fullname.rb +11 -0
- data/lib/relaton/bib/model/ics.rb +49 -0
- data/lib/relaton/bib/model/image.rb +28 -0
- data/lib/relaton/bib/model/item.rb +96 -0
- data/lib/relaton/bib/model/item_base.rb +20 -0
- data/lib/relaton/bib/model/item_shared.rb +88 -0
- data/lib/relaton/bib/model/keyword.rb +30 -0
- data/lib/relaton/bib/model/locality.rb +18 -0
- data/lib/relaton/bib/model/locality_stack.rb +14 -0
- data/lib/relaton/bib/model/localized_string.rb +48 -0
- data/lib/relaton/bib/model/localized_string_attrs.rb +24 -0
- data/lib/relaton/bib/model/logo.rb +14 -0
- data/lib/relaton/bib/model/medium.rb +22 -0
- data/lib/relaton/bib/model/note.rb +16 -0
- data/lib/relaton/bib/model/organization.rb +13 -0
- data/lib/relaton/bib/model/organization_type.rb +42 -0
- data/lib/relaton/bib/model/person.rb +36 -0
- data/lib/relaton/bib/model/phone.rb +14 -0
- data/lib/relaton/bib/model/place.rb +33 -0
- data/lib/relaton/bib/model/price.rb +14 -0
- data/lib/relaton/bib/model/relation.rb +43 -0
- data/lib/relaton/bib/model/series.rb +34 -0
- data/lib/relaton/bib/model/size.rb +23 -0
- data/lib/relaton/bib/model/source_locality_stack.rb +14 -0
- data/lib/relaton/bib/model/status.rb +27 -0
- data/lib/relaton/bib/model/structured_identifier.rb +49 -0
- data/lib/relaton/bib/model/subdivision.rb +16 -0
- data/lib/relaton/bib/model/title.rb +56 -0
- data/lib/relaton/bib/model/type/plain_date.rb +16 -0
- data/lib/relaton/bib/model/type/string_date.rb +48 -0
- data/lib/relaton/bib/model/uri.rb +18 -0
- data/lib/relaton/bib/model/validity.rb +16 -0
- data/lib/relaton/bib/model/version.rb +43 -0
- data/lib/relaton/bib/namespace_helper.rb +21 -0
- data/lib/relaton/bib/sanitizer.rb +264 -0
- data/lib/relaton/bib/util.rb +18 -0
- data/lib/relaton/bib/versions.json +35 -0
- data/lib/relaton/bib.rb +46 -0
- data/lib/relaton/bipm/bibliography.rb +231 -0
- data/lib/relaton/bipm/converter/asciibib.rb +64 -0
- data/lib/relaton/bipm/data_fetcher.rb +81 -0
- data/lib/relaton/bipm/data_outcomes_parser.rb +656 -0
- data/lib/relaton/bipm/id_parser.rb +278 -0
- data/lib/relaton/bipm/item_data.rb +47 -0
- data/lib/relaton/bipm/model/bibdata.rb +9 -0
- data/lib/relaton/bipm/model/bibitem.rb +9 -0
- data/lib/relaton/bipm/model/comment_period.rb +13 -0
- data/lib/relaton/bipm/model/doctype.rb +12 -0
- data/lib/relaton/bipm/model/ext.rb +38 -0
- data/lib/relaton/bipm/model/item.rb +11 -0
- data/lib/relaton/bipm/model/structured_identifier.rb +36 -0
- data/lib/relaton/bipm/processor.rb +69 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/affiliations.rb +111 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/fetcher.rb +172 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/niso_jats_parser.rb +353 -0
- data/lib/relaton/bipm/si_brochure_parser.rb +188 -0
- data/lib/relaton/bipm/util.rb +8 -0
- data/lib/relaton/bipm.rb +38 -0
- data/lib/relaton/bsi/bibliography.rb +196 -0
- data/lib/relaton/bsi/hit.rb +28 -0
- data/lib/relaton/bsi/hit_collection.rb +113 -0
- data/lib/relaton/bsi/item_data.rb +13 -0
- data/lib/relaton/bsi/model/bibdata.rb +8 -0
- data/lib/relaton/bsi/model/bibitem.rb +8 -0
- data/lib/relaton/bsi/model/docidentifier.rb +107 -0
- data/lib/relaton/bsi/model/doctype.rb +14 -0
- data/lib/relaton/bsi/model/ext.rb +17 -0
- data/lib/relaton/bsi/model/item.rb +17 -0
- data/lib/relaton/bsi/model/item_base.rb +22 -0
- data/lib/relaton/bsi/model/relation.rb +9 -0
- data/lib/relaton/bsi/processor.rb +43 -0
- data/lib/relaton/bsi/schema.json +24882 -0
- data/lib/relaton/bsi/scraper.rb +288 -0
- data/lib/relaton/bsi/util.rb +8 -0
- data/lib/relaton/bsi.rb +25 -0
- data/lib/relaton/calconnect/bibliography.rb +93 -0
- data/lib/relaton/calconnect/data_fetcher.rb +174 -0
- data/lib/relaton/calconnect/docidentifier.rb +80 -0
- data/lib/relaton/calconnect/hit.rb +14 -0
- data/lib/relaton/calconnect/hit_collection.rb +92 -0
- data/lib/relaton/calconnect/item_data.rb +12 -0
- data/lib/relaton/calconnect/model/bibdata.rb +8 -0
- data/lib/relaton/calconnect/model/bibitem.rb +8 -0
- data/lib/relaton/calconnect/model/doctype.rb +11 -0
- data/lib/relaton/calconnect/model/ext.rb +11 -0
- data/lib/relaton/calconnect/model/item.rb +20 -0
- data/lib/relaton/calconnect/processor.rb +72 -0
- data/lib/relaton/calconnect/scraper.rb +87 -0
- data/lib/relaton/calconnect/util.rb +8 -0
- data/lib/relaton/calconnect.rb +36 -0
- data/lib/relaton/ccsds/bibliography.rb +63 -0
- data/lib/relaton/ccsds/data/fetcher.rb +252 -0
- data/lib/relaton/ccsds/data/iso_references.rb +30 -0
- data/lib/relaton/ccsds/data/parser.rb +194 -0
- data/lib/relaton/ccsds/hit.rb +24 -0
- data/lib/relaton/ccsds/hit_collection.rb +47 -0
- data/lib/relaton/ccsds/item_data.rb +9 -0
- data/lib/relaton/ccsds/model/bibdata.rb +8 -0
- data/lib/relaton/ccsds/model/bibitem.rb +8 -0
- data/lib/relaton/ccsds/model/docidentifier.rb +121 -0
- data/lib/relaton/ccsds/model/doctype.rb +9 -0
- data/lib/relaton/ccsds/model/ext.rb +19 -0
- data/lib/relaton/ccsds/model/item.rb +15 -0
- data/lib/relaton/ccsds/processor.rb +68 -0
- data/lib/relaton/ccsds/util.rb +10 -0
- data/lib/relaton/ccsds.rb +33 -0
- data/lib/relaton/cen/bibliography.rb +149 -0
- data/lib/relaton/cen/committees.yaml +66 -0
- data/lib/relaton/cen/hit.rb +31 -0
- data/lib/relaton/cen/hit_collection.rb +116 -0
- data/lib/relaton/cen/item_data.rb +7 -0
- data/lib/relaton/cen/model/bibdata.rb +8 -0
- data/lib/relaton/cen/model/bibitem.rb +8 -0
- data/lib/relaton/cen/model/docidentifier.rb +100 -0
- data/lib/relaton/cen/model/ext.rb +11 -0
- data/lib/relaton/cen/model/item.rb +14 -0
- data/lib/relaton/cen/model/structured_identifier.rb +9 -0
- data/lib/relaton/cen/processor.rb +45 -0
- data/lib/relaton/cen/scraper.rb +218 -0
- data/lib/relaton/cen/util.rb +8 -0
- data/lib/relaton/cen.rb +30 -0
- data/lib/relaton/cie/bibdata.rb +8 -0
- data/lib/relaton/cie/bibitem.rb +8 -0
- data/lib/relaton/cie/bibliography.rb +31 -0
- data/lib/relaton/cie/data_fetcher.rb +540 -0
- data/lib/relaton/cie/ext.rb +7 -0
- data/lib/relaton/cie/item.rb +11 -0
- data/lib/relaton/cie/item_data.rb +6 -0
- data/lib/relaton/cie/processor.rb +68 -0
- data/lib/relaton/cie/scrapper.rb +52 -0
- data/lib/relaton/cie/util.rb +8 -0
- data/lib/relaton/cie.rb +29 -0
- data/lib/relaton/core/array_wrapper.rb +20 -0
- data/lib/relaton/core/data_fetcher.rb +244 -0
- data/lib/relaton/core/date_parser.rb +42 -0
- data/lib/relaton/core/governor.rb +320 -0
- data/lib/relaton/core/hash_keys_sybolizer.rb +19 -0
- data/lib/relaton/core/hit.rb +49 -0
- data/lib/relaton/core/hit_collection.rb +118 -0
- data/lib/relaton/core/pacer.rb +134 -0
- data/lib/relaton/core/processor.rb +67 -0
- data/lib/relaton/core/request_error.rb +14 -0
- data/lib/relaton/core/workers_pool.rb +45 -0
- data/lib/relaton/core.rb +12 -0
- data/lib/relaton/db/registry.rb +44 -4
- data/lib/relaton/db.rb +0 -1
- data/lib/relaton/doi/crossref.rb +89 -0
- data/lib/relaton/doi/parser.rb +921 -0
- data/lib/relaton/doi/processor.rb +65 -0
- data/lib/relaton/doi/util.rb +8 -0
- data/lib/relaton/doi.rb +20 -0
- data/lib/relaton/easc/bibdata.rb +8 -0
- data/lib/relaton/easc/bibitem.rb +8 -0
- data/lib/relaton/easc/bibliography.rb +95 -0
- data/lib/relaton/easc/docidentifier.rb +100 -0
- data/lib/relaton/easc/doctype.rb +14 -0
- data/lib/relaton/easc/ext.rb +44 -0
- data/lib/relaton/easc/item.rb +13 -0
- data/lib/relaton/easc/item_base.rb +18 -0
- data/lib/relaton/easc/item_data.rb +6 -0
- data/lib/relaton/easc/processor.rb +46 -0
- data/lib/relaton/easc/util.rb +8 -0
- data/lib/relaton/easc.rb +35 -0
- data/lib/relaton/ecma/bibdata.rb +8 -0
- data/lib/relaton/ecma/bibitem.rb +8 -0
- data/lib/relaton/ecma/bibliography.rb +149 -0
- data/lib/relaton/ecma/data_fetcher.rb +162 -0
- data/lib/relaton/ecma/data_parser.rb +49 -0
- data/lib/relaton/ecma/docidentifier.rb +124 -0
- data/lib/relaton/ecma/edition_parser.rb +80 -0
- data/lib/relaton/ecma/ext.rb +7 -0
- data/lib/relaton/ecma/item.rb +13 -0
- data/lib/relaton/ecma/item_data.rb +6 -0
- data/lib/relaton/ecma/memento_parser.rb +60 -0
- data/lib/relaton/ecma/page_fetcher.rb +39 -0
- data/lib/relaton/ecma/parser_common.rb +33 -0
- data/lib/relaton/ecma/processor.rb +69 -0
- data/lib/relaton/ecma/standard_parser.rb +134 -0
- data/lib/relaton/ecma/util.rb +8 -0
- data/lib/relaton/ecma.rb +33 -0
- data/lib/relaton/etsi/bibdata.rb +10 -0
- data/lib/relaton/etsi/bibitem.rb +10 -0
- data/lib/relaton/etsi/bibliography.rb +111 -0
- data/lib/relaton/etsi/data_fetcher.rb +167 -0
- data/lib/relaton/etsi/data_parser.rb +208 -0
- data/lib/relaton/etsi/doctype.rb +30 -0
- data/lib/relaton/etsi/ext.rb +31 -0
- data/lib/relaton/etsi/item.rb +15 -0
- data/lib/relaton/etsi/item_data.rb +6 -0
- data/lib/relaton/etsi/processor.rb +71 -0
- data/lib/relaton/etsi/pubid.rb +37 -0
- data/lib/relaton/etsi/status.rb +13 -0
- data/lib/relaton/etsi/util.rb +8 -0
- data/lib/relaton/etsi.rb +26 -0
- data/lib/relaton/gb/bibdata.rb +8 -0
- data/lib/relaton/gb/bibitem.rb +8 -0
- data/lib/relaton/gb/bibliography.rb +171 -0
- data/lib/relaton/gb/ccs.rb +14 -0
- data/lib/relaton/gb/committee.rb +13 -0
- data/lib/relaton/gb/docidentifier.rb +72 -0
- data/lib/relaton/gb/doctype.rb +9 -0
- data/lib/relaton/gb/ext.rb +36 -0
- data/lib/relaton/gb/gb_scraper.rb +61 -0
- data/lib/relaton/gb/gb_type.rb +20 -0
- data/lib/relaton/gb/hit.rb +48 -0
- data/lib/relaton/gb/hit_collection.rb +19 -0
- data/lib/relaton/gb/item.rb +13 -0
- data/lib/relaton/gb/item_data.rb +6 -0
- data/lib/relaton/gb/processor.rb +49 -0
- data/lib/relaton/gb/project_number.rb +38 -0
- data/lib/relaton/gb/scraper.rb +221 -0
- data/lib/relaton/gb/sec_scraper.rb +92 -0
- data/lib/relaton/gb/stage_name.rb +13 -0
- data/lib/relaton/gb/structured_identifier.rb +26 -0
- data/lib/relaton/gb/t_scraper.rb +126 -0
- data/lib/relaton/gb/util.rb +8 -0
- data/lib/relaton/gb/yaml/prefixes.yaml +200 -0
- data/lib/relaton/gb.rb +33 -0
- data/lib/relaton/gost/bibdata.rb +8 -0
- data/lib/relaton/gost/bibitem.rb +8 -0
- data/lib/relaton/gost/bibliography.rb +107 -0
- data/lib/relaton/gost/docidentifier.rb +80 -0
- data/lib/relaton/gost/doctype.rb +16 -0
- data/lib/relaton/gost/ext.rb +46 -0
- data/lib/relaton/gost/item.rb +15 -0
- data/lib/relaton/gost/item_base.rb +18 -0
- data/lib/relaton/gost/item_data.rb +6 -0
- data/lib/relaton/gost/processor.rb +49 -0
- data/lib/relaton/gost/util.rb +8 -0
- data/lib/relaton/gost.rb +36 -0
- data/lib/relaton/iala/bibdata.rb +8 -0
- data/lib/relaton/iala/bibitem.rb +8 -0
- data/lib/relaton/iala/bibliography.rb +146 -0
- data/lib/relaton/iala/docidentifier.rb +89 -0
- data/lib/relaton/iala/doctype.rb +18 -0
- data/lib/relaton/iala/ext.rb +32 -0
- data/lib/relaton/iala/item.rb +21 -0
- data/lib/relaton/iala/item_base.rb +18 -0
- data/lib/relaton/iala/item_data.rb +6 -0
- data/lib/relaton/iala/processor.rb +43 -0
- data/lib/relaton/iala/relation.rb +7 -0
- data/lib/relaton/iala/util.rb +8 -0
- data/lib/relaton/iala.rb +35 -0
- data/lib/relaton/iana/bibdata.rb +8 -0
- data/lib/relaton/iana/bibitem.rb +8 -0
- data/lib/relaton/iana/bibliography.rb +100 -0
- data/lib/relaton/iana/data_fetcher.rb +101 -0
- data/lib/relaton/iana/item.rb +7 -0
- data/lib/relaton/iana/item_data.rb +6 -0
- data/lib/relaton/iana/parser.rb +146 -0
- data/lib/relaton/iana/processor.rb +70 -0
- data/lib/relaton/iana/util.rb +8 -0
- data/lib/relaton/iana.rb +40 -0
- data/lib/relaton/iec/bibliography.rb +283 -0
- data/lib/relaton/iec/data_fetcher.rb +222 -0
- data/lib/relaton/iec/data_parser.rb +391 -0
- data/lib/relaton/iec/hit.rb +26 -0
- data/lib/relaton/iec/hit_collection.rb +138 -0
- data/lib/relaton/iec/item_data.rb +7 -0
- data/lib/relaton/iec/model/bibdata.rb +8 -0
- data/lib/relaton/iec/model/bibitem.rb +8 -0
- data/lib/relaton/iec/model/docidentifier.rb +135 -0
- data/lib/relaton/iec/model/doctype.rb +12 -0
- data/lib/relaton/iec/model/ext.rb +53 -0
- data/lib/relaton/iec/model/item.rb +20 -0
- data/lib/relaton/iec/model/item_base.rb +12 -0
- data/lib/relaton/iec/model/relation.rb +7 -0
- data/lib/relaton/iec/model/stage_name.rb +13 -0
- data/lib/relaton/iec/processor.rb +74 -0
- data/lib/relaton/iec/statuses.yml +199 -0
- data/lib/relaton/iec/util.rb +8 -0
- data/lib/relaton/iec.rb +98 -0
- data/lib/relaton/ieee/balloting_group.rb +13 -0
- data/lib/relaton/ieee/bibdata.rb +8 -0
- data/lib/relaton/ieee/bibitem.rb +8 -0
- data/lib/relaton/ieee/bibliography.rb +73 -0
- data/lib/relaton/ieee/converter/bibxml/from_rfcxml.rb +10 -0
- data/lib/relaton/ieee/converter/bibxml/from_rfcxml_referencegroup.rb +10 -0
- data/lib/relaton/ieee/converter/bibxml.rb +20 -0
- data/lib/relaton/ieee/data_fetcher.rb +771 -0
- data/lib/relaton/ieee/doctype.rb +9 -0
- data/lib/relaton/ieee/editorial_group.rb +19 -0
- data/lib/relaton/ieee/ext.rb +36 -0
- data/lib/relaton/ieee/idams_parser.rb +330 -0
- data/lib/relaton/ieee/item.rb +11 -0
- data/lib/relaton/ieee/item_data.rb +7 -0
- data/lib/relaton/ieee/processor.rb +71 -0
- data/lib/relaton/ieee/rawbib_id_parser.rb +753 -0
- data/lib/relaton/ieee/util.rb +8 -0
- data/lib/relaton/ieee.rb +30 -0
- data/lib/relaton/ietf/bibdata.rb +8 -0
- data/lib/relaton/ietf/bibitem.rb +8 -0
- data/lib/relaton/ietf/bibliography.rb +35 -0
- data/lib/relaton/ietf/bibxml_parser.rb +232 -0
- data/lib/relaton/ietf/data_fetcher.rb +561 -0
- data/lib/relaton/ietf/doctype.rb +9 -0
- data/lib/relaton/ietf/ext.rb +63 -0
- data/lib/relaton/ietf/item.rb +16 -0
- data/lib/relaton/ietf/item_base.rb +18 -0
- data/lib/relaton/ietf/item_data.rb +6 -0
- data/lib/relaton/ietf/processing_instructions.rb +79 -0
- data/lib/relaton/ietf/processor.rb +72 -0
- data/lib/relaton/ietf/relation.rb +9 -0
- data/lib/relaton/ietf/rfc/abstract.rb +19 -0
- data/lib/relaton/ietf/rfc/author.rb +21 -0
- data/lib/relaton/ietf/rfc/entry.rb +446 -0
- data/lib/relaton/ietf/rfc/entry_date.rb +21 -0
- data/lib/relaton/ietf/rfc/format.rb +19 -0
- data/lib/relaton/ietf/rfc/index.rb +46 -0
- data/lib/relaton/ietf/rfc/is_also.rb +21 -0
- data/lib/relaton/ietf/rfc/keywords.rb +19 -0
- data/lib/relaton/ietf/rfc/rfc_index_namespace.rb +11 -0
- data/lib/relaton/ietf/scraper.rb +101 -0
- data/lib/relaton/ietf/util.rb +8 -0
- data/lib/relaton/ietf/wg_name_resolver.rb +42 -0
- data/lib/relaton/ietf.rb +30 -0
- data/lib/relaton/iho/bibdata.rb +8 -0
- data/lib/relaton/iho/bibitem.rb +8 -0
- data/lib/relaton/iho/bibliography.rb +114 -0
- data/lib/relaton/iho/comment_period.rb +13 -0
- data/lib/relaton/iho/docidentifier.rb +31 -0
- data/lib/relaton/iho/doctype.rb +10 -0
- data/lib/relaton/iho/ext.rb +20 -0
- data/lib/relaton/iho/hash_parser_v1.rb +144 -0
- data/lib/relaton/iho/item.rb +20 -0
- data/lib/relaton/iho/item_base.rb +18 -0
- data/lib/relaton/iho/item_data.rb +6 -0
- data/lib/relaton/iho/processor.rb +54 -0
- data/lib/relaton/iho/relation.rb +9 -0
- data/lib/relaton/iho/structured_identifier.rb +20 -0
- data/lib/relaton/iho/util.rb +8 -0
- data/lib/relaton/iho.rb +27 -0
- data/lib/relaton/index/config.rb +52 -0
- data/lib/relaton/index/file_io.rb +305 -0
- data/lib/relaton/index/file_storage.rb +66 -0
- data/lib/relaton/index/pool.rb +46 -0
- data/lib/relaton/index/shard_source.rb +201 -0
- data/lib/relaton/index/type.rb +210 -0
- data/lib/relaton/index/util.rb +18 -0
- data/lib/relaton/index.rb +61 -0
- data/lib/relaton/isbn/isbn.rb +61 -0
- data/lib/relaton/isbn/open_library.rb +43 -0
- data/lib/relaton/isbn/parser.rb +88 -0
- data/lib/relaton/isbn/processor.rb +48 -0
- data/lib/relaton/isbn/util.rb +8 -0
- data/lib/relaton/isbn.rb +19 -0
- data/lib/relaton/iso/bibliography.rb +412 -0
- data/lib/relaton/iso/data_fetcher.rb +338 -0
- data/lib/relaton/iso/data_parser.rb +458 -0
- data/lib/relaton/iso/hash_parser_v1.rb +177 -0
- data/lib/relaton/iso/hit.rb +57 -0
- data/lib/relaton/iso/hit_collection.rb +196 -0
- data/lib/relaton/iso/item_data.rb +50 -0
- data/lib/relaton/iso/model/bibdata.rb +10 -0
- data/lib/relaton/iso/model/bibitem.rb +8 -0
- data/lib/relaton/iso/model/contributor.rb +6 -0
- data/lib/relaton/iso/model/contributor_info.rb +9 -0
- data/lib/relaton/iso/model/docidentifier.rb +146 -0
- data/lib/relaton/iso/model/doctype.rb +13 -0
- data/lib/relaton/iso/model/ext.rb +35 -0
- data/lib/relaton/iso/model/item.rb +17 -0
- data/lib/relaton/iso/model/item_base.rb +22 -0
- data/lib/relaton/iso/model/organization.rb +9 -0
- data/lib/relaton/iso/model/project_number.rb +22 -0
- data/lib/relaton/iso/model/relation.rb +9 -0
- data/lib/relaton/iso/model/stagename.rb +14 -0
- data/lib/relaton/iso/model/structured_identifier.rb +31 -0
- data/lib/relaton/iso/processor.rb +85 -0
- data/lib/relaton/iso/scraper.rb +635 -0
- data/lib/relaton/iso/type/pubid.rb +50 -0
- data/lib/relaton/iso/util.rb +8 -0
- data/lib/relaton/iso.rb +30 -0
- data/lib/relaton/itu/bibliography.rb +95 -0
- data/lib/relaton/itu/data_crawler_r.rb +664 -0
- data/lib/relaton/itu/data_fetcher.rb +550 -0
- data/lib/relaton/itu/data_merge_r.rb +149 -0
- data/lib/relaton/itu/data_parser_r.rb +214 -0
- data/lib/relaton/itu/data_parser_t.rb +228 -0
- data/lib/relaton/itu/family_cache.rb +177 -0
- data/lib/relaton/itu/governor.rb +56 -0
- data/lib/relaton/itu/hit.rb +28 -0
- data/lib/relaton/itu/hit_collection.rb +299 -0
- data/lib/relaton/itu/item_data.rb +6 -0
- data/lib/relaton/itu/model/approval_stage.rb +13 -0
- data/lib/relaton/itu/model/bibdata.rb +8 -0
- data/lib/relaton/itu/model/bibitem.rb +8 -0
- data/lib/relaton/itu/model/docidentifier.rb +75 -0
- data/lib/relaton/itu/model/doctype.rb +13 -0
- data/lib/relaton/itu/model/ext.rb +47 -0
- data/lib/relaton/itu/model/item.rb +13 -0
- data/lib/relaton/itu/model/meeting.rb +13 -0
- data/lib/relaton/itu/model/meeting_date.rb +15 -0
- data/lib/relaton/itu/model/question.rb +13 -0
- data/lib/relaton/itu/model/recommendation_status.rb +11 -0
- data/lib/relaton/itu/model/structured_identifier.rb +38 -0
- data/lib/relaton/itu/processor.rb +72 -0
- data/lib/relaton/itu/pubid.rb +199 -0
- data/lib/relaton/itu/radio_regulations_parser.rb +70 -0
- data/lib/relaton/itu/recommendation_fields.rb +334 -0
- data/lib/relaton/itu/recommendation_parser.rb +30 -0
- data/lib/relaton/itu/scraper.rb +203 -0
- data/lib/relaton/itu/util.rb +8 -0
- data/lib/relaton/itu.rb +34 -0
- data/lib/relaton/jcgm/bibdata.rb +8 -0
- data/lib/relaton/jcgm/bibitem.rb +8 -0
- data/lib/relaton/jcgm/bibliography.rb +97 -0
- data/lib/relaton/jcgm/data_fetcher.rb +81 -0
- data/lib/relaton/jcgm/docidentifier.rb +102 -0
- data/lib/relaton/jcgm/doctype.rb +12 -0
- data/lib/relaton/jcgm/ext.rb +23 -0
- data/lib/relaton/jcgm/item.rb +20 -0
- data/lib/relaton/jcgm/item_base.rb +18 -0
- data/lib/relaton/jcgm/item_data.rb +6 -0
- data/lib/relaton/jcgm/meetings_parser.rb +175 -0
- data/lib/relaton/jcgm/processor.rb +71 -0
- data/lib/relaton/jcgm/relation.rb +9 -0
- data/lib/relaton/jcgm/structured_identifier.rb +40 -0
- data/lib/relaton/jcgm/util.rb +8 -0
- data/lib/relaton/jcgm.rb +24 -0
- data/lib/relaton/jis/bibdata.rb +8 -0
- data/lib/relaton/jis/bibitem.rb +8 -0
- data/lib/relaton/jis/bibliography.rb +73 -0
- data/lib/relaton/jis/data_fetcher.rb +183 -0
- data/lib/relaton/jis/docidentifier.rb +120 -0
- data/lib/relaton/jis/doctype.rb +9 -0
- data/lib/relaton/jis/ext.rb +13 -0
- data/lib/relaton/jis/hit.rb +88 -0
- data/lib/relaton/jis/hit_collection.rb +128 -0
- data/lib/relaton/jis/item.rb +22 -0
- data/lib/relaton/jis/item_base.rb +26 -0
- data/lib/relaton/jis/item_data.rb +8 -0
- data/lib/relaton/jis/processor.rb +55 -0
- data/lib/relaton/jis/relation.rb +11 -0
- data/lib/relaton/jis/scraper.rb +232 -0
- data/lib/relaton/jis/structured_identifier.rb +13 -0
- data/lib/relaton/jis/util.rb +8 -0
- data/lib/relaton/jis.rb +32 -0
- data/lib/relaton/logger/channels/gh_issue.rb +143 -0
- data/lib/relaton/logger/config.rb +34 -0
- data/lib/relaton/logger/formatter_json.rb +8 -0
- data/lib/relaton/logger/formatter_string.rb +12 -0
- data/lib/relaton/logger/log.rb +64 -0
- data/lib/relaton/logger/log_device.rb +27 -0
- data/lib/relaton/logger/pool.rb +24 -0
- data/lib/relaton/logger.rb +18 -0
- data/lib/relaton/nist/bibdata.rb +8 -0
- data/lib/relaton/nist/bibitem.rb +8 -0
- data/lib/relaton/nist/bibliography.rb +191 -0
- data/lib/relaton/nist/comment_period.rb +15 -0
- data/lib/relaton/nist/data_fetcher.rb +134 -0
- data/lib/relaton/nist/date.rb +7 -0
- data/lib/relaton/nist/docidentifier.rb +165 -0
- data/lib/relaton/nist/doctype.rb +7 -0
- data/lib/relaton/nist/ext.rb +16 -0
- data/lib/relaton/nist/hit.rb +18 -0
- data/lib/relaton/nist/hit_collection.rb +362 -0
- data/lib/relaton/nist/item.rb +19 -0
- data/lib/relaton/nist/item_base.rb +16 -0
- data/lib/relaton/nist/item_data.rb +6 -0
- data/lib/relaton/nist/mods_parser.rb +302 -0
- data/lib/relaton/nist/processor.rb +69 -0
- data/lib/relaton/nist/pubs_export.rb +69 -0
- data/lib/relaton/nist/relation.rb +10 -0
- data/lib/relaton/nist/scraper.rb +293 -0
- data/lib/relaton/nist/series.yaml +49 -0
- data/lib/relaton/nist/util.rb +8 -0
- data/lib/relaton/nist.rb +34 -0
- data/lib/relaton/oasis/bibdata.rb +8 -0
- data/lib/relaton/oasis/bibitem.rb +8 -0
- data/lib/relaton/oasis/bibliography.rb +201 -0
- data/lib/relaton/oasis/browser_agent.rb +71 -0
- data/lib/relaton/oasis/data_fetcher.rb +130 -0
- data/lib/relaton/oasis/data_parser.rb +305 -0
- data/lib/relaton/oasis/data_parser_utils.rb +330 -0
- data/lib/relaton/oasis/data_part_parser.rb +239 -0
- data/lib/relaton/oasis/docidentifier.rb +54 -0
- data/lib/relaton/oasis/doctype.rb +7 -0
- data/lib/relaton/oasis/ext.rb +19 -0
- data/lib/relaton/oasis/item.rb +14 -0
- data/lib/relaton/oasis/item_data.rb +6 -0
- data/lib/relaton/oasis/processor.rb +74 -0
- data/lib/relaton/oasis/util.rb +8 -0
- data/lib/relaton/oasis.rb +41 -0
- data/lib/relaton/ogc/bibdata.rb +8 -0
- data/lib/relaton/ogc/bibitem.rb +8 -0
- data/lib/relaton/ogc/bibliography.rb +64 -0
- data/lib/relaton/ogc/data_fetcher.rb +131 -0
- data/lib/relaton/ogc/docidentifier.rb +111 -0
- data/lib/relaton/ogc/doctype.rb +12 -0
- data/lib/relaton/ogc/ext.rb +15 -0
- data/lib/relaton/ogc/hit.rb +18 -0
- data/lib/relaton/ogc/hit_collection.rb +111 -0
- data/lib/relaton/ogc/item.rb +13 -0
- data/lib/relaton/ogc/item_data.rb +6 -0
- data/lib/relaton/ogc/processor.rb +59 -0
- data/lib/relaton/ogc/scraper.rb +225 -0
- data/lib/relaton/ogc/util.rb +8 -0
- data/lib/relaton/ogc.rb +30 -0
- data/lib/relaton/oiml/bibdata.rb +8 -0
- data/lib/relaton/oiml/bibitem.rb +8 -0
- data/lib/relaton/oiml/bibliography.rb +169 -0
- data/lib/relaton/oiml/docidentifier.rb +48 -0
- data/lib/relaton/oiml/doctype.rb +13 -0
- data/lib/relaton/oiml/ext.rb +42 -0
- data/lib/relaton/oiml/item.rb +20 -0
- data/lib/relaton/oiml/item_base.rb +18 -0
- data/lib/relaton/oiml/item_data.rb +6 -0
- data/lib/relaton/oiml/processor.rb +54 -0
- data/lib/relaton/oiml/relation.rb +9 -0
- data/lib/relaton/oiml/util.rb +8 -0
- data/lib/relaton/oiml.rb +24 -0
- data/lib/relaton/omg/bibdata.rb +8 -0
- data/lib/relaton/omg/bibitem.rb +8 -0
- data/lib/relaton/omg/bibliography.rb +31 -0
- data/lib/relaton/omg/docidentifier.rb +67 -0
- data/lib/relaton/omg/ext.rb +7 -0
- data/lib/relaton/omg/item.rb +9 -0
- data/lib/relaton/omg/item_data.rb +6 -0
- data/lib/relaton/omg/processor.rb +35 -0
- data/lib/relaton/omg/scraper.rb +186 -0
- data/lib/relaton/omg/util.rb +8 -0
- data/lib/relaton/omg.rb +25 -0
- data/lib/relaton/plateau/bibdata.rb +8 -0
- data/lib/relaton/plateau/bibitem.rb +8 -0
- data/lib/relaton/plateau/bibliography.rb +31 -0
- data/lib/relaton/plateau/data_fetcher.rb +176 -0
- data/lib/relaton/plateau/doctype.rb +7 -0
- data/lib/relaton/plateau/ext.rb +23 -0
- data/lib/relaton/plateau/handbook_parser.rb +102 -0
- data/lib/relaton/plateau/hit.rb +21 -0
- data/lib/relaton/plateau/hit_collection.rb +79 -0
- data/lib/relaton/plateau/item.rb +12 -0
- data/lib/relaton/plateau/item_data.rb +6 -0
- data/lib/relaton/plateau/parser.rb +101 -0
- data/lib/relaton/plateau/processor.rb +51 -0
- data/lib/relaton/plateau/technical_report_parser.rb +98 -0
- data/lib/relaton/plateau/util.rb +8 -0
- data/lib/relaton/plateau.rb +29 -0
- data/lib/relaton/sdo/config.rb +34 -0
- data/lib/relaton/sdo/fetcher.rb +52 -0
- data/lib/relaton/sdo/logo.rb +95 -0
- data/lib/relaton/sdo/name.rb +26 -0
- data/lib/relaton/sdo/organization.rb +71 -0
- data/lib/relaton/sdo/store.rb +49 -0
- data/lib/relaton/sdo.rb +29 -0
- data/lib/relaton/un/bibdata.rb +8 -0
- data/lib/relaton/un/bibitem.rb +8 -0
- data/lib/relaton/un/bibliography.rb +48 -0
- data/lib/relaton/un/doctype.rb +10 -0
- data/lib/relaton/un/ext.rb +30 -0
- data/lib/relaton/un/hit.rb +56 -0
- data/lib/relaton/un/hit_collection.rb +61 -0
- data/lib/relaton/un/item.rb +11 -0
- data/lib/relaton/un/item_data.rb +6 -0
- data/lib/relaton/un/parser.rb +108 -0
- data/lib/relaton/un/processor.rb +38 -0
- data/lib/relaton/un/session.rb +25 -0
- data/lib/relaton/un/token_generator.rb +105 -0
- data/lib/relaton/un/util.rb +8 -0
- data/lib/relaton/un/wasm/decoder.rb +434 -0
- data/lib/relaton/un/wasm/instance.rb +101 -0
- data/lib/relaton/un/wasm/interpreter.rb +613 -0
- data/lib/relaton/un/wasm/memory.rb +112 -0
- data/lib/relaton/un/wasm/module.rb +47 -0
- data/lib/relaton/un/wasm.rb +17 -0
- data/lib/relaton/un/wasm_v_bg.wasm +0 -0
- data/lib/relaton/un.rb +28 -0
- data/lib/relaton/version.rb +1 -1
- data/lib/relaton/w3c/bibdata.rb +8 -0
- data/lib/relaton/w3c/bibitem.rb +8 -0
- data/lib/relaton/w3c/bibliography.rb +174 -0
- data/lib/relaton/w3c/data_fetcher.rb +487 -0
- data/lib/relaton/w3c/data_parser.rb +379 -0
- data/lib/relaton/w3c/docidentifier.rb +48 -0
- data/lib/relaton/w3c/doctype.rb +7 -0
- data/lib/relaton/w3c/ext.rb +11 -0
- data/lib/relaton/w3c/governor.rb +32 -0
- data/lib/relaton/w3c/item.rb +15 -0
- data/lib/relaton/w3c/item_data.rb +6 -0
- data/lib/relaton/w3c/processor.rb +49 -0
- data/lib/relaton/w3c/pubid.rb +85 -0
- data/lib/relaton/w3c/safe_realize.rb +148 -0
- data/lib/relaton/w3c/util.rb +8 -0
- data/lib/relaton/w3c.rb +36 -0
- data/lib/relaton/xsf/bibdata.rb +8 -0
- data/lib/relaton/xsf/bibitem.rb +8 -0
- data/lib/relaton/xsf/bibliography.rb +84 -0
- data/lib/relaton/xsf/data_fetcher.rb +106 -0
- data/lib/relaton/xsf/docidentifier.rb +46 -0
- data/lib/relaton/xsf/hit.rb +17 -0
- data/lib/relaton/xsf/hit_collection.rb +52 -0
- data/lib/relaton/xsf/item.rb +13 -0
- data/lib/relaton/xsf/item_data.rb +6 -0
- data/lib/relaton/xsf/processor.rb +51 -0
- data/lib/relaton/xsf/util.rb +9 -0
- data/lib/relaton/xsf.rb +34 -0
- data/lib/relaton-core.rb +1 -0
- data/lib/relaton.rb +85 -0
- metadata +775 -161
- data/.github/workflows/rake.yml +0 -14
- data/.github/workflows/release.yml +0 -24
- data/.github/workflows/rubocop.yml +0 -48
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/CLAUDE.md +0 -78
- data/Gemfile +0 -29
- data/Rakefile +0 -6
- data/docs/CHANGELOG.adoc +0 -16
- data/docs/VERSIONING_POLICY.adoc +0 -38
- data/docs/navigation.adoc +0 -6
- data/lib/relaton/db/version.rb +0 -5
- data/relaton.gemspec +0 -72
- data/spec/relaton/config_spec.rb +0 -10
- data/spec/relaton/db_cache_spec.rb +0 -51
- data/spec/relaton/db_spec.rb +0 -567
- data/spec/relaton/registry_spec.rb +0 -178
- data/spec/relaton/util_spec.rb +0 -3
- data/spec/relaton_meta_spec.rb +0 -25
- data/spec/relaton_spec.rb +0 -800
- data/spec/spec_helper.rb +0 -45
- data/spec/support/gb_t_20223_2006.xml +0 -33
- data/spec/support/iso_111111119115_1.xml +0 -0
- data/spec/support/iso_19115_1.xml +0 -115
- data/spec/support/iso_19115_2.xml +0 -95
- data/spec/support/rfc_8341.xml +0 -46
- data/spec/vcr_cassetes/api_relaton_org.yml +0 -121
- data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +0 -140
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +0 -202
- data/spec/vcr_cassetes/cipm_meeting_43.yml +0 -1505
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +0 -729
- data/spec/vcr_cassetes/iso_111111119115_1.yml +0 -12951
- data/spec/vcr_cassetes/iso_19115_1.yml +0 -17334
- data/spec/vcr_cassetes/iso_19115_1_2.yml +0 -322
- data/spec/vcr_cassetes/iso_19115_1_std.yml +0 -17334
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +0 -185
- data/spec/vcr_cassetes/iso_19133_2005.yml +0 -144
- data/spec/vcr_cassetes/iso_combined_applied.yml +0 -318
- data/spec/vcr_cassetes/iso_combined_included.yml +0 -318
- data/spec/vcr_cassetes/ogc_19_025r1.yml +0 -374
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +0 -317
- data/spec/vcr_cassetes/rfc_8341.yml +0 -1278
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
require "net/http"
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Iala
|
|
5
|
+
module Bibliography
|
|
6
|
+
ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-iala/main/".freeze
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
# Search for an IALA publication by its identifier.
|
|
10
|
+
#
|
|
11
|
+
# @param text [String] the IALA reference to look up (e.g. "IALA S1070")
|
|
12
|
+
# @param _year [String, nil] optional edition/year filter
|
|
13
|
+
# @param _opts [Hash] options (unused)
|
|
14
|
+
# @return [Relaton::Iala::Item, nil]
|
|
15
|
+
def search(text, _year = nil, _opts = {})
|
|
16
|
+
Util.info "Fetching from Relaton repository ...", key: text
|
|
17
|
+
row = best_match text
|
|
18
|
+
unless row
|
|
19
|
+
Util.info "Not found.", key: text
|
|
20
|
+
return
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
uri = URI("#{ENDPOINT}#{row[:file]}")
|
|
24
|
+
resp = Net::HTTP.get_response uri
|
|
25
|
+
unless resp.code == "200"
|
|
26
|
+
raise Relaton::RequestError, "Could not access #{uri}: HTTP #{resp.code}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
item = Relaton::Iala::Item.from_yaml resp.body
|
|
30
|
+
Util.info "Found: `#{item.docidentifier.first&.content}`", key: text
|
|
31
|
+
item.tap { |i| i.fetched = Date.today.to_s }
|
|
32
|
+
rescue SocketError, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
|
33
|
+
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
|
34
|
+
Net::ProtocolError, Net::ReadTimeout, OpenSSL::SSL::SSLError,
|
|
35
|
+
Errno::ETIMEDOUT => e
|
|
36
|
+
raise Relaton::RequestError, "Could not access #{uri}: #{e.message}"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def get(ref, year = nil, opts = {})
|
|
40
|
+
search(ref, year, opts)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
#
|
|
46
|
+
# Find the index row for a reference, newest edition first.
|
|
47
|
+
#
|
|
48
|
+
# Passing the pubid to `Index::Type#search` is what enables the binary
|
|
49
|
+
# search on `id.root.number` — with a block alone, or with the plain
|
|
50
|
+
# string this used to pass, the whole index is scanned. Selection is
|
|
51
|
+
# `Type#search`'s default with no block — pubid's asymmetric subset
|
|
52
|
+
# match (`Pubid::SubsetMatch`): the reference on the left, the row on
|
|
53
|
+
# the right, and a component the reference omits matches any value.
|
|
54
|
+
# `edition` and `language` are IALA's only
|
|
55
|
+
# optional components, so a bare `IALA M0001` still finds the
|
|
56
|
+
# `Ed 9.0 (E)` row. The document type is deliberately NOT a wildcard —
|
|
57
|
+
# it is the identifier's class, and `===` requires the same class. 17 of
|
|
58
|
+
# the 309 index numbers are shared by two types, so `R1001` and `C1001`
|
|
59
|
+
# must never match each other. An `Annex` row carries its base
|
|
60
|
+
# identifier, which `===` compares with its own subset match.
|
|
61
|
+
#
|
|
62
|
+
# @param text [String]
|
|
63
|
+
# @return [Hash, nil]
|
|
64
|
+
#
|
|
65
|
+
# The substring-scan fallback this used to take when parsing failed is
|
|
66
|
+
# gone with the rescue. It was the same conflation the convention
|
|
67
|
+
# rejects: an unparseable string matched a SUBSTRING of the rendered
|
|
68
|
+
# ids, so an ambiguous reference silently resolved to whichever row
|
|
69
|
+
# sorted first, instead of telling the caller the reference is not an
|
|
70
|
+
# identifier. ecma, w3c and xsf never had one.
|
|
71
|
+
def best_match(text)
|
|
72
|
+
pubid = parse_ref text
|
|
73
|
+
rows = index.search(pubid)
|
|
74
|
+
rows.max_by { |r| [edition_key(r[:id].edition), language_key(r[:id]), r[:file]] }
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
#
|
|
78
|
+
# Order key for an IALA edition.
|
|
79
|
+
#
|
|
80
|
+
# Editions are dotted version strings, so they must be compared segment
|
|
81
|
+
# by segment as integers rather than as text: `"10.0"` is newer than
|
|
82
|
+
# `"9.0"` but sorts before it as a string. No published edition has a
|
|
83
|
+
# segment above 9 today, so this is a latent bug rather than a live one
|
|
84
|
+
# — the same one already fixed for ETSI. An absent edition sorts below
|
|
85
|
+
# every present one.
|
|
86
|
+
#
|
|
87
|
+
# `2` and `2.0` are distinct editions in the index and compare as
|
|
88
|
+
# `[2] < [2, 0]`; `2.02` and `2.2` reduce to the same segments. Both
|
|
89
|
+
# pairs are broken by the edition text and then the file path, so a
|
|
90
|
+
# repeated lookup returns the same document (the index sort is not
|
|
91
|
+
# stable).
|
|
92
|
+
#
|
|
93
|
+
# @param edition [String, nil]
|
|
94
|
+
# @return [Array]
|
|
95
|
+
#
|
|
96
|
+
def edition_key(edition)
|
|
97
|
+
[edition.to_s.split(".").map(&:to_i), edition.to_s]
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Prefer the language-neutral record over its translations: it is the
|
|
101
|
+
# base document, and the translations are keyed off it.
|
|
102
|
+
#
|
|
103
|
+
# @param row_id [Pubid::Iala::Identifier]
|
|
104
|
+
# @return [Integer]
|
|
105
|
+
#
|
|
106
|
+
def language_key(row_id)
|
|
107
|
+
row_id.language.nil? ? 1 : 0
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
#
|
|
111
|
+
# Parse a user reference into a `Pubid::Iala::Identifier`, or nil.
|
|
112
|
+
#
|
|
113
|
+
# `Pubid::Iala` takes the `IALA ` publisher prefix as optional and
|
|
114
|
+
# zero-pads the number to its type's canonical width, so `IALA M1`,
|
|
115
|
+
# `M0001` and `R1016:ed2.0(F)` all parse without normalization here.
|
|
116
|
+
#
|
|
117
|
+
# @param text [String]
|
|
118
|
+
# @return [Pubid::Iala::Identifier, nil]
|
|
119
|
+
#
|
|
120
|
+
# An unrecognized reference **raises**; like ISO, ETSI and 3GPP we let it
|
|
121
|
+
# propagate. relaton-cli rescues `Pubid::Errors::Error` and renders
|
|
122
|
+
# `"..." is not a recognized standards identifier`
|
|
123
|
+
# (`gems/relaton-cli/lib/relaton/cli/command.rb:324`), and `Db#fetch`
|
|
124
|
+
# logs it through the `StandardError` arm at `lib/relaton/db.rb:122`.
|
|
125
|
+
# Rescuing here would collapse "this identifier is malformed" into "no
|
|
126
|
+
# such document", leaving a caller unable to tell them apart.
|
|
127
|
+
def parse_ref(text)
|
|
128
|
+
::Pubid::Iala::Identifier.parse text.to_s.strip
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# The index is pubid-backed: `pubid_class:` is what makes
|
|
132
|
+
# Relaton::Index deserialize the rows into identifiers, sort them by
|
|
133
|
+
# `id.root.number`, and let `Type#search` bsearch. Without it the rows
|
|
134
|
+
# stay raw hashes and every lookup scans all 701 of them.
|
|
135
|
+
def index
|
|
136
|
+
Relaton::Index.find_or_create(
|
|
137
|
+
:iala,
|
|
138
|
+
url: "#{ENDPOINT}#{INDEXFILE}.zip",
|
|
139
|
+
file: "#{INDEXFILE}.yaml",
|
|
140
|
+
pubid_class: ::Pubid::Iala::Identifier,
|
|
141
|
+
)
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Iala
|
|
3
|
+
# Structured IALA document identifier. The docid string is the canonical
|
|
4
|
+
# form (e.g. "IALA S1070 Ed 2.0"). Defined as a subclass so future
|
|
5
|
+
# Pubid::Iala integration can hook in via #pubid without changing the
|
|
6
|
+
# public interface.
|
|
7
|
+
class Docidentifier < Bib::Docidentifier
|
|
8
|
+
attr_reader :pubid
|
|
9
|
+
|
|
10
|
+
# Capture the inherited (LocalizedMarkedUpString) content setter before
|
|
11
|
+
# overriding #content=, so #refresh_content! can write the re-rendered
|
|
12
|
+
# string back WITHOUT re-parsing (a re-parse would rebuild @pubid from
|
|
13
|
+
# the string, which may not even parse back — e.g. an all-parts
|
|
14
|
+
# wrapper's own "(all parts)" rendering — and discard the mutation).
|
|
15
|
+
alias_method :store_content, :content=
|
|
16
|
+
|
|
17
|
+
def initialize(attrs = {}, options = {})
|
|
18
|
+
pubid = attrs.is_a?(Hash) ? attrs.delete(:pubid) : nil
|
|
19
|
+
attrs[:content] ||= pubid.to_s if pubid
|
|
20
|
+
super
|
|
21
|
+
@pubid = pubid if pubid
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def content=(value)
|
|
25
|
+
super
|
|
26
|
+
return unless value
|
|
27
|
+
|
|
28
|
+
@pubid = begin
|
|
29
|
+
# `pubid/iala` needs pubid core (Pubid::PrefixesSupport) loaded first,
|
|
30
|
+
# so require both. Rescue LoadError so a missing pubid gem degrades to
|
|
31
|
+
# a plain string, and StandardError so non-IALA/unparseable content
|
|
32
|
+
# just leaves @pubid nil rather than raising.
|
|
33
|
+
require "pubid"
|
|
34
|
+
require "pubid/iala"
|
|
35
|
+
::Pubid::Iala.parse(value)
|
|
36
|
+
rescue LoadError, StandardError
|
|
37
|
+
nil
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# IALA's Pubid::Iala::Identifier models only publisher/number/edition/
|
|
42
|
+
# language. It has no distinct `date` component and folds any subpart
|
|
43
|
+
# inline into `number` (e.g. "0103-1"), so:
|
|
44
|
+
# * #remove_date! maps onto `edition` — IALA's version discriminator —
|
|
45
|
+
# yielding the version-agnostic ("most recent") reference.
|
|
46
|
+
# * #remove_part! clears the (currently-unused) part/subpart attributes;
|
|
47
|
+
# it is a no-op for the rendered content today, but is implemented so
|
|
48
|
+
# it never raises and starts working automatically should pubid-iala
|
|
49
|
+
# ever model `part` separately.
|
|
50
|
+
# All three no-op safely when @pubid is nil (parse failed or the pubid gem
|
|
51
|
+
# is unavailable), so Bib::ItemData#to_all_parts / #to_most_recent_reference
|
|
52
|
+
# never raise on IALA items.
|
|
53
|
+
|
|
54
|
+
def remove_part!
|
|
55
|
+
clear_attr!(:part)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def remove_date!
|
|
59
|
+
clear_attr!(:edition)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def to_all_parts!
|
|
63
|
+
return if !@pubid || @pubid.all_parts?
|
|
64
|
+
|
|
65
|
+
# `#exclude` (no args) rebuilds a full independent copy — `remove_part!`
|
|
66
|
+
# / `remove_date!` mutate `@pubid` in place, so a bare reference here
|
|
67
|
+
# would lose the original edition to that mutation too.
|
|
68
|
+
original = @pubid.exclude
|
|
69
|
+
remove_part!
|
|
70
|
+
remove_date!
|
|
71
|
+
@pubid = original.to_all_parts
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
private
|
|
75
|
+
|
|
76
|
+
def clear_attr!(attr)
|
|
77
|
+
return unless @pubid && @pubid.respond_to?("#{attr}=")
|
|
78
|
+
|
|
79
|
+
@pubid.public_send("#{attr}=", nil)
|
|
80
|
+
@pubid.subpart = nil if attr == :part && @pubid.respond_to?(:subpart=)
|
|
81
|
+
refresh_content!
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def refresh_content!
|
|
85
|
+
store_content(@pubid.to_s) if @pubid
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Iala
|
|
3
|
+
# IALA publication document types. The value is carried in the
|
|
4
|
+
# inherited `content` attribute (e.g. `standard`, `recommendation`).
|
|
5
|
+
# The list mirrors the seven categories the IALA site exposes.
|
|
6
|
+
class Doctype < Bib::Doctype
|
|
7
|
+
TYPES = %w[
|
|
8
|
+
standard
|
|
9
|
+
recommendation
|
|
10
|
+
guideline
|
|
11
|
+
manual
|
|
12
|
+
model-course
|
|
13
|
+
report
|
|
14
|
+
resolution
|
|
15
|
+
].freeze
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Iala
|
|
3
|
+
# IALA bibliographic item extension. Adds IALA-specific structured
|
|
4
|
+
# metadata on top of the shared Relaton::Bib::Ext so the fields
|
|
5
|
+
# round-trip through both XML and YAML without per-repo merge hacks.
|
|
6
|
+
# Doctype is referenced lazily via autoload from lib/relaton/iala.rb.
|
|
7
|
+
class Ext < Bib::Ext
|
|
8
|
+
attribute :doctype, Doctype
|
|
9
|
+
attribute :urn, :string
|
|
10
|
+
attribute :webpage, :string
|
|
11
|
+
attribute :committee, :string
|
|
12
|
+
attribute :normative, :string
|
|
13
|
+
attribute :supersedes, :string, collection: true, initialize_empty: true
|
|
14
|
+
|
|
15
|
+
xml do
|
|
16
|
+
map_element "urn", to: :urn
|
|
17
|
+
map_element "webpage", to: :webpage
|
|
18
|
+
map_element "committee", to: :committee
|
|
19
|
+
map_element "normative", to: :normative
|
|
20
|
+
map_element "supersedes", to: :supersedes
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
key_value do
|
|
24
|
+
map_element "urn", to: :urn
|
|
25
|
+
map_element "webpage", to: :webpage
|
|
26
|
+
map_element "committee", to: :committee
|
|
27
|
+
map_element "normative", to: :normative
|
|
28
|
+
map_element "supersedes", to: :supersedes
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Iala
|
|
3
|
+
# IALA bibliographic item. Re-declares +ext+ to use the typed Ext
|
|
4
|
+
# subclass so IALA-specific fields round-trip natively. Sub-files
|
|
5
|
+
# (ItemData, Ext, Docidentifier, Relation) are loaded lazily via the
|
|
6
|
+
# autoload entries declared in lib/relaton/iala.rb.
|
|
7
|
+
class Item < Bib::Item
|
|
8
|
+
model ItemData
|
|
9
|
+
|
|
10
|
+
attribute :ext, Ext
|
|
11
|
+
attribute :docidentifier, Docidentifier, collection: true,
|
|
12
|
+
initialize_empty: true
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Wire up the back-reference: an Item's relation collection contains
|
|
18
|
+
# Relation nodes whose bibitem is an ItemBase. Referencing
|
|
19
|
+
# Relaton::Iala::Relation triggers its autoload.
|
|
20
|
+
Relaton::Iala::Item.attribute :relation, Relaton::Iala::Relation,
|
|
21
|
+
collection: true, initialize_empty: true
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Iala
|
|
3
|
+
class ItemBase < Lutaml::Model::Serializable
|
|
4
|
+
include Bib::NamespaceHelper
|
|
5
|
+
|
|
6
|
+
attr_accessor :type
|
|
7
|
+
|
|
8
|
+
model ItemData
|
|
9
|
+
|
|
10
|
+
instance_exec(&Bib::ItemShared::ATTRIBUTES)
|
|
11
|
+
|
|
12
|
+
xml do
|
|
13
|
+
map_attribute "type", to: :type
|
|
14
|
+
instance_exec(&Bib::ItemShared::XML_BODY)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require "relaton/core/processor"
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Iala
|
|
5
|
+
class Processor < Core::Processor
|
|
6
|
+
attr_reader :idtype
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
@short = :relaton_iala
|
|
10
|
+
@prefix = "IALA"
|
|
11
|
+
@defaultprefix = %r{^IALA\s}
|
|
12
|
+
@idtype = "IALA"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get(code, date, opts)
|
|
16
|
+
require_relative "../iala"
|
|
17
|
+
Bibliography.get(code, date, opts)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def from_xml(xml)
|
|
21
|
+
require_relative "../iala"
|
|
22
|
+
Item.from_xml xml
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def from_yaml(yaml)
|
|
26
|
+
require_relative "../iala"
|
|
27
|
+
Item.from_yaml(yaml)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def grammar_hash
|
|
31
|
+
require_relative "../iala"
|
|
32
|
+
@grammar_hash ||= ::Relaton::Iala.grammar_hash
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def remove_index_file
|
|
36
|
+
require_relative "../iala"
|
|
37
|
+
Relaton::Index.find_or_create(
|
|
38
|
+
:iala, url: true, file: "#{INDEXFILE}.yaml"
|
|
39
|
+
).remove_file
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
data/lib/relaton/iala.rb
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require "pubid"
|
|
2
|
+
require "relaton/bib"
|
|
3
|
+
require "relaton/index"
|
|
4
|
+
require "relaton/version"
|
|
5
|
+
|
|
6
|
+
# Relaton::Iala is the IALA (International Organization for Marine Aids
|
|
7
|
+
# to Navigation) flavor of the unified relaton gem. Adds typed Ext fields
|
|
8
|
+
# (urn, webpage, committee, normative, supersedes) so they round-trip
|
|
9
|
+
# natively through YAML and XML without per-repo merge hacks.
|
|
10
|
+
module Relaton
|
|
11
|
+
module Iala
|
|
12
|
+
INDEXFILE = "index-v2".freeze
|
|
13
|
+
|
|
14
|
+
class Error < StandardError; end
|
|
15
|
+
|
|
16
|
+
autoload :Util, "relaton/iala/util"
|
|
17
|
+
autoload :Doctype, "relaton/iala/doctype"
|
|
18
|
+
autoload :Ext, "relaton/iala/ext"
|
|
19
|
+
autoload :ItemData, "relaton/iala/item_data"
|
|
20
|
+
autoload :ItemBase, "relaton/iala/item_base"
|
|
21
|
+
autoload :Item, "relaton/iala/item"
|
|
22
|
+
autoload :Relation, "relaton/iala/relation"
|
|
23
|
+
autoload :Bibitem, "relaton/iala/bibitem"
|
|
24
|
+
autoload :Bibdata, "relaton/iala/bibdata"
|
|
25
|
+
autoload :Docidentifier, "relaton/iala/docidentifier"
|
|
26
|
+
autoload :Bibliography, "relaton/iala/bibliography"
|
|
27
|
+
autoload :Processor, "relaton/iala/processor"
|
|
28
|
+
|
|
29
|
+
# Returns hash of XML grammar
|
|
30
|
+
# @return [String]
|
|
31
|
+
def self.grammar_hash
|
|
32
|
+
Digest::MD5.hexdigest Relaton::VERSION
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Iana
|
|
5
|
+
# Retrieval front-end for the IANA flavor. Parses the citation with
|
|
6
|
+
# Pubid::Iana, looks it up in the pubid-structured `relaton-data-iana`
|
|
7
|
+
# index-v2, and fetches the matching per-document YAML over HTTP.
|
|
8
|
+
#
|
|
9
|
+
# An IANA entry is a protocol registry, not a numbered standard: the
|
|
10
|
+
# identifier is a registry slug with at most one "/"
|
|
11
|
+
# (`IANA _6lowpan-parameters`, `IANA _6lowpan-parameters/lowpan_nhc`). The
|
|
12
|
+
# index rows key on the TOP-LEVEL slug (`Identifiers::Registry#number`), so
|
|
13
|
+
# a registry and all of its sub-registries share one bsearch bucket and the
|
|
14
|
+
# block below distinguishes them.
|
|
15
|
+
module Bibliography
|
|
16
|
+
SOURCE = "https://raw.githubusercontent.com/relaton/relaton-data-iana/refs/heads/v2/"
|
|
17
|
+
|
|
18
|
+
# @param text [String, Pubid::Iana::Identifier]
|
|
19
|
+
# @return [Relaton::Iana::Item, nil]
|
|
20
|
+
def search(text)
|
|
21
|
+
pubid = parse_ref text
|
|
22
|
+
return unless pubid
|
|
23
|
+
|
|
24
|
+
# Pass the pubid so Relaton::Index narrows candidates by number via
|
|
25
|
+
# binary search before applying the block. The match is exact, so there
|
|
26
|
+
# is at most one row.
|
|
27
|
+
row = index.search(pubid) { |r| pubid_match? r[:id], pubid }.first
|
|
28
|
+
return unless row
|
|
29
|
+
|
|
30
|
+
fetch_row row
|
|
31
|
+
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
|
|
32
|
+
EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
|
33
|
+
Net::ProtocolError, Errno::ETIMEDOUT => e
|
|
34
|
+
raise Relaton::RequestError, e.message
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @param ref [String] the IANA registry slug to look up
|
|
38
|
+
# @param year [String, NilClass] not used
|
|
39
|
+
# @param opts [Hash] options
|
|
40
|
+
# @return [Relaton::Iana::Item, nil]
|
|
41
|
+
def get(ref, _year = nil, _opts = {})
|
|
42
|
+
Util.info "Fetching from Relaton repository ...", key: ref
|
|
43
|
+
result = search(ref)
|
|
44
|
+
unless result
|
|
45
|
+
Util.info "Not found.", key: ref
|
|
46
|
+
return
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
Util.info "Found: `#{result.docidentifier[0].content}`", key: ref
|
|
50
|
+
result
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def index
|
|
56
|
+
Relaton::Index.find_or_create :iana, url: "#{SOURCE}#{INDEXFILE}.zip",
|
|
57
|
+
file: "#{INDEXFILE}.yaml",
|
|
58
|
+
pubid_class: ::Pubid::Iana::Identifier
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# `Pubid::Iana::Identifier.parse` accepts both the printed `IANA <slug>`
|
|
62
|
+
# form and the bare slug the index rows render back to. It raises a plain
|
|
63
|
+
# RuntimeError on anything else, and a citation relaton cannot parse is a
|
|
64
|
+
# miss, not an error — `#get` reports it as "Not found.".
|
|
65
|
+
#
|
|
66
|
+
# @param text [String, Pubid::Iana::Identifier]
|
|
67
|
+
# @return [Pubid::Iana::Identifier, nil]
|
|
68
|
+
def parse_ref(text)
|
|
69
|
+
return text unless text.is_a? String
|
|
70
|
+
|
|
71
|
+
::Pubid::Iana::Identifier.parse text
|
|
72
|
+
rescue StandardError => e
|
|
73
|
+
Util.warn "Failed to parse pubid `#{text}`: #{e.message}"
|
|
74
|
+
nil
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Both arguments are Pubid::Iana identifiers. Compared field by field
|
|
78
|
+
# rather than with `==` so the two identity fields are explicit: a bare
|
|
79
|
+
# registry must NOT match its own sub-registries, which share its bsearch
|
|
80
|
+
# bucket. (index-v1 matched by substring, so `IANA rpki` also hit
|
|
81
|
+
# `rpki/signed-objects` and `min_by` picked the shortest id.)
|
|
82
|
+
def pubid_match?(row_id, query)
|
|
83
|
+
row_id.class == query.class &&
|
|
84
|
+
row_id.number == query.number &&
|
|
85
|
+
row_id.sub_registry.to_s == query.sub_registry.to_s
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# @param row [Hash] an index row
|
|
89
|
+
# @return [Relaton::Iana::Item, nil]
|
|
90
|
+
def fetch_row(row)
|
|
91
|
+
resp = Net::HTTP.get_response URI("#{SOURCE}#{row[:file]}")
|
|
92
|
+
return unless resp.code == "200"
|
|
93
|
+
|
|
94
|
+
Item.from_yaml(resp.body).tap { |item| item.fetched = Date.today.to_s }
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
extend self
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
require "relaton/core"
|
|
2
|
+
require_relative "../iana"
|
|
3
|
+
require_relative "parser"
|
|
4
|
+
|
|
5
|
+
module Relaton
|
|
6
|
+
module Iana
|
|
7
|
+
class DataFetcher < Core::DataFetcher
|
|
8
|
+
#
|
|
9
|
+
# Parse documents
|
|
10
|
+
#
|
|
11
|
+
def log_error(msg)
|
|
12
|
+
Util.error msg
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def fetch(_source = nil)
|
|
16
|
+
Dir["iana-registries/**/*.xml"].each do |file|
|
|
17
|
+
content = File.read file, encoding: "UTF-8"
|
|
18
|
+
parse(content) if content.include? "<registry"
|
|
19
|
+
rescue StandardError => e
|
|
20
|
+
Util.error "Error: #{e.message}. File: #{file}"
|
|
21
|
+
end
|
|
22
|
+
index.save
|
|
23
|
+
report_errors
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def index
|
|
29
|
+
@index ||= Relaton::Index.find_or_create :iana, file: "#{INDEXFILE}.yaml",
|
|
30
|
+
pubid_class: ::Pubid::Iana::Identifier
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
#
|
|
34
|
+
# Add a document to the pubid-keyed index-v2.
|
|
35
|
+
#
|
|
36
|
+
# Stores the Pubid::Iana identifier object (not its hash): with
|
|
37
|
+
# pubid_class set, Relaton::Index sorts the index by the id's number on
|
|
38
|
+
# save and serializes each id to its `_type: pubid:iana:registry` hash.
|
|
39
|
+
#
|
|
40
|
+
# The rescue is load-bearing. Relaton::Index rejects the WHOLE index if a
|
|
41
|
+
# single row fails to deserialize, so a slug pubid cannot parse has to be
|
|
42
|
+
# skipped here rather than raise and abort the crawl.
|
|
43
|
+
#
|
|
44
|
+
# @param [String] docnumber bare registry slug, `registry[/sub-registry]`
|
|
45
|
+
# @param [String] file path of the document file
|
|
46
|
+
#
|
|
47
|
+
def add_to_index(docnumber, file)
|
|
48
|
+
index.add_or_update ::Pubid::Iana::Identifier.parse(docnumber), file
|
|
49
|
+
rescue StandardError => e
|
|
50
|
+
Util.warn "Skipping index entry for `#{docnumber}` (#{file}): #{e.message}"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def parse(content)
|
|
54
|
+
xml = Nokogiri::XML(content)
|
|
55
|
+
registry = xml.at("/xmlns:registry")
|
|
56
|
+
doc = Parser.parse registry, nil, @errors
|
|
57
|
+
save_doc doc
|
|
58
|
+
registry.xpath("./xmlns:registry").each { |r| save_doc Parser.parse(r, doc, @errors) }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#
|
|
62
|
+
# Save document to file
|
|
63
|
+
#
|
|
64
|
+
# @param [RelatonIana::IanaBibliographicItem, nil] bib bibliographic item
|
|
65
|
+
#
|
|
66
|
+
def save_doc(bib) # rubocop:disable Metrics/MethodLength
|
|
67
|
+
return unless bib
|
|
68
|
+
|
|
69
|
+
# Two distinct registries can sanitize to one filename (`/` and `-` both
|
|
70
|
+
# collapse to `-`), e.g. `rpki/signed-objects` and `rpki-signed-objects`.
|
|
71
|
+
# Take a path of our own rather than overwriting the other document, but
|
|
72
|
+
# keep the clash visible in the crawl log.
|
|
73
|
+
file = unique_output_file bib.docnumber
|
|
74
|
+
if @files.include? file
|
|
75
|
+
# A reserved path only ever belongs to one docnumber, so this is the
|
|
76
|
+
# same document again: a genuine duplicate, not a collision. Checked
|
|
77
|
+
# FIRST, because a disambiguated path stays != output_file forever.
|
|
78
|
+
Util.warn "File #{file} already exists. Document: #{bib.docnumber}"
|
|
79
|
+
elsif file != output_file(bib.docnumber)
|
|
80
|
+
Util.warn "File #{output_file bib.docnumber} already exists. " \
|
|
81
|
+
"Document: #{bib.docnumber}. Writing #{file} instead."
|
|
82
|
+
end
|
|
83
|
+
@files << file
|
|
84
|
+
add_to_index bib.docnumber, file
|
|
85
|
+
File.write file, serialize(bib), encoding: "UTF-8"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def to_xml(bib)
|
|
89
|
+
bib.to_xml(bibdata: true)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def to_yaml(bib)
|
|
93
|
+
bib.to_yaml
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def to_bibxml(bib)
|
|
97
|
+
bib.to_rfcxml
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|