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,288 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "graphql/client"
|
|
4
|
+
require "graphql/client/http"
|
|
5
|
+
|
|
6
|
+
Encoding.default_internal = Encoding::UTF_8
|
|
7
|
+
Encoding.default_external = Encoding::UTF_8
|
|
8
|
+
|
|
9
|
+
module Relaton::Bsi
|
|
10
|
+
# Scraper.
|
|
11
|
+
module Scraper
|
|
12
|
+
HTTP = GraphQL::Client::HTTP.new "https://shop-bsi.myshopify.com/api/2021-04/graphql.json" do
|
|
13
|
+
def headers(_context)
|
|
14
|
+
{ "x-shopify-storefront-access-token": "c935c196c0b7d1d86bfb5139006cfd46" }
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
Schema = GraphQL::Client.load_schema File.join(__dir__, "schema.json")
|
|
19
|
+
|
|
20
|
+
Client = GraphQL::Client.new(schema: Schema, execute: HTTP)
|
|
21
|
+
|
|
22
|
+
Product = Client.parse <<~'GRAPHQL'
|
|
23
|
+
fragment ProductFragment on Product {
|
|
24
|
+
createdAt
|
|
25
|
+
publishedAt
|
|
26
|
+
updatedAt
|
|
27
|
+
productType
|
|
28
|
+
committee: metafield(namespace: "global", key: "committee") {
|
|
29
|
+
value
|
|
30
|
+
}
|
|
31
|
+
designated: metafield(namespace: "global", key: "designatedStandard") {
|
|
32
|
+
value
|
|
33
|
+
}
|
|
34
|
+
packContents: metafield(namespace: "global", key: "packContents") {
|
|
35
|
+
value
|
|
36
|
+
}
|
|
37
|
+
summary: metafield(namespace: "global", key: "summary") {
|
|
38
|
+
value
|
|
39
|
+
}
|
|
40
|
+
corrigendumHandle: metafield(namespace: "global", key: "corrigendumHandle") {
|
|
41
|
+
value
|
|
42
|
+
}
|
|
43
|
+
variants(first: 250) {
|
|
44
|
+
edges {
|
|
45
|
+
node {
|
|
46
|
+
version: metafield(namespace: "global", key: "version") {
|
|
47
|
+
value
|
|
48
|
+
}
|
|
49
|
+
isbn: metafield(namespace: "global", key: "isbn") {
|
|
50
|
+
value
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
description
|
|
56
|
+
}
|
|
57
|
+
GRAPHQL
|
|
58
|
+
|
|
59
|
+
Query = Client.parse <<~GRAPHQL
|
|
60
|
+
query GetProducts($h0: String!) {
|
|
61
|
+
productByHandle(handle: $h0) {
|
|
62
|
+
...Relaton::Bsi::Scraper::Product::ProductFragment
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
GRAPHQL
|
|
66
|
+
|
|
67
|
+
class << self
|
|
68
|
+
# Parse page.
|
|
69
|
+
# @param hit [Relaton::Bsi::Hit]
|
|
70
|
+
# @return [Relaton::Bsi::IetemData]
|
|
71
|
+
def parse_page(hit) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
72
|
+
# doc = hit.hit_collection.agent.get hit.hit[:url]
|
|
73
|
+
result = Client.query(Query::GetProducts, variables: { h0: hit.hit[:url] })
|
|
74
|
+
data = result.data.product_by_handle.to_h
|
|
75
|
+
item = Relaton::Bsi::ItemData.new(
|
|
76
|
+
fetched: Date.today.to_s,
|
|
77
|
+
type: "standard",
|
|
78
|
+
docidentifier: fetch_docid(hit.hit[:code], data),
|
|
79
|
+
docnumber: hit.hit[:code].match(/\d+/).to_s,
|
|
80
|
+
language: ["en"],
|
|
81
|
+
script: ["Latn"],
|
|
82
|
+
title: fetch_titles(hit.hit[:title]),
|
|
83
|
+
status: fetch_status(hit.hit[:status]),
|
|
84
|
+
date: fetch_dates(hit),
|
|
85
|
+
contributor: fetch_contributors(hit, data),
|
|
86
|
+
abstract: fetch_abstract(data),
|
|
87
|
+
copyright: fetch_copyright(hit),
|
|
88
|
+
source: fetch_link(hit.hit[:url]),
|
|
89
|
+
# relation: fetch_relations(doc),
|
|
90
|
+
place: [Relaton::Bib::Place.new(city: "London")],
|
|
91
|
+
ext: fetch_ext(hit, data),
|
|
92
|
+
)
|
|
93
|
+
item.create_id
|
|
94
|
+
item
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
private
|
|
98
|
+
|
|
99
|
+
def fetch_ext(hit, data)
|
|
100
|
+
Ext.new(
|
|
101
|
+
doctype: fetch_doctype(hit),
|
|
102
|
+
flavor: "bsi",
|
|
103
|
+
ics: fetch_ics(hit.hit[:ics]),
|
|
104
|
+
structuredidentifier: fetch_structuredid(hit),
|
|
105
|
+
)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# @param ics [Array<String>]
|
|
109
|
+
# @return [Array<Relaton::Bib::ICS>]
|
|
110
|
+
def fetch_ics(ics)
|
|
111
|
+
ics.map do |s|
|
|
112
|
+
code, = s.split
|
|
113
|
+
Relaton::Bib::ICS.new(code: code, text: Isoics.fetch(code).description)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Fetch abstracts.
|
|
118
|
+
# @param data [Hash]
|
|
119
|
+
# @return [Array<Relaton::Bib::Abstract>]
|
|
120
|
+
def fetch_abstract(data)
|
|
121
|
+
return [] unless data["description"]
|
|
122
|
+
|
|
123
|
+
[Relaton::Bib::Abstract.new(content: data["description"], language: "en", script: "Latn")]
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Fetch docid.
|
|
127
|
+
# @param docid [String]
|
|
128
|
+
# @param data [Hash]
|
|
129
|
+
# @return [Array<Relaton::Bib::Docidentifier>]
|
|
130
|
+
def fetch_docid(docid, data) # rubocop:disable Metrics/AbcSize
|
|
131
|
+
ids = [{ type: "BSI", content: docid, primary: true }]
|
|
132
|
+
if data.any? && data["variants"]["edges"][0]["node"]["isbn"]
|
|
133
|
+
isbn = data["variants"]["edges"][0]["node"]["isbn"]["value"]
|
|
134
|
+
ids << { type: "ISBN", content: isbn }
|
|
135
|
+
end
|
|
136
|
+
ids.map do |did|
|
|
137
|
+
Relaton::Bsi::Docidentifier.new(**did)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# Fetch status.
|
|
142
|
+
# @param status [String]
|
|
143
|
+
# @return [Relaton::Bib::Status, nil]
|
|
144
|
+
def fetch_status(status)
|
|
145
|
+
return unless status
|
|
146
|
+
|
|
147
|
+
stage = Relaton::Bib::Status::Stage.new(content: status)
|
|
148
|
+
Relaton::Bib::Status.new(stage: stage)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# @param hit [Relaton::Bsi::Hit]
|
|
152
|
+
# @return [Relaton::Iso::StructuredIdentifier]
|
|
153
|
+
def fetch_structuredid(hit)
|
|
154
|
+
content, origyr = hit.hit[:code].split(":")
|
|
155
|
+
project_number = Relaton::Iso::ProjectNumber.new(content: content, origyr: origyr)
|
|
156
|
+
Relaton::Iso::StructuredIdentifier.new project_number: project_number
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Fetch relations.
|
|
160
|
+
# @param doc [Mechanize::Page]
|
|
161
|
+
# @return [Array<Hash>]
|
|
162
|
+
# def fetch_relations(doc)
|
|
163
|
+
# doc.xpath("//tr[th='Replaces']/td/a").map do |r|
|
|
164
|
+
# fref = RelatonBib::FormattedRef.new(content: r.text, language: "en", script: "Latn")
|
|
165
|
+
# link = fetch_link r[:href]
|
|
166
|
+
# bibitem = BsiBibliographicItem.new(formattedref: fref, type: "standard", link: link)
|
|
167
|
+
# { type: "complements", bibitem: bibitem }
|
|
168
|
+
# end
|
|
169
|
+
# end
|
|
170
|
+
|
|
171
|
+
# Fetch titles.
|
|
172
|
+
# @param title [String]
|
|
173
|
+
# @return [Array<Relaton::Bib::Title>]
|
|
174
|
+
def fetch_titles(title)
|
|
175
|
+
titles = split_title(title).map do |t|
|
|
176
|
+
Relaton::Bib::Title.new(**t, language: "en", script: "Latn")
|
|
177
|
+
end
|
|
178
|
+
titles << Relaton::Bib::Title.new(type: "main", content: title, language: "en", script: "Latn")
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def split_title(title)
|
|
182
|
+
ttls = title.split(/\s(?:-|\u2014)\s/) # if ttls.size == 1
|
|
183
|
+
case ttls.size
|
|
184
|
+
when 0, 1 then [{ type: "title-main", content: ttls.first }]
|
|
185
|
+
else intro_or_part ttls
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# @param ttls [Array<String>]
|
|
190
|
+
# @return [Array<Hash>]
|
|
191
|
+
def intro_or_part(ttls)
|
|
192
|
+
titles = [{ type: "title-intro", content: ttls[0] }, { type: "title-main", content: ttls[1] }]
|
|
193
|
+
parts = ttls.slice(2..-1)
|
|
194
|
+
titles << { type: "title-part", content: parts.join(" -- ") } if parts.any?
|
|
195
|
+
titles
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
#
|
|
199
|
+
# Fetch doctype.
|
|
200
|
+
#
|
|
201
|
+
# @param [Relaton::Bsi::Hit] hit hit
|
|
202
|
+
#
|
|
203
|
+
# @return [Relaton::Bsi::Doctype] doctype
|
|
204
|
+
#
|
|
205
|
+
def fetch_doctype(hit)
|
|
206
|
+
Doctype.new(content: doctype(hit))
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def doctype(hit)
|
|
210
|
+
case hit.hit[:code]
|
|
211
|
+
when /(^|\s)Flex\s/ then "flex-standard"
|
|
212
|
+
when /(^|\s)PAS\s/ then "publicly-available-specification"
|
|
213
|
+
else hit.hit[:doctype]
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# Fetch dates
|
|
218
|
+
# @param hit [Relaton::Bsi:Hit]
|
|
219
|
+
# @return [Array<Relaton::Bib::Date>]
|
|
220
|
+
def fetch_dates(hit)
|
|
221
|
+
[Relaton::Bib::Date.new(type: "published", at: hit.hit[:date])]
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# Fetch contributors
|
|
225
|
+
# @param hit [Relaton::Bsi::Hit]
|
|
226
|
+
# @param data [Hash]
|
|
227
|
+
# @return [Array<Relaton::Bib::Contributor>]
|
|
228
|
+
def fetch_contributors(hit, data)
|
|
229
|
+
contribs = [create_contributor({ type: "publisher" }, owner_entity(hit))]
|
|
230
|
+
|
|
231
|
+
wg = data["committee"]&.fetch("value")
|
|
232
|
+
if wg
|
|
233
|
+
subdivision = Relaton::Bib::Subdivision.new(
|
|
234
|
+
type: "technical-committee",
|
|
235
|
+
name: [Relaton::Bib::TypedLocalizedString.new(content: wg)],
|
|
236
|
+
)
|
|
237
|
+
org = bsi_org(subdivision: [subdivision])
|
|
238
|
+
desc = Relaton::Bib::LocalizedMarkedUpString.new(content: "committee")
|
|
239
|
+
role = Relaton::Bib::Contributor::Role.new(type: "author", description: [desc])
|
|
240
|
+
contribs << Relaton::Bib::Contributor.new(role: [role], organization: org)
|
|
241
|
+
end
|
|
242
|
+
contribs
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
def create_contributor(role, org)
|
|
246
|
+
role = Relaton::Bib::Contributor::Role.new(**role)
|
|
247
|
+
Relaton::Bib::Contributor.new(role: [role], organization: org)
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# Fetch links.
|
|
251
|
+
# @param path [String]
|
|
252
|
+
# @return [Array<Relaton::Bib::Uri>]
|
|
253
|
+
def fetch_link(path)
|
|
254
|
+
url = "#{HitCollection::DOMAIN}/products/#{path}"
|
|
255
|
+
[Relaton::Bib::Uri.new(type: "src", content: url)]
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# Fetch copyright.
|
|
259
|
+
# @param hit [Relaton::Bsi::Hit]
|
|
260
|
+
# @return [Array<Relaton::Bib::Copyright>]
|
|
261
|
+
def fetch_copyright(hit)
|
|
262
|
+
owner = Relaton::Bib::ContributionInfo.new organization: owner_entity(hit)
|
|
263
|
+
from = Date.parse(hit.hit[:date]).year.to_s
|
|
264
|
+
[Relaton::Bib::Copyright.new(owner: [owner], from: from)]
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
# @param hit [Relaton::Bsi::Hit]
|
|
268
|
+
# @return [Relaton::Bib::Organization]
|
|
269
|
+
def owner_entity(hit)
|
|
270
|
+
case hit.hit[:publisher]
|
|
271
|
+
when "BSI" then bsi_org
|
|
272
|
+
else
|
|
273
|
+
name = Relaton::Bib::TypedLocalizedString.new(content: hit.hit[:publisher])
|
|
274
|
+
Relaton::Bib::Organization.new(name: [name])
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def bsi_org(subdivision: [])
|
|
279
|
+
abbre = Relaton::Bib::LocalizedString.new(content: "BSI", language: "en", script: "Latn")
|
|
280
|
+
name = Relaton::Bib::TypedLocalizedString.new(
|
|
281
|
+
content: "British Standards Institution", language: "en", script: "Latn"
|
|
282
|
+
)
|
|
283
|
+
uri = Relaton::Bib::Uri.new(content: "https://www.bsigroup.com/")
|
|
284
|
+
Relaton::Bib::Organization.new abbreviation: abbre, name: [name], uri: [uri], subdivision: subdivision
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
end
|
data/lib/relaton/bsi.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require "relaton/iso"
|
|
2
|
+
require_relative "version"
|
|
3
|
+
require_relative "bsi/util"
|
|
4
|
+
require_relative "bsi/item_data"
|
|
5
|
+
require_relative "bsi/model/item"
|
|
6
|
+
require_relative "bsi/model/relation"
|
|
7
|
+
require_relative "bsi/model/bibitem"
|
|
8
|
+
require_relative "bsi/model/bibdata"
|
|
9
|
+
require_relative "bsi/scraper"
|
|
10
|
+
require_relative "bsi/hit_collection"
|
|
11
|
+
require_relative "bsi/hit"
|
|
12
|
+
require_relative "bsi/bibliography"
|
|
13
|
+
|
|
14
|
+
module Relaton
|
|
15
|
+
module Bsi
|
|
16
|
+
# Returns hash of XML greammar
|
|
17
|
+
# @return [String]
|
|
18
|
+
def self.grammar_hash
|
|
19
|
+
# gem_path = File.expand_path "..", __dir__
|
|
20
|
+
# grammars_path = File.join gem_path, "grammars", "*"
|
|
21
|
+
# grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
|
22
|
+
Digest::MD5.hexdigest Relaton::VERSION # grammars
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
require "mechanize"
|
|
2
|
+
|
|
3
|
+
module Relaton::Calconnect
|
|
4
|
+
class Bibliography
|
|
5
|
+
class << self
|
|
6
|
+
# @param text [String]
|
|
7
|
+
# @return [RelatonCalconnect::HitCollection]
|
|
8
|
+
def search(text, year = nil, _opts = {})
|
|
9
|
+
HitCollection.new text, year
|
|
10
|
+
rescue Mechanize::ResponseCodeError, SocketError, Errno::ECONNREFUSED
|
|
11
|
+
raise Relaton::RequestError, "Could not access https://standards.calconnect.org"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# @param ref [String] the OGC standard Code to look up (e..g "8200")
|
|
15
|
+
# @param year [String] the year the standard was published (optional)
|
|
16
|
+
#
|
|
17
|
+
# @param opts [Hash] options
|
|
18
|
+
# @option opts [TrueClass, FalseClass] :all_parts restricted to all parts
|
|
19
|
+
# if all-parts reference is required
|
|
20
|
+
# @option opts [TrueClass, FalseClass] :bibdata
|
|
21
|
+
#
|
|
22
|
+
# @return [RelatonCalconnect::CcBibliographicItem]
|
|
23
|
+
# The reference is no longer split by regex before searching. pubid parses
|
|
24
|
+
# `CC/DIR 10005:2019` whole, so a dated reference narrows to that row in
|
|
25
|
+
# the index itself; the `year` ARGUMENT is what still needs filtering
|
|
26
|
+
# afterwards, because an undated reference reaches every year of the
|
|
27
|
+
# document. That split is why `bib_results_filter` stays.
|
|
28
|
+
def get(ref, year = nil, opts = {})
|
|
29
|
+
Util.info "Fetching from Relaton repository ...", key: ref
|
|
30
|
+
result = search(ref, year, opts) || (return nil)
|
|
31
|
+
ret = bib_results_filter(result, year)
|
|
32
|
+
if ret[:ret]
|
|
33
|
+
Util.info "Found: `#{ret[:ret].docidentifier.first.content}`", key: ref
|
|
34
|
+
ret[:ret]
|
|
35
|
+
else
|
|
36
|
+
Util.info "Not found.", key: ref
|
|
37
|
+
fetch_ref_err(ref, year, ret[:years])
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
# Sort through the results from RelatonNist, fetching them three at a time,
|
|
44
|
+
# and return the first result that matches the code,
|
|
45
|
+
# matches the year (if provided), and which # has a title (amendments do not).
|
|
46
|
+
# Only expects the first page of results to be populated.
|
|
47
|
+
# Does not match corrigenda etc (e.g. ISO 3166-1:2006/Cor 1:2007)
|
|
48
|
+
# If no match, returns any years which caused mismatch, for error reporting
|
|
49
|
+
#
|
|
50
|
+
# @param result
|
|
51
|
+
# @param opts [Hash] options
|
|
52
|
+
#
|
|
53
|
+
# @return [Hash]
|
|
54
|
+
def bib_results_filter(result, year)
|
|
55
|
+
missed_years = Set.new
|
|
56
|
+
result.each do |r|
|
|
57
|
+
item = r.item
|
|
58
|
+
item.fetched = Date.today.to_s
|
|
59
|
+
return { ret: item } if !year
|
|
60
|
+
|
|
61
|
+
# The row id is a `Pubid::Calconnect::Identifier` now, so the year is
|
|
62
|
+
# read off the identifier rather than scraped from a rendered string.
|
|
63
|
+
# The old `/:(\d{4})$/` regex would raise TypeError against it.
|
|
64
|
+
id_year = r.hit[:id].date&.year
|
|
65
|
+
return { ret: item } if year.to_i == id_year.to_i
|
|
66
|
+
|
|
67
|
+
missed_years << id_year.to_i if id_year
|
|
68
|
+
|
|
69
|
+
item.date.select { |d| d.type == "published" }.each do |d|
|
|
70
|
+
return { ret: item } if year.to_i == d.at.to_date.year
|
|
71
|
+
|
|
72
|
+
missed_years << d.at.to_date.year
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
{ years: missed_years }
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# @param code [Strig]
|
|
79
|
+
# @param year [String]
|
|
80
|
+
# @param missed_years [Array<Strig>]
|
|
81
|
+
def fetch_ref_err(code, year, missed_years)
|
|
82
|
+
# id = year ? "`#{code}` year `#{year}`" : code
|
|
83
|
+
# Util.info "WARNING: No match found online for #{id}. " \
|
|
84
|
+
# "The code must be exactly like it is on the standards website."
|
|
85
|
+
unless missed_years.empty?
|
|
86
|
+
Util.info "There was no match for `#{year}`, though there " \
|
|
87
|
+
"were matches found for `#{missed_years.join('`, `')}`."
|
|
88
|
+
end
|
|
89
|
+
nil
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# frozen_string_literal:true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require "mechanize"
|
|
5
|
+
require "relaton/core"
|
|
6
|
+
require "relaton/index"
|
|
7
|
+
# The flavor top-level, for INDEXFILE and ::Pubid::Calconnect::Identifier.
|
|
8
|
+
# `relaton-data-calconnect`'s crawler requires THIS file and nothing else, so
|
|
9
|
+
# without it `#index` NameErrors on the very first document. (The ECMA form;
|
|
10
|
+
# the same invariant the processor's `remove_index_file` follows.)
|
|
11
|
+
require_relative "../calconnect"
|
|
12
|
+
require_relative "scraper"
|
|
13
|
+
require_relative "util"
|
|
14
|
+
|
|
15
|
+
module Relaton::Calconnect
|
|
16
|
+
#
|
|
17
|
+
# Relaton-calconnect data fetcher
|
|
18
|
+
#
|
|
19
|
+
class DataFetcher < Relaton::Core::DataFetcher
|
|
20
|
+
ENDPOINT = "https://standards.calconnect.org/cc/index.json"
|
|
21
|
+
|
|
22
|
+
def etagfile
|
|
23
|
+
@etagfile ||= File.join @output, "etag.txt"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# The pubid `index-v2` this crawl builds.
|
|
27
|
+
#
|
|
28
|
+
# `pubid_class:` is required on the producer too: `FileIO#save` calls
|
|
29
|
+
# `to_hash` only for instances of it, so without it the crawl writes
|
|
30
|
+
# v1-shaped rows under a v2 name, silently, and the consumer then rejects
|
|
31
|
+
# the whole index. Memoized with `||=` — re-creating the Type on every call
|
|
32
|
+
# evicts the pooled entry a suite (or a sibling call site) set up.
|
|
33
|
+
def index
|
|
34
|
+
@index ||= Relaton::Index.find_or_create(
|
|
35
|
+
:CC, file: "#{INDEXFILE}.yaml",
|
|
36
|
+
pubid_class: ::Pubid::Calconnect::Identifier
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def log_error(msg)
|
|
41
|
+
Util.error msg
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def agent
|
|
45
|
+
@agent ||= Mechanize.new
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
#
|
|
49
|
+
# fetch data form server and save it to file.
|
|
50
|
+
#
|
|
51
|
+
def fetch(_source = nil) # rubocop:disable Metrics/AbcSize
|
|
52
|
+
agent.request_headers["If-None-Match"] = etag if etag
|
|
53
|
+
resp = agent.get(ENDPOINT)
|
|
54
|
+
# 304 Not Modified — nothing changed since the last fetch
|
|
55
|
+
return if resp.code == "304"
|
|
56
|
+
|
|
57
|
+
data = JSON.parse resp.body
|
|
58
|
+
all_success = true
|
|
59
|
+
Array(data["documents"]).each { |doc| all_success &&= parse_page doc }
|
|
60
|
+
self.etag = resp.response["etag"] if all_success
|
|
61
|
+
index.save
|
|
62
|
+
report_errors
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
#
|
|
68
|
+
# Parse document and write it to file
|
|
69
|
+
#
|
|
70
|
+
# @param [Hash] doc
|
|
71
|
+
#
|
|
72
|
+
def parse_page(doc)
|
|
73
|
+
bib = Scraper.new(@errors).parse_page doc
|
|
74
|
+
write_doc doc["id"], bib
|
|
75
|
+
true
|
|
76
|
+
rescue StandardError => e
|
|
77
|
+
Util.warn "Document: #{doc['id']}"
|
|
78
|
+
Util.warn e.message
|
|
79
|
+
Util.warn e.backtrace[0..5].join("\n")
|
|
80
|
+
false
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def write_doc(slug, bib) # rubocop:disable Metrics/MethodLength
|
|
84
|
+
# Distinct slugs can sanitize to one filename; take a path of our own
|
|
85
|
+
# rather than overwriting the other document (Core#unique_output_file).
|
|
86
|
+
file = unique_output_file slug
|
|
87
|
+
if @files.include? file
|
|
88
|
+
# Same reserved path == same slug: a genuine duplicate. Checked FIRST,
|
|
89
|
+
# because a disambiguated path stays != output_file forever.
|
|
90
|
+
Util.warn "#{file} exist"
|
|
91
|
+
elsif file != output_file(slug)
|
|
92
|
+
Util.warn "#{output_file slug} exist; writing #{file} instead"
|
|
93
|
+
end
|
|
94
|
+
@files << file
|
|
95
|
+
# Write first, index second: an id pubid rejects is skipped from the
|
|
96
|
+
# index, and the document still has to reach disk.
|
|
97
|
+
File.write file, serialize(bib), encoding: "UTF-8"
|
|
98
|
+
add_to_index bib, file
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
#
|
|
102
|
+
# Index the document, or record why it could not be indexed.
|
|
103
|
+
#
|
|
104
|
+
# An id pubid cannot rebuild is recorded in `@errors` — the inherited
|
|
105
|
+
# `report_errors` logs a String value as the message, and its GhIssue
|
|
106
|
+
# channel opens a GitHub issue at the end of the crawl — and the row is
|
|
107
|
+
# skipped rather than indexed unparsed: `Relaton::Index` rejects the WHOLE
|
|
108
|
+
# index if a single row fails to deserialize, and its sort calls
|
|
109
|
+
# `.root.number` on every id. The data file is already written by the
|
|
110
|
+
# caller, so the document is unindexed, never lost. (The ECMA/W3C shape.)
|
|
111
|
+
#
|
|
112
|
+
# @param bib [Relaton::Calconnect::ItemData]
|
|
113
|
+
# @param file [String] path the document was written to
|
|
114
|
+
#
|
|
115
|
+
def add_to_index(bib, file)
|
|
116
|
+
id = index_id bib
|
|
117
|
+
return index.add_or_update(id, file) if id
|
|
118
|
+
|
|
119
|
+
docid = primary_docid(bib)&.content || file
|
|
120
|
+
@errors[docid.to_s] = "Unparseable primary id `#{docid}` was not indexed (#{file})"
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
#
|
|
124
|
+
# The index key: the primary docidentifier's own
|
|
125
|
+
# `Pubid::Calconnect::Identifier`.
|
|
126
|
+
#
|
|
127
|
+
# Taken from the parsed model, never re-parsed from a rendered string, and
|
|
128
|
+
# never mutated — unlike ECMA, the CalConnect index key IS the document's
|
|
129
|
+
# printed id (`CC/DIR 10005:2019`), because pubid renders the publisher by
|
|
130
|
+
# default and the flavor models no edition or volume. There is no
|
|
131
|
+
# index-only component to add and none to strip.
|
|
132
|
+
#
|
|
133
|
+
# It is still **duplicated**, for a different reason than ECMA's: the index
|
|
134
|
+
# holds the object, and `Docidentifier#remove_date!` mutates the identifier
|
|
135
|
+
# in place. Sharing it would let anything that asks a crawled record for its
|
|
136
|
+
# most-recent reference rewrite an already-indexed key, between
|
|
137
|
+
# `add_or_update` and `index.save`, with nothing to show for it.
|
|
138
|
+
#
|
|
139
|
+
# @param bib [Relaton::Calconnect::ItemData]
|
|
140
|
+
# @return [Pubid::Calconnect::Identifier, nil] nil if pubid rejects the docid
|
|
141
|
+
#
|
|
142
|
+
def index_id(bib)
|
|
143
|
+
primary_docid(bib)&.pubid&.dup
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# The docidentifier the index is keyed on — the canonical one
|
|
147
|
+
# (e.g. "CC/DIR 10005:2019"), never the upstream slug used for filenames.
|
|
148
|
+
# Every published record carries exactly one, marked primary; the fallback
|
|
149
|
+
# is for a record that marks none.
|
|
150
|
+
def primary_docid(bib)
|
|
151
|
+
bib.docidentifier.find(&:primary) || bib.docidentifier.first
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def to_yaml(bib) = bib.to_yaml
|
|
155
|
+
def to_xml(bib) = bib.to_xml(bibdata: true)
|
|
156
|
+
def to_bibxml(bib) = bib.to_rfcxml
|
|
157
|
+
|
|
158
|
+
#
|
|
159
|
+
# Read ETag from file
|
|
160
|
+
#
|
|
161
|
+
# @return [String, NilClass]
|
|
162
|
+
def etag
|
|
163
|
+
@etag ||= File.exist?(etagfile) ? File.read(etagfile, encoding: "UTF-8") : nil
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
#
|
|
167
|
+
# Save ETag to file
|
|
168
|
+
#
|
|
169
|
+
# @param tag [String]
|
|
170
|
+
def etag=(e_tag)
|
|
171
|
+
File.write etagfile, e_tag, encoding: "UTF-8"
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Calconnect
|
|
3
|
+
# A CalConnect document identifier that carries its parsed pubid alongside
|
|
4
|
+
# the source string.
|
|
5
|
+
#
|
|
6
|
+
# Every published record carries exactly one docidentifier, `type:
|
|
7
|
+
# CalConnect`, `primary: true`, in the form `CC[/<series>] <number>[:<date>]`
|
|
8
|
+
# — `CC/DIR 10005:2019`, `CC 18011:2018`, `CC/WD 51017:2024-07-23`. That is
|
|
9
|
+
# exactly what `Pubid::Calconnect::Identifier.parse` accepts, so nothing has
|
|
10
|
+
# to synthesize or strip a publisher prefix.
|
|
11
|
+
# `DataFetcher#index_id` takes `#pubid` straight from here to build the
|
|
12
|
+
# `index-v2` rows.
|
|
13
|
+
#
|
|
14
|
+
# Follows the IHO/W3C shape rather than the ISO one: `content=` calls
|
|
15
|
+
# `super` first, so `content` keeps the source string verbatim and
|
|
16
|
+
# serialization is unchanged. That matters here beyond convention —
|
|
17
|
+
# `Relaton::Calconnect::ItemData#create_id` derives the record's `id` from
|
|
18
|
+
# `content.gsub(/\W+/, "")`, so a re-render would move every published id.
|
|
19
|
+
#
|
|
20
|
+
# Unlike W3C, CalConnect ids carry a date, so `remove_date!` is real and has
|
|
21
|
+
# to re-render. It writes back through `store_content`, never `content=`: a
|
|
22
|
+
# re-parse would rebuild `@pubid` from the string and discard the mutation.
|
|
23
|
+
#
|
|
24
|
+
# There is deliberately no `render` option to opt out of. `Pubid::Calconnect`
|
|
25
|
+
# renders the publisher by default and models no edition or volume, so its
|
|
26
|
+
# default output IS the stored docid form — the index key and the document's
|
|
27
|
+
# own printed id are the same string. This is why the flavor needs no
|
|
28
|
+
# `with_*` flag dance (contrast `Relaton::Ecma::Docidentifier`, which opts
|
|
29
|
+
# out of two, and `Relaton::ThreeGpp::Docidentifier`, which opts in to one).
|
|
30
|
+
class Docidentifier < Bib::Docidentifier
|
|
31
|
+
attr_reader :pubid
|
|
32
|
+
|
|
33
|
+
# Capture the inherited (LocalizedMarkedUpString) content setter before
|
|
34
|
+
# overriding #content=, so #refresh_content! can write the re-rendered
|
|
35
|
+
# string back WITHOUT re-parsing.
|
|
36
|
+
alias_method :store_content, :content=
|
|
37
|
+
|
|
38
|
+
def content=(value)
|
|
39
|
+
super
|
|
40
|
+
@pubid = value && parse(value)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# CalConnect's one optional component, and the only real mutator here.
|
|
44
|
+
# `CC/DIR 10005:2019` -> `CC/DIR 10005`.
|
|
45
|
+
def remove_date!
|
|
46
|
+
return unless @pubid
|
|
47
|
+
|
|
48
|
+
@pubid.date = nil
|
|
49
|
+
refresh_content!
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# No-ops, and not for lack of an override. A CalConnect number is one
|
|
53
|
+
# token — `0812-1` and `0707.1` are numbers, not a number plus a part —
|
|
54
|
+
# so `Pubid::Calconnect::Identifier` models no part, and there is nothing
|
|
55
|
+
# for either of these to strip. Stated explicitly so the next reader does
|
|
56
|
+
# not "fix" them by splitting the number.
|
|
57
|
+
def remove_part!; end
|
|
58
|
+
|
|
59
|
+
def to_all_parts!; end
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
# An identifier that does not parse is a data defect, so it is reported at
|
|
64
|
+
# ERROR — never at WARN. It does not raise: an already-published record
|
|
65
|
+
# still has to deserialize and render. The crawl escalates the same
|
|
66
|
+
# failure into a tracked GitHub issue (see `DataFetcher#add_to_index` and
|
|
67
|
+
# `Core::DataFetcher#report_errors`).
|
|
68
|
+
def parse(value)
|
|
69
|
+
::Pubid::Calconnect::Identifier.parse value.to_s
|
|
70
|
+
rescue StandardError => e
|
|
71
|
+
Util.error "Failed to parse pubid `#{value}`: #{e.message}"
|
|
72
|
+
nil
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def refresh_content!
|
|
76
|
+
store_content(@pubid.to_s)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require "mechanize"
|
|
2
|
+
|
|
3
|
+
module Relaton::Calconnect
|
|
4
|
+
class Hit < Relaton::Core::Hit
|
|
5
|
+
# Parse page.
|
|
6
|
+
# @return [Relaton::Calconnect::ItemData]
|
|
7
|
+
def item
|
|
8
|
+
@item ||= begin
|
|
9
|
+
url = "#{HitCollection::GHURL}#{@hit[:file]}"
|
|
10
|
+
Item.from_yaml Mechanize.new.get(url).body
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|