relaton 2.1.0 → 3.0.0.pre.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{docs/README.adoc → README.adoc} +109 -38
- data/lib/relaton/3gpp/bibdata.rb +9 -0
- data/lib/relaton/3gpp/bibitem.rb +9 -0
- data/lib/relaton/3gpp/bibliography.rb +48 -0
- data/lib/relaton/3gpp/data_fetcher.rb +255 -0
- data/lib/relaton/3gpp/doctype.rb +9 -0
- data/lib/relaton/3gpp/ext.rb +31 -0
- data/lib/relaton/3gpp/item.rb +12 -0
- data/lib/relaton/3gpp/item_data.rb +15 -0
- data/lib/relaton/3gpp/parser.rb +400 -0
- data/lib/relaton/3gpp/processor.rb +68 -0
- data/lib/relaton/3gpp/release.rb +34 -0
- data/lib/relaton/3gpp/util.rb +8 -0
- data/lib/relaton/3gpp.rb +25 -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 +34 -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 +48 -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 +68 -0
- data/lib/relaton/bib/util.rb +18 -0
- data/lib/relaton/bib/versions.json +35 -0
- data/lib/relaton/bib.rb +48 -0
- data/lib/relaton/bipm/bibliography.rb +82 -0
- data/lib/relaton/bipm/converter/asciibib.rb +64 -0
- data/lib/relaton/bipm/data_fetcher.rb +57 -0
- data/lib/relaton/bipm/data_outcomes_parser.rb +657 -0
- data/lib/relaton/bipm/id_parser.rb +277 -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 +15 -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 +174 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/niso_jats_parser.rb +353 -0
- data/lib/relaton/bipm/si_brochure_parser.rb +186 -0
- data/lib/relaton/bipm/util.rb +8 -0
- data/lib/relaton/bipm.rb +32 -0
- data/lib/relaton/bsi/bibliography.rb +124 -0
- data/lib/relaton/bsi/hit.rb +14 -0
- data/lib/relaton/bsi/hit_collection.rb +114 -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 +9 -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 +42 -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 +95 -0
- data/lib/relaton/calconnect/data_fetcher.rb +106 -0
- data/lib/relaton/calconnect/hit.rb +14 -0
- data/lib/relaton/calconnect/hit_collection.rb +84 -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 +13 -0
- data/lib/relaton/calconnect/processor.rb +66 -0
- data/lib/relaton/calconnect/scraper.rb +87 -0
- data/lib/relaton/calconnect/util.rb +8 -0
- data/lib/relaton/calconnect.rb +26 -0
- data/lib/relaton/ccsds/bibliography.rb +63 -0
- data/lib/relaton/ccsds/data/fetcher.rb +247 -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 +42 -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/doctype.rb +9 -0
- data/lib/relaton/ccsds/model/ext.rb +19 -0
- data/lib/relaton/ccsds/model/item.rb +13 -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 +121 -0
- data/lib/relaton/cen/committees.yaml +66 -0
- data/lib/relaton/cen/hit.rb +16 -0
- data/lib/relaton/cen/hit_collection.rb +68 -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 +9 -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 +40 -0
- data/lib/relaton/cen/scraper.rb +210 -0
- data/lib/relaton/cen/util.rb +8 -0
- data/lib/relaton/cen.rb +29 -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 +355 -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 +66 -0
- data/lib/relaton/cie/scrapper.rb +39 -0
- data/lib/relaton/cie/util.rb +8 -0
- data/lib/relaton/cie.rb +28 -0
- data/lib/relaton/core/array_wrapper.rb +20 -0
- data/lib/relaton/core/data_fetcher.rb +97 -0
- data/lib/relaton/core/date_parser.rb +42 -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/processor.rb +48 -0
- data/lib/relaton/core/workers_pool.rb +45 -0
- data/lib/relaton/core.rb +9 -0
- data/lib/relaton/db/cache.rb +232 -0
- data/lib/relaton/db/config.rb +24 -0
- data/lib/relaton/db/registry.rb +119 -0
- data/lib/relaton/db/util.rb +9 -0
- data/lib/relaton/db/workers_pool.rb +22 -0
- data/lib/relaton/db.rb +20 -206
- data/lib/relaton/doi/crossref.rb +72 -0
- data/lib/relaton/doi/parser.rb +827 -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/ecma/bibdata.rb +8 -0
- data/lib/relaton/ecma/bibitem.rb +8 -0
- data/lib/relaton/ecma/bibliography.rb +81 -0
- data/lib/relaton/ecma/data_fetcher.rb +103 -0
- data/lib/relaton/ecma/data_parser.rb +49 -0
- data/lib/relaton/ecma/edition_parser.rb +80 -0
- data/lib/relaton/ecma/ext.rb +7 -0
- data/lib/relaton/ecma/item.rb +11 -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 +27 -0
- data/lib/relaton/ecma/parser_common.rb +33 -0
- data/lib/relaton/ecma/processor.rb +66 -0
- data/lib/relaton/ecma/standard_parser.rb +134 -0
- data/lib/relaton/ecma/util.rb +8 -0
- data/lib/relaton/ecma.rb +24 -0
- data/lib/relaton/etsi/bibdata.rb +10 -0
- data/lib/relaton/etsi/bibitem.rb +10 -0
- data/lib/relaton/etsi/bibliography.rb +46 -0
- data/lib/relaton/etsi/data_fetcher.rb +128 -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 +69 -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 +25 -0
- data/lib/relaton/gb/bibdata.rb +8 -0
- data/lib/relaton/gb/bibitem.rb +8 -0
- data/lib/relaton/gb/bibliography.rb +145 -0
- data/lib/relaton/gb/ccs.rb +14 -0
- data/lib/relaton/gb/committee.rb +13 -0
- data/lib/relaton/gb/docidentifier.rb +23 -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 +46 -0
- data/lib/relaton/gb/project_number.rb +38 -0
- data/lib/relaton/gb/scraper.rb +204 -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/iana/bibdata.rb +8 -0
- data/lib/relaton/iana/bibitem.rb +8 -0
- data/lib/relaton/iana/bibliography.rb +47 -0
- data/lib/relaton/iana/data_fetcher.rb +71 -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 +68 -0
- data/lib/relaton/iana/util.rb +8 -0
- data/lib/relaton/iana.rb +29 -0
- data/lib/relaton/iec/bibliography.rb +283 -0
- data/lib/relaton/iec/data_fetcher.rb +216 -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 +131 -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 +73 -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 +51 -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 +630 -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 +323 -0
- data/lib/relaton/ieee/item.rb +11 -0
- data/lib/relaton/ieee/item_data.rb +7 -0
- data/lib/relaton/ieee/processor.rb +68 -0
- data/lib/relaton/ieee/pub_id.rb +161 -0
- data/lib/relaton/ieee/rawbib_id_parser.rb +548 -0
- data/lib/relaton/ieee/util.rb +8 -0
- data/lib/relaton/ieee.rb +29 -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 +278 -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 +68 -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 +410 -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 +68 -0
- data/lib/relaton/ietf/util.rb +8 -0
- data/lib/relaton/ietf/wg_name_resolver.rb +42 -0
- data/lib/relaton/ietf.rb +27 -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 +61 -0
- data/lib/relaton/index/id_number.rb +30 -0
- data/lib/relaton/index/pool.rb +41 -0
- data/lib/relaton/index/type.rb +159 -0
- data/lib/relaton/index/util.rb +18 -0
- data/lib/relaton/index.rb +60 -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 +407 -0
- data/lib/relaton/iso/data_fetcher.rb +338 -0
- data/lib/relaton/iso/data_parser.rb +444 -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 +184 -0
- data/lib/relaton/iso/item_data.rb +28 -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 +134 -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 +84 -0
- data/lib/relaton/iso/scraper.rb +619 -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 +90 -0
- data/lib/relaton/itu/data_fetcher.rb +104 -0
- data/lib/relaton/itu/data_parser_r.rb +140 -0
- data/lib/relaton/itu/hit.rb +22 -0
- data/lib/relaton/itu/hit_collection.rb +127 -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 +9 -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 +19 -0
- data/lib/relaton/itu/processor.rb +66 -0
- data/lib/relaton/itu/pubid.rb +177 -0
- data/lib/relaton/itu/radio_regulations_parser.rb +70 -0
- data/lib/relaton/itu/recommendation_parser.rb +161 -0
- data/lib/relaton/itu/scraper.rb +193 -0
- data/lib/relaton/itu/util.rb +8 -0
- data/lib/relaton/itu.rb +33 -0
- data/lib/relaton/jis/bibdata.rb +8 -0
- data/lib/relaton/jis/bibitem.rb +8 -0
- data/lib/relaton/jis/bibliography.rb +75 -0
- data/lib/relaton/jis/data_fetcher.rb +181 -0
- data/lib/relaton/jis/docidentifier.rb +21 -0
- data/lib/relaton/jis/doctype.rb +9 -0
- data/lib/relaton/jis/ext.rb +13 -0
- data/lib/relaton/jis/hit.rb +93 -0
- data/lib/relaton/jis/hit_collection.rb +127 -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 +33 -0
- data/lib/relaton/logger/channels/gh_issue.rb +78 -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 +84 -0
- data/lib/relaton/nist/date.rb +7 -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 +17 -0
- data/lib/relaton/nist/item_data.rb +6 -0
- data/lib/relaton/nist/mods_parser.rb +276 -0
- data/lib/relaton/nist/processor.rb +68 -0
- data/lib/relaton/nist/pubs_export.rb +69 -0
- data/lib/relaton/nist/relation.rb +7 -0
- data/lib/relaton/nist/scraper.rb +290 -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 +60 -0
- data/lib/relaton/oasis/browser_agent.rb +71 -0
- data/lib/relaton/oasis/data_fetcher.rb +94 -0
- data/lib/relaton/oasis/data_parser.rb +305 -0
- data/lib/relaton/oasis/data_parser_utils.rb +296 -0
- data/lib/relaton/oasis/data_part_parser.rb +239 -0
- data/lib/relaton/oasis/doctype.rb +7 -0
- data/lib/relaton/oasis/ext.rb +19 -0
- data/lib/relaton/oasis/item.rb +11 -0
- data/lib/relaton/oasis/item_data.rb +6 -0
- data/lib/relaton/oasis/processor.rb +68 -0
- data/lib/relaton/oasis/util.rb +8 -0
- data/lib/relaton/oasis.rb +28 -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 +110 -0
- data/lib/relaton/ogc/docidentifier.rb +6 -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 +36 -0
- data/lib/relaton/ogc/item.rb +13 -0
- data/lib/relaton/ogc/item_data.rb +6 -0
- data/lib/relaton/ogc/processor.rb +58 -0
- data/lib/relaton/ogc/scraper.rb +225 -0
- data/lib/relaton/ogc/util.rb +8 -0
- data/lib/relaton/ogc.rb +26 -0
- data/lib/relaton/oiml/bibdata.rb +8 -0
- data/lib/relaton/oiml/bibitem.rb +8 -0
- data/lib/relaton/oiml/bibliography.rb +94 -0
- data/lib/relaton/oiml/docidentifier.rb +33 -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/ext.rb +7 -0
- data/lib/relaton/omg/item.rb +8 -0
- data/lib/relaton/omg/item_data.rb +6 -0
- data/lib/relaton/omg/processor.rb +34 -0
- data/lib/relaton/omg/scraper.rb +141 -0
- data/lib/relaton/omg/util.rb +8 -0
- data/lib/relaton/omg.rb +24 -0
- data/lib/relaton/plateau/bibdata.rb +8 -0
- data/lib/relaton/plateau/bibitem.rb +8 -0
- data/lib/relaton/plateau/bibliography.rb +24 -0
- data/lib/relaton/plateau/data_fetcher.rb +153 -0
- data/lib/relaton/plateau/doctype.rb +7 -0
- data/lib/relaton/plateau/ext.rb +23 -0
- data/lib/relaton/plateau/handbook_parser.rb +95 -0
- data/lib/relaton/plateau/hit.rb +13 -0
- data/lib/relaton/plateau/hit_collection.rb +59 -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 +49 -0
- data/lib/relaton/plateau/technical_report_parser.rb +91 -0
- data/lib/relaton/plateau/util.rb +8 -0
- data/lib/relaton/plateau.rb +28 -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 +54 -0
- data/lib/relaton/w3c/data_fetcher.rb +309 -0
- data/lib/relaton/w3c/data_parser.rb +379 -0
- data/lib/relaton/w3c/doctype.rb +7 -0
- data/lib/relaton/w3c/ext.rb +11 -0
- data/lib/relaton/w3c/item.rb +12 -0
- data/lib/relaton/w3c/item_data.rb +6 -0
- data/lib/relaton/w3c/processor.rb +49 -0
- data/lib/relaton/w3c/pubid.rb +73 -0
- data/lib/relaton/w3c/safe_realize.rb +59 -0
- data/lib/relaton/w3c/util.rb +8 -0
- data/lib/relaton/w3c.rb +25 -0
- data/lib/relaton/xsf/bibdata.rb +8 -0
- data/lib/relaton/xsf/bibitem.rb +8 -0
- data/lib/relaton/xsf/bibliography.rb +24 -0
- data/lib/relaton/xsf/data_fetcher.rb +56 -0
- data/lib/relaton/xsf/hit.rb +17 -0
- data/lib/relaton/xsf/hit_collection.rb +24 -0
- data/lib/relaton/xsf/item.rb +7 -0
- data/lib/relaton/xsf/item_data.rb +6 -0
- data/lib/relaton/xsf/processor.rb +50 -0
- data/lib/relaton/xsf/util.rb +9 -0
- data/lib/relaton/xsf.rb +30 -0
- data/lib/relaton-core.rb +1 -0
- data/lib/relaton.rb +44 -9
- metadata +708 -150
- 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/.rubocop.yml +0 -12
- data/CLAUDE.md +0 -70
- data/Gemfile +0 -21
- 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/config.rb +0 -24
- data/lib/relaton/db_cache.rb +0 -230
- data/lib/relaton/registry.rb +0 -118
- data/lib/relaton/util.rb +0 -7
- data/lib/relaton/workers_pool.rb +0 -21
- data/relaton.gemspec +0 -61
- data/spec/relaton/config_spec.rb +0 -10
- data/spec/relaton/db_cache_spec.rb +0 -51
- data/spec/relaton/db_spec.rb +0 -556
- data/spec/relaton/registry_spec.rb +0 -178
- data/spec/relaton/util_spec.rb +0 -3
- data/spec/relaton_spec.rb +0 -725
- 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/3gpp_tr_00_01u_umts_3_0_0.yml +0 -12720
- data/spec/vcr_cassetes/api_relaton_org.yml +0 -121
- data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +0 -143
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +0 -199
- data/spec/vcr_cassetes/cie_001_1980.yml +0 -401
- data/spec/vcr_cassetes/cipm_meeting_43.yml +0 -1513
- data/spec/vcr_cassetes/doi_10_6028_nist_ir_8245.yml +0 -86
- data/spec/vcr_cassetes/ecma_6.yml +0 -112
- data/spec/vcr_cassetes/en_10160_1999.yml +0 -13624
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +0 -733
- data/spec/vcr_cassetes/ieee_528_2019.yml +0 -2786
- data/spec/vcr_cassetes/iso_111111119115_1.yml +0 -12951
- data/spec/vcr_cassetes/iso_19115_1.yml +0 -13177
- data/spec/vcr_cassetes/iso_19115_1_2.yml +0 -369
- data/spec/vcr_cassetes/iso_19115_1_std.yml +0 -13177
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +0 -229
- data/spec/vcr_cassetes/iso_19133_2005.yml +0 -148
- data/spec/vcr_cassetes/iso_combined_applied.yml +0 -364
- data/spec/vcr_cassetes/iso_combined_included.yml +0 -364
- data/spec/vcr_cassetes/iso_dis.yml +0 -157
- data/spec/vcr_cassetes/ogc_19_025r1.yml +0 -371
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +0 -317
- data/spec/vcr_cassetes/rfc_8341.yml +0 -1272
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
require "relaton/core"
|
|
2
|
+
require_relative "../iec"
|
|
3
|
+
require_relative "data_parser"
|
|
4
|
+
|
|
5
|
+
module Relaton
|
|
6
|
+
module Iec
|
|
7
|
+
class DataFetcher < Relaton::Core::DataFetcher
|
|
8
|
+
ENTRYPOINT = "https://api.iec.ch/harmonized/publications?size=100&sortBy=urn&page=".freeze
|
|
9
|
+
CREDENTIAL = "https://api.iec.ch/oauth/client_credential/accesstoken?grant_type=client_credentials".freeze
|
|
10
|
+
LAST_CHANGE_FILE = "last_change.txt".freeze
|
|
11
|
+
|
|
12
|
+
#
|
|
13
|
+
# Fetch data from IEC.
|
|
14
|
+
#
|
|
15
|
+
def log_error(msg)
|
|
16
|
+
Util.error msg
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def fetch(source = "iec-harmonised-latest") # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
20
|
+
@all = source == "iec-harmonised-all"
|
|
21
|
+
|
|
22
|
+
if @all
|
|
23
|
+
FileUtils.rm_rf @output
|
|
24
|
+
end
|
|
25
|
+
FileUtils.mkdir_p @output
|
|
26
|
+
rebuild_index
|
|
27
|
+
fetch_all
|
|
28
|
+
index.save
|
|
29
|
+
save_last_change
|
|
30
|
+
report_errors
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def last_change
|
|
36
|
+
return @last_change if defined? @last_change
|
|
37
|
+
|
|
38
|
+
@last_change = File.read(LAST_CHANGE_FILE, encoding: "UTF-8") if File.exist? LAST_CHANGE_FILE
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def last_change_max
|
|
42
|
+
@last_change_max ||= last_change.to_s
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# def last_change_max(date)
|
|
46
|
+
# @last_change_max = date if last_change_max < date
|
|
47
|
+
# end
|
|
48
|
+
|
|
49
|
+
def save_last_change
|
|
50
|
+
return if last_change_max.empty?
|
|
51
|
+
|
|
52
|
+
File.write LAST_CHANGE_FILE, last_change_max, encoding: "UTF-8"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def index
|
|
56
|
+
@index ||= Relaton::Index.find_or_create(
|
|
57
|
+
:iec, file: "#{INDEXFILE}.yaml", pubid_class: ::Pubid::Iec::Identifier
|
|
58
|
+
)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#
|
|
62
|
+
# Rebuild index from existing YAML files.
|
|
63
|
+
#
|
|
64
|
+
# @return [void]
|
|
65
|
+
#
|
|
66
|
+
def rebuild_index
|
|
67
|
+
Dir.glob(File.join(@output, "*.yaml")).each do |file|
|
|
68
|
+
add_file_to_index(file)
|
|
69
|
+
end
|
|
70
|
+
add_static_files_to_index if Dir.exist?("static")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
#
|
|
74
|
+
# Add a YAML file to the index.
|
|
75
|
+
#
|
|
76
|
+
# @param [String] file path to the YAML file
|
|
77
|
+
#
|
|
78
|
+
# @return [void]
|
|
79
|
+
#
|
|
80
|
+
def add_file_to_index(file)
|
|
81
|
+
item = Item.from_yaml(File.read(file, encoding: "UTF-8"))
|
|
82
|
+
did = find_primary_docidentifier item
|
|
83
|
+
return unless did
|
|
84
|
+
|
|
85
|
+
pubid = parse_pubid(did.to_s)
|
|
86
|
+
index.add_or_update pubid, file if pubid
|
|
87
|
+
rescue StandardError => e
|
|
88
|
+
Util.warn "Failed to index file `#{file}`: #{e.message}"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def find_primary_docidentifier(item)
|
|
92
|
+
item.docidentifier.detect(&:primary) ||
|
|
93
|
+
item.docidentifier.detect { |id| id.type == "IEC" } ||
|
|
94
|
+
item.docidentifier.first
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
#
|
|
98
|
+
# Add static files to index.
|
|
99
|
+
#
|
|
100
|
+
# @return [void]
|
|
101
|
+
#
|
|
102
|
+
def add_static_files_to_index
|
|
103
|
+
Dir.glob("static/*.yaml").each do |file|
|
|
104
|
+
add_file_to_index(file)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
#
|
|
109
|
+
# Fetch documents from IEC API.
|
|
110
|
+
#
|
|
111
|
+
# @return [void]
|
|
112
|
+
#
|
|
113
|
+
def fetch_all # rubocop:disable Metrics/MethodLength
|
|
114
|
+
page = 0
|
|
115
|
+
next_page = true
|
|
116
|
+
while next_page
|
|
117
|
+
res = fetch_page_token page
|
|
118
|
+
unless res.code == "200"
|
|
119
|
+
Util.warn "#{res.body}"
|
|
120
|
+
break
|
|
121
|
+
end
|
|
122
|
+
json = JSON.parse res.body
|
|
123
|
+
json["publication"].each { |pub| fetch_pub pub }
|
|
124
|
+
page += 1
|
|
125
|
+
next_page = res["link"]&.include? "rel=\"last\""
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
#
|
|
130
|
+
# Fetch page. If response code is 401, then get new access token and try
|
|
131
|
+
#
|
|
132
|
+
# @param [Integer] page page number
|
|
133
|
+
#
|
|
134
|
+
# @return [Net::HTTP::Response] response
|
|
135
|
+
#
|
|
136
|
+
def fetch_page_token(page)
|
|
137
|
+
res = fetch_page page
|
|
138
|
+
if res.code == "401"
|
|
139
|
+
@access_token = nil
|
|
140
|
+
res = fetch_page page
|
|
141
|
+
end
|
|
142
|
+
res
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
#
|
|
146
|
+
# Fetch page from IEC API.
|
|
147
|
+
#
|
|
148
|
+
# @param [Integer] page page number
|
|
149
|
+
#
|
|
150
|
+
# @return [Net::HTTP::Response] response
|
|
151
|
+
#
|
|
152
|
+
def fetch_page(page)
|
|
153
|
+
url = "#{ENTRYPOINT}#{page}"
|
|
154
|
+
if !@all && last_change
|
|
155
|
+
url += "&lastChangeTimestampFrom=#{last_change}"
|
|
156
|
+
end
|
|
157
|
+
uri = URI url
|
|
158
|
+
req = Net::HTTP::Get.new uri
|
|
159
|
+
req["Authorization"] = "Bearer #{access_token}"
|
|
160
|
+
Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
|
161
|
+
http.request req
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
#
|
|
166
|
+
# Get access token.
|
|
167
|
+
#
|
|
168
|
+
# @return [String] access token
|
|
169
|
+
#
|
|
170
|
+
def access_token # rubocop:disable Metrics/AbcSize
|
|
171
|
+
@access_token ||= begin
|
|
172
|
+
uri = URI CREDENTIAL
|
|
173
|
+
req = Net::HTTP::Get.new uri
|
|
174
|
+
req.basic_auth ENV.fetch("IEC_HAPI_PROJ_PUBS_KEY"), ENV.fetch("IEC_HAPI_PROJ_PUBS_SECRET")
|
|
175
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
|
176
|
+
http.request req
|
|
177
|
+
end
|
|
178
|
+
JSON.parse(res.body)["access_token"]
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
#
|
|
183
|
+
# Fetch publication and save it to file.
|
|
184
|
+
#
|
|
185
|
+
# @param [Hash] pub publication
|
|
186
|
+
#
|
|
187
|
+
def fetch_pub(pub) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
188
|
+
bib = DataParser.new(pub, @errors).parse
|
|
189
|
+
did = bib.docidentifier.detect(&:primary)
|
|
190
|
+
file = output_file(did.to_s)
|
|
191
|
+
if @files.include? file then Util.warn "File #{file} exists."
|
|
192
|
+
else
|
|
193
|
+
@files << file
|
|
194
|
+
pubid = parse_pubid(did.to_s)
|
|
195
|
+
index.add_or_update pubid, file if pubid
|
|
196
|
+
end
|
|
197
|
+
ts = pub["lastChangeTimestamp"]
|
|
198
|
+
@last_change_max = ts if ts && last_change_max < ts
|
|
199
|
+
File.write file, serialize(bib), encoding: "UTF-8"
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def parse_pubid(content)
|
|
203
|
+
::Pubid::Iec::Identifier.parse(content)
|
|
204
|
+
rescue StandardError => e
|
|
205
|
+
Util.warn "Failed to parse pubid `#{content}`: #{e.message}"
|
|
206
|
+
nil
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def to_xml(bib) = bib.to_xml bibdata: true
|
|
210
|
+
|
|
211
|
+
def to_yaml(bib) = bib.to_yaml
|
|
212
|
+
|
|
213
|
+
def to_bibxml(bib) = bib.to_rfcxml
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
end
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Iec
|
|
3
|
+
class DataParser
|
|
4
|
+
include Core::ArrayWrapper
|
|
5
|
+
|
|
6
|
+
DOMAIN = "https://webstore.iec.ch"
|
|
7
|
+
|
|
8
|
+
ATTRS = %i[
|
|
9
|
+
type docidentifier language script title date contributor
|
|
10
|
+
status edition abstract copyright source relation place ext
|
|
11
|
+
].freeze
|
|
12
|
+
|
|
13
|
+
ABBREVS = {
|
|
14
|
+
"ISO" => ["International Organization for Standardization", "www.iso.org"],
|
|
15
|
+
"IEC" => ["International Electrotechnical Commission", "www.iec.ch"],
|
|
16
|
+
"IEEE" => ["Institute of Electrical and Electronics Engineers", "www.ieee.org"],
|
|
17
|
+
"ASTM" => ["American Society of Testing Materials", "www.astm.org"],
|
|
18
|
+
"CISPR" => ["International special committee on radio interference", "www.iec.ch"],
|
|
19
|
+
}.freeze
|
|
20
|
+
|
|
21
|
+
DOCTYPES = {
|
|
22
|
+
"IS" => "international-standard",
|
|
23
|
+
"TR" => "technical-report",
|
|
24
|
+
"TS" => "technical-specification",
|
|
25
|
+
"PAS" => "publicly-available-specification",
|
|
26
|
+
"SRD" => "system-reference-deliverable",
|
|
27
|
+
}.freeze
|
|
28
|
+
|
|
29
|
+
#
|
|
30
|
+
# Initialize new instance.
|
|
31
|
+
#
|
|
32
|
+
# @param [Hash] pub document data
|
|
33
|
+
#
|
|
34
|
+
def initialize(pub, errors = {})
|
|
35
|
+
@pub = pub
|
|
36
|
+
@errors = errors
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
#
|
|
40
|
+
# Parse document.
|
|
41
|
+
#
|
|
42
|
+
# @return [RelatonIec::IecBibliographicItem] bib item
|
|
43
|
+
#
|
|
44
|
+
def parse
|
|
45
|
+
args = ATTRS.each_with_object({}) { |a, h| h[a] = send a }
|
|
46
|
+
ItemData.new(**args)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def type = "standard"
|
|
52
|
+
|
|
53
|
+
#
|
|
54
|
+
# Parse document identifiers.
|
|
55
|
+
#
|
|
56
|
+
# @return [Array<Relaton::Bib::Docidentifier>] document identifiers
|
|
57
|
+
#
|
|
58
|
+
def docidentifier
|
|
59
|
+
result = [iec_docid, urn_docid].compact
|
|
60
|
+
@errors[:docidentifier] &&= result.empty?
|
|
61
|
+
result
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def iec_docid
|
|
65
|
+
pubid = ::Pubid::Iec::Identifier.parse(@pub["reference"])
|
|
66
|
+
Docidentifier.new(content: pubid, type: "IEC", primary: true)
|
|
67
|
+
rescue StandardError => e
|
|
68
|
+
Util.warn "Failed to parse IEC identifier `#{@pub['reference']}`: #{e.message}"
|
|
69
|
+
Docidentifier.new(content: @pub["reference"], type: "IEC", primary: true)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def urn_docid
|
|
73
|
+
pubid = parse_urn_pubid
|
|
74
|
+
return unless pubid
|
|
75
|
+
|
|
76
|
+
Docidentifier.new(content: pubid, type: "URN")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def parse_urn_pubid
|
|
80
|
+
if @pub["urnAlt"]&.first
|
|
81
|
+
urnid = "urn:#{@pub['urnAlt'][0]}"
|
|
82
|
+
begin
|
|
83
|
+
return ::Pubid::Iec::Identifier.parse(urnid)
|
|
84
|
+
rescue StandardError => e
|
|
85
|
+
Util.warn "Failed to parse URN `#{urnid}`: #{e.message}"
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
::Pubid::Iec::Identifier.parse(@pub["reference"])
|
|
89
|
+
rescue StandardError
|
|
90
|
+
nil
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
#
|
|
94
|
+
# Parse languages.
|
|
95
|
+
#
|
|
96
|
+
# @return [Array<String>] languages
|
|
97
|
+
#
|
|
98
|
+
def language
|
|
99
|
+
result = @pub["title"].map { |t| t["lang"] }.uniq
|
|
100
|
+
@errors[:language] &&= result.empty?
|
|
101
|
+
result
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
#
|
|
105
|
+
# Parse scripts.
|
|
106
|
+
#
|
|
107
|
+
# @return [Array<String>] scripts
|
|
108
|
+
#
|
|
109
|
+
def script
|
|
110
|
+
result = language.each_with_object([]) do |l, s|
|
|
111
|
+
scr = lang_to_script l
|
|
112
|
+
s << scr if scr && !s.include?(scr)
|
|
113
|
+
end
|
|
114
|
+
@errors[:script] &&= result.empty?
|
|
115
|
+
result
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
#
|
|
119
|
+
# Detect script.
|
|
120
|
+
#
|
|
121
|
+
# @param [String] lang language
|
|
122
|
+
#
|
|
123
|
+
# @return [String] script
|
|
124
|
+
#
|
|
125
|
+
def lang_to_script(lang)
|
|
126
|
+
case lang
|
|
127
|
+
when "en", "fr", "es" then "Latn"
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
#
|
|
132
|
+
# Parse titles.
|
|
133
|
+
#
|
|
134
|
+
# @return [Array<Relaton::Bib::Title>] titles
|
|
135
|
+
#
|
|
136
|
+
def title
|
|
137
|
+
result = @pub["title"].reduce([]) do |acc, t|
|
|
138
|
+
acc + Bib::Title.from_string(t["value"], t["lang"], lang_to_script(t["lang"]))
|
|
139
|
+
end
|
|
140
|
+
@errors[:title] &&= result.empty?
|
|
141
|
+
result
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def status
|
|
145
|
+
result = begin
|
|
146
|
+
stage = Bib::Status::Stage.new content: @pub["status"]
|
|
147
|
+
Bib::Status.new stage: stage
|
|
148
|
+
end
|
|
149
|
+
@errors[:status] &&= result.nil?
|
|
150
|
+
result
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def edition
|
|
154
|
+
result = Bib::Edition.new content: @pub["edition"]
|
|
155
|
+
@errors[:edition] &&= result.nil?
|
|
156
|
+
result
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
#
|
|
160
|
+
# Parse abstract.
|
|
161
|
+
#
|
|
162
|
+
# @return [Array<Relaton::Bib::LocalizedMarkedUpString>] abstract
|
|
163
|
+
#
|
|
164
|
+
def abstract
|
|
165
|
+
result = Array(@pub["abstract"]).map do |a|
|
|
166
|
+
Bib::Abstract.new(
|
|
167
|
+
content: a["content"], language: a["lang"], script: lang_to_script(a["lang"]),
|
|
168
|
+
)
|
|
169
|
+
end
|
|
170
|
+
@errors[:abstract] &&= result.empty?
|
|
171
|
+
result
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# @return [Array<Relaton::Bib::Copyright>] copyright
|
|
175
|
+
def copyright # rubocop:disable Metrics/AbcSize
|
|
176
|
+
from = @pub["reference"].match(/(?<=:)\d{4}/).to_s
|
|
177
|
+
from = @pub["releaseDate"]&.match(/\d{4}/).to_s if from.empty?
|
|
178
|
+
return [] if from.nil? || from.empty?
|
|
179
|
+
|
|
180
|
+
abbreviation = @pub["reference"].match(/.*?(?=\s)/).to_s
|
|
181
|
+
owner = abbreviation.split("/").map do |abbrev|
|
|
182
|
+
name, url = ABBREVS[abbrev]
|
|
183
|
+
orgname = Bib::TypedLocalizedString.new(content: name, language: "en", script: "Latn")
|
|
184
|
+
abbrev = Bib::LocalizedString.new(content: abbrev, language: "en", script: "Latn")
|
|
185
|
+
uri = Bib::Uri.new(content: url, type: "org")
|
|
186
|
+
org = Bib::Organization.new(name: [orgname], abbreviation: abbrev, uri: [uri])
|
|
187
|
+
Bib::ContributionInfo.new(organization: org)
|
|
188
|
+
end
|
|
189
|
+
result = [Bib::Copyright.new(owner: owner, from: from)]
|
|
190
|
+
@errors[:copyright] &&= result.empty?
|
|
191
|
+
result
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
#
|
|
195
|
+
# Parse dates.
|
|
196
|
+
#
|
|
197
|
+
# @return [Array<Relaton::Bib::Date>] dates
|
|
198
|
+
#
|
|
199
|
+
def date
|
|
200
|
+
result = {
|
|
201
|
+
"published" => "publicationDate",
|
|
202
|
+
"stable-until" => "stabilityDate",
|
|
203
|
+
"confirmed" => "confirmationDate",
|
|
204
|
+
"obsoleted" => "dateOfWithdrawal",
|
|
205
|
+
}.reduce([]) do |a, (k, v)|
|
|
206
|
+
next a unless @pub[v]
|
|
207
|
+
|
|
208
|
+
a << Bib::Date.new(type: k, at: @pub[v])
|
|
209
|
+
end
|
|
210
|
+
@errors[:date] &&= result.empty?
|
|
211
|
+
result
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
#
|
|
215
|
+
# Parse contributors.
|
|
216
|
+
#
|
|
217
|
+
# @return [Array<Bib::Contributor>] contributors
|
|
218
|
+
#
|
|
219
|
+
def contributor
|
|
220
|
+
contribs = @pub["reference"].sub(/\s.*/, "").split("/").map do |abbrev|
|
|
221
|
+
name, url = ABBREVS[abbrev]
|
|
222
|
+
orgname = Bib::TypedLocalizedString.new(content: name, language: "en", script: "Latn")
|
|
223
|
+
abbr = Bib::LocalizedString.new(content: abbrev, language: "en", script: "Latn")
|
|
224
|
+
uri = Bib::Uri.new(content: url, type: "org")
|
|
225
|
+
org = Bib::Organization.new(name: [orgname], uri: [uri], abbreviation: abbr)
|
|
226
|
+
role = Bib::Contributor::Role.new(type: "publisher")
|
|
227
|
+
Bib::Contributor.new(organization: org, role: [role])
|
|
228
|
+
end
|
|
229
|
+
result = contribs + editorialgroup_contributors
|
|
230
|
+
@errors[:contributor] &&= result.empty?
|
|
231
|
+
result
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
#
|
|
235
|
+
# Create contributors from editorial group (committee).
|
|
236
|
+
#
|
|
237
|
+
# @return [Array<Bib::Contributor>] editorial group contributors
|
|
238
|
+
#
|
|
239
|
+
def editorialgroup_contributors
|
|
240
|
+
return [] unless @pub["committee"]
|
|
241
|
+
|
|
242
|
+
wg = @pub["committee"]["reference"]
|
|
243
|
+
number = wg.match(/\d+/)&.to_s
|
|
244
|
+
orgname = Bib::TypedLocalizedString.new(content: "International Electrotechnical Commission",
|
|
245
|
+
language: "en", script: "Latn")
|
|
246
|
+
abbr = Bib::LocalizedString.new(content: "IEC", language: "en", script: "Latn")
|
|
247
|
+
tcname = Bib::TypedLocalizedString.new(content: wg, language: "en", script: "Latn")
|
|
248
|
+
identifiers = array(number).map { |n| Bib::OrganizationType::Identifier.new(content: n) }
|
|
249
|
+
subdivision = Bib::Subdivision.new(
|
|
250
|
+
type: "technical-committee",
|
|
251
|
+
name: [tcname],
|
|
252
|
+
identifier: identifiers,
|
|
253
|
+
)
|
|
254
|
+
org = Bib::Organization.new(name: [orgname], abbreviation: abbr, subdivision: [subdivision])
|
|
255
|
+
desc = Bib::LocalizedMarkedUpString.new(content: "committee")
|
|
256
|
+
role = Bib::Contributor::Role.new(type: "author", description: [desc])
|
|
257
|
+
[Bib::Contributor.new(organization: org, role: [role])]
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
#
|
|
261
|
+
# Parse links.
|
|
262
|
+
#
|
|
263
|
+
# @return [Array<Relaton::Bib::Uri>] links
|
|
264
|
+
#
|
|
265
|
+
def source
|
|
266
|
+
url = "#{DOMAIN}/publication/#{urn_id}"
|
|
267
|
+
l = [Bib::Uri.new(content: url, type: "src")]
|
|
268
|
+
result = array(@pub["releaseItems"]).each_with_object(l) do |r, a|
|
|
269
|
+
next unless r["type"] == "PREVIEW"
|
|
270
|
+
|
|
271
|
+
url = "#{DOMAIN}/preview/#{r['contentRef']['fileName']}"
|
|
272
|
+
a << Bib::Uri.new(content: url, type: "obp")
|
|
273
|
+
end
|
|
274
|
+
@errors[:source] &&= result.empty?
|
|
275
|
+
result
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
#
|
|
279
|
+
# Extract URN ID from URN.
|
|
280
|
+
#
|
|
281
|
+
# @return [String] URN ID
|
|
282
|
+
#
|
|
283
|
+
def urn_id
|
|
284
|
+
@pub["urn"].split(":").last
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
#
|
|
288
|
+
# Parse relation.
|
|
289
|
+
#
|
|
290
|
+
# @return [Array<Relaton::Bib::Relation>] relation
|
|
291
|
+
#
|
|
292
|
+
def relation # rubocop:disable Metrics/MethodLength
|
|
293
|
+
try = 0
|
|
294
|
+
result = begin
|
|
295
|
+
uri = URI "#{DOMAIN}/webstore/webstore.nsf/AjaxRequestXML?Openagent&url=#{urn_id}"
|
|
296
|
+
resp = Net::HTTP.get_response uri
|
|
297
|
+
doc = Nokogiri::XML resp.body
|
|
298
|
+
create_relations doc
|
|
299
|
+
rescue StandardError => e
|
|
300
|
+
try += 1
|
|
301
|
+
try < 3 ? retry : raise(e)
|
|
302
|
+
end
|
|
303
|
+
@errors[:relation] &&= result.empty?
|
|
304
|
+
result
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
#
|
|
308
|
+
# Create relations.
|
|
309
|
+
#
|
|
310
|
+
# @param [Nokogiri::XML::Document] doc XML document
|
|
311
|
+
#
|
|
312
|
+
# @return [Array<Relaton::Bib::Relation>] relations
|
|
313
|
+
#
|
|
314
|
+
def create_relations(doc) # rubocop:disable Metrics/MethodLength
|
|
315
|
+
doc.xpath('//ROW[STATUS[.!="PREPARING" and .!="PUBLISHED"]]')
|
|
316
|
+
.map do |r|
|
|
317
|
+
r_type = r.at("STATUS").text.downcase
|
|
318
|
+
type = case r_type
|
|
319
|
+
when "revised", "replaced" then "updates"
|
|
320
|
+
when "withdrawn" then "obsoletes"
|
|
321
|
+
else r_type
|
|
322
|
+
end
|
|
323
|
+
ref = r.at("FULL_NAME").text
|
|
324
|
+
docid = Docidentifier.new(content: ref, type: "IEC", primary: true)
|
|
325
|
+
bibitem = ItemData.new(formattedref: Bib::Formattedref.new(content: ref), docidentifier: [docid])
|
|
326
|
+
Relation.new type: type, bibitem: bibitem
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
def place
|
|
331
|
+
[Bib::Place.new(city: "Geneva")]
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
def ext
|
|
335
|
+
result = Ext.new(
|
|
336
|
+
doctype: doctype,
|
|
337
|
+
structuredidentifier: structuredidentifier,
|
|
338
|
+
flavor: "iec",
|
|
339
|
+
ics: ics,
|
|
340
|
+
price_code: @pub.dig("priceInfo", "priceCode"),
|
|
341
|
+
)
|
|
342
|
+
@errors[:ext] &&= result.nil?
|
|
343
|
+
result
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
#
|
|
347
|
+
# Parse structured identifier.
|
|
348
|
+
#
|
|
349
|
+
# @return [Relaton::Iso::StructuredIdentifier] structured identifier
|
|
350
|
+
#
|
|
351
|
+
def structuredidentifier
|
|
352
|
+
urn = @pub.dig("project", "urn")
|
|
353
|
+
return unless urn
|
|
354
|
+
|
|
355
|
+
result = begin
|
|
356
|
+
pnum = Iso::ProjectNumber.new(content: urn.split(":").last)
|
|
357
|
+
Iso::StructuredIdentifier.new(project_number: pnum, type: "IEC")
|
|
358
|
+
end
|
|
359
|
+
@errors[:structuredidentifier] &&= result.nil?
|
|
360
|
+
result
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
#
|
|
364
|
+
# Parse document type.
|
|
365
|
+
#
|
|
366
|
+
# @return [Relaton::Iec::Doctype] document type
|
|
367
|
+
#
|
|
368
|
+
def doctype
|
|
369
|
+
type = DOCTYPES[@pub["stdType"]] || @pub["stdType"].downcase
|
|
370
|
+
result = Doctype.new content: type
|
|
371
|
+
@errors[:doctype] &&= result.nil?
|
|
372
|
+
result
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
#
|
|
376
|
+
# Fetche ics.
|
|
377
|
+
#
|
|
378
|
+
# @return [Array<Relaton::Bib::ICS>] ics
|
|
379
|
+
#
|
|
380
|
+
def ics
|
|
381
|
+
return [] unless @pub["classifications"]
|
|
382
|
+
|
|
383
|
+
result = @pub["classifications"].select { |c| c["type"] == "ICS" }.map do |c|
|
|
384
|
+
Bib::ICS.new(code: c["value"])
|
|
385
|
+
end
|
|
386
|
+
@errors[:ics] &&= result.empty?
|
|
387
|
+
result
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
end
|
|
391
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Iec
|
|
5
|
+
# Hit.
|
|
6
|
+
class Hit < Core::Hit
|
|
7
|
+
GHURL = "https://raw.githubusercontent.com/relaton/relaton-data-iec/refs/heads/v2/"
|
|
8
|
+
|
|
9
|
+
attr_writer :item
|
|
10
|
+
|
|
11
|
+
# Parse page.
|
|
12
|
+
# @return [Relaton::Iec::ItemData]
|
|
13
|
+
def item
|
|
14
|
+
@item ||= begin
|
|
15
|
+
url = "#{GHURL}#{hit[:file]}"
|
|
16
|
+
resp = Net::HTTP.get URI(url)
|
|
17
|
+
Item.from_yaml(resp).tap { |it| it.fetched = Date.today.to_s }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def part
|
|
22
|
+
@part ||= hit[:id]&.part&.to_s || hit[:code]&.match(/(?<=-)[\w-]+/)&.to_s
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|