relaton 2.2.0.pre.alpha.1 → 3.0.0.pre.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/registry.rb +4 -4
- data/lib/relaton/db.rb +0 -1
- 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 +43 -0
- metadata +673 -170
- 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,66 @@
|
|
|
1
|
+
require "relaton/core/processor"
|
|
2
|
+
|
|
3
|
+
module Relaton::Calconnect
|
|
4
|
+
class Processor < Relaton::Core::Processor
|
|
5
|
+
attr_reader :idtype
|
|
6
|
+
|
|
7
|
+
def initialize # rubocop:disable Lint/MissingSuper
|
|
8
|
+
@short = :relaton_calconnect
|
|
9
|
+
@prefix = "CC"
|
|
10
|
+
@defaultprefix = %r{^CC(?!\w)}
|
|
11
|
+
@idtype = "CC"
|
|
12
|
+
@datasets = %w[calconnect-org]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @param code [String]
|
|
16
|
+
# @param date [String, nil] year
|
|
17
|
+
# @param opts [Hash]
|
|
18
|
+
# @return [Relaton::Calconnect::ItemData, nil]
|
|
19
|
+
def get(code, date, opts)
|
|
20
|
+
require_relative "../calconnect"
|
|
21
|
+
Bibliography.get(code, date, opts)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
#
|
|
25
|
+
# Fetch all the documents from a source
|
|
26
|
+
#
|
|
27
|
+
# @param [String] _source source name
|
|
28
|
+
# @param [Hash] opts
|
|
29
|
+
# @option opts [String] :output directory to output documents
|
|
30
|
+
# @option opts [String] :format
|
|
31
|
+
#
|
|
32
|
+
def fetch_data(_source, opts)
|
|
33
|
+
require_relative "data_fetcher"
|
|
34
|
+
DataFetcher.fetch(**opts)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @param xml [String]
|
|
38
|
+
# @return [Relaton::Calconnect::ItemData]
|
|
39
|
+
def from_xml(xml)
|
|
40
|
+
require_relative "../calconnect"
|
|
41
|
+
Item.from_xml xml
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @param hash [Hash]
|
|
45
|
+
# @return [Relaton::Calconnect::ItemData]
|
|
46
|
+
def hash_to_bib(hash)
|
|
47
|
+
require_relative "../calconnect"
|
|
48
|
+
Item.from_yaml hash.to_yaml
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Returns hash of XML grammar
|
|
52
|
+
# @return [String]
|
|
53
|
+
def grammar_hash
|
|
54
|
+
require_relative "../calconnect"
|
|
55
|
+
@grammar_hash ||= ::Relaton::Calconnect.grammar_hash
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
#
|
|
59
|
+
# Remove index file
|
|
60
|
+
#
|
|
61
|
+
def remove_index_file
|
|
62
|
+
require_relative "../calconnect"
|
|
63
|
+
Relaton::Index.find_or_create(:CC, url: true, file: "#{INDEXFILE}.yaml").remove_file
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
require "mechanize"
|
|
2
|
+
require "stringio"
|
|
3
|
+
require "zip"
|
|
4
|
+
require_relative "model/item"
|
|
5
|
+
require_relative "model/bibdata"
|
|
6
|
+
|
|
7
|
+
module Relaton
|
|
8
|
+
module Calconnect
|
|
9
|
+
class Scraper
|
|
10
|
+
include Core::HashKeysSymbolizer
|
|
11
|
+
include Core::ArrayWrapper
|
|
12
|
+
|
|
13
|
+
RELEASE_ASSET_URL = "https://github.com/%<owner>s/%<repo>s/releases/download/" \
|
|
14
|
+
"%<tag>s/%<asset_stem>s.zip".freeze
|
|
15
|
+
|
|
16
|
+
# @param errors [Hash] error tracking hash
|
|
17
|
+
def initialize(errors = {})
|
|
18
|
+
@errors = errors
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
#
|
|
22
|
+
# Parse an aggregate-index document entry: download the per-document
|
|
23
|
+
# GitHub release zip, extract the RXL, and parse it into a bibitem.
|
|
24
|
+
#
|
|
25
|
+
# @param hit [Hash] document entry from /cc/index.json
|
|
26
|
+
#
|
|
27
|
+
# @return [Relaton::Calconnect::ItemData] bibliographic item
|
|
28
|
+
#
|
|
29
|
+
def parse_page(hit)
|
|
30
|
+
zip_data = download_release_zip hit
|
|
31
|
+
rxl = extract_rxl zip_data, rxl_filename(hit)
|
|
32
|
+
xml = normalize_rxl rxl
|
|
33
|
+
Item.from_xml xml
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def release_zip_url(hit)
|
|
39
|
+
source = hit["source"] || {}
|
|
40
|
+
format(
|
|
41
|
+
RELEASE_ASSET_URL,
|
|
42
|
+
owner: source["owner"],
|
|
43
|
+
repo: source["repo"],
|
|
44
|
+
tag: source["tag"],
|
|
45
|
+
asset_stem: asset_stem(hit),
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def rxl_filename(hit)
|
|
50
|
+
"#{asset_stem(hit)}.rxl"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# The release asset uses the tag with the slash replaced by a hyphen,
|
|
54
|
+
# which encodes both the document id and the release qualifier
|
|
55
|
+
# (e.g. `ed1`, `ed1-wd`).
|
|
56
|
+
def asset_stem(hit)
|
|
57
|
+
(hit["source"] && hit["source"]["tag"] || "").tr("/", "-")
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def download_release_zip(hit)
|
|
61
|
+
url = release_zip_url(hit)
|
|
62
|
+
agent.get(url).body
|
|
63
|
+
rescue Mechanize::ResponseCodeError => e
|
|
64
|
+
raise "Failed to download release zip #{url}: HTTP #{e.response_code}"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def agent
|
|
68
|
+
@agent ||= Mechanize.new
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def extract_rxl(zip_data, filename)
|
|
72
|
+
Zip::File.open_buffer(StringIO.new(zip_data)) do |zip|
|
|
73
|
+
entry = zip.find_entry(filename)
|
|
74
|
+
raise "RXL file #{filename} not found in release zip" unless entry
|
|
75
|
+
|
|
76
|
+
return entry.get_input_stream.read
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def normalize_rxl(xml)
|
|
81
|
+
xml.gsub(%r{(</?)technical-committee(>)}, '\1committee\2')
|
|
82
|
+
.gsub(%r{type="(?:csd|CC)"(?=>)}i, '\0 primary="true"')
|
|
83
|
+
.gsub(%r{type="Technical committee"}, 'type="technical-committee"')
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require "relaton/index"
|
|
2
|
+
require "relaton/core"
|
|
3
|
+
require_relative "version"
|
|
4
|
+
require_relative "calconnect/model/item"
|
|
5
|
+
require_relative "calconnect/util"
|
|
6
|
+
require_relative "calconnect/model/bibitem"
|
|
7
|
+
require_relative "calconnect/model/bibdata"
|
|
8
|
+
require_relative "calconnect/bibliography"
|
|
9
|
+
require_relative "calconnect/hit_collection"
|
|
10
|
+
require_relative "calconnect/hit"
|
|
11
|
+
require_relative "calconnect/scraper"
|
|
12
|
+
|
|
13
|
+
module Relaton
|
|
14
|
+
module Calconnect
|
|
15
|
+
INDEXFILE = "index-v1".freeze
|
|
16
|
+
|
|
17
|
+
# Returns hash of XML reammar
|
|
18
|
+
# @return [String]
|
|
19
|
+
def self.grammar_hash
|
|
20
|
+
# gem_path = File.expand_path "..", __dir__
|
|
21
|
+
# grammars_path = File.join gem_path, "grammars", "*"
|
|
22
|
+
# grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
|
23
|
+
Digest::MD5.hexdigest Relaton::VERSION # grammars
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require_relative "hit_collection"
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Ccsds
|
|
5
|
+
module Bibliography
|
|
6
|
+
extend self
|
|
7
|
+
|
|
8
|
+
#
|
|
9
|
+
# Search for CCSDS standards by document reference.
|
|
10
|
+
#
|
|
11
|
+
# @param [String] ref document reference
|
|
12
|
+
#
|
|
13
|
+
# @return [RelatonCcsds::HitCollection] collection of hits
|
|
14
|
+
#
|
|
15
|
+
def search(ref)
|
|
16
|
+
HitCollection.new(ref).fetch
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
#
|
|
20
|
+
# Get CCSDS standard by document reference.
|
|
21
|
+
# If format is not specified, then all format will be returned.
|
|
22
|
+
#
|
|
23
|
+
# @param reference [String]
|
|
24
|
+
# @param year [String, nil]
|
|
25
|
+
# @param opts [Hash]
|
|
26
|
+
# @option opts [String] :format format of fetched document (DOC, PDF)
|
|
27
|
+
#
|
|
28
|
+
# @return [RelatonCcsds::BibliographicItem]
|
|
29
|
+
#
|
|
30
|
+
def get(reference, _year = nil, opts = {})
|
|
31
|
+
ref, opts = parse_format(reference, opts)
|
|
32
|
+
Util.info "Fetching from Relaton repository ...", key: reference
|
|
33
|
+
item, hit = fetch_item(ref)
|
|
34
|
+
if item.nil? || filter_sources(item, opts[:format])
|
|
35
|
+
Util.info "Not found.", key: reference
|
|
36
|
+
return nil
|
|
37
|
+
end
|
|
38
|
+
Util.info "Found: `#{hit[:code]}`.", key: reference
|
|
39
|
+
item
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def parse_format(reference, opts)
|
|
45
|
+
ref = reference.sub(/\s\((DOC|PDF)\)$/, "")
|
|
46
|
+
opts[:format] ||= Regexp.last_match(1)
|
|
47
|
+
[ref, opts]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def fetch_item(ref)
|
|
51
|
+
hit = search(ref).first
|
|
52
|
+
[hit&.item, hit&.hit]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def filter_sources(item, format)
|
|
56
|
+
return unless format
|
|
57
|
+
|
|
58
|
+
item.source = item.source.select { |s| s.type == format.downcase }
|
|
59
|
+
item.source.empty?
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
require "mechanize"
|
|
3
|
+
require "relaton/index"
|
|
4
|
+
require "pubid"
|
|
5
|
+
require_relative "../../ccsds"
|
|
6
|
+
require_relative "parser"
|
|
7
|
+
|
|
8
|
+
module Relaton
|
|
9
|
+
module Ccsds
|
|
10
|
+
class DataFetcher < Relaton::Core::DataFetcher
|
|
11
|
+
TRRGX = /\s-\s\w+\sTranslated$/
|
|
12
|
+
|
|
13
|
+
def agent
|
|
14
|
+
return @agent if @agent
|
|
15
|
+
|
|
16
|
+
@agent = Mechanize.new
|
|
17
|
+
@agent.request_headers = { "Accept" => "application/json;odata=verbose" }
|
|
18
|
+
@agent
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Pubid index (index-v2): `:id` is the lean pubid hash. index-v1 (the
|
|
22
|
+
# pubid-v1 hash index for the released gem line) is rebuilt separately by
|
|
23
|
+
# the data repo's build_index_v1.rb, in its own process with a pubid-v1
|
|
24
|
+
# bundle, because pubid v1 and v2 both define Pubid::Ccsds::Identifier and
|
|
25
|
+
# cannot coexist here.
|
|
26
|
+
def index
|
|
27
|
+
@index ||= Relaton::Index.find_or_create(
|
|
28
|
+
:ccsds, file: "#{INDEXFILE}.yaml", pubid_class: Pubid::Ccsds::Identifier
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def fetch(_source = nil)
|
|
33
|
+
fetch_docs "https://ccsds.org/publications/ccsdsallpubs/"
|
|
34
|
+
index.save
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
#
|
|
38
|
+
# Fetch documents from url
|
|
39
|
+
#
|
|
40
|
+
# @param [String] url
|
|
41
|
+
#
|
|
42
|
+
# @return [void]
|
|
43
|
+
#
|
|
44
|
+
def fetch_docs(url)
|
|
45
|
+
resp = agent.get(url)
|
|
46
|
+
json = JSON.parse resp.body.match(/const config = (.*);/)[1]
|
|
47
|
+
@array = json["data"].map { |doc| parse_and_save doc, json["data"] }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
#
|
|
51
|
+
# Parse document and save to file
|
|
52
|
+
#
|
|
53
|
+
# @param [Hash] doc document data
|
|
54
|
+
# @param [Array<Array<String>>] data collection of documents
|
|
55
|
+
# 0 - empty
|
|
56
|
+
# 1 - center/a HTML element with href to PDF
|
|
57
|
+
# 2 - a HTML element with href to HTML and document ID content (e.g. "CCSDS 123.0-B-1")
|
|
58
|
+
# 3 - document title
|
|
59
|
+
# 4 - document series (e.g. "Blue Book", "Silver Book", etc)
|
|
60
|
+
# 5 - issue number
|
|
61
|
+
# 6 - publication date (e.g. "August 2020")
|
|
62
|
+
# 7 - abstract
|
|
63
|
+
# 8 - Working Group as `{WG name} <a href="{path}" ...`
|
|
64
|
+
# 9 - ISO Equivalent as `{ISO id} <a href="{uri}" ...`
|
|
65
|
+
# 10 - Patent Licensing. Some docs has this field. Content is same and looks not useful.
|
|
66
|
+
# 11 - Extra Information. Looks not useful.
|
|
67
|
+
#
|
|
68
|
+
# @return [void]
|
|
69
|
+
#
|
|
70
|
+
def parse_and_save(doc, data)
|
|
71
|
+
bibitem = DataParser.new(doc, data).parse
|
|
72
|
+
if doc[4] == "Silver Book"
|
|
73
|
+
predecessor = DataParser.new(doc, data, bibitem).parse
|
|
74
|
+
save_bib predecessor
|
|
75
|
+
end
|
|
76
|
+
save_bib bibitem
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
#
|
|
80
|
+
# Save bibitem to file
|
|
81
|
+
#
|
|
82
|
+
# @param [Relaton::Ccsds::Item] bib bibitem
|
|
83
|
+
#
|
|
84
|
+
# @return [void]
|
|
85
|
+
#
|
|
86
|
+
def save_bib(bib) # rubocop:disable Metrics/AbcSize
|
|
87
|
+
search_instance_translation bib
|
|
88
|
+
file = output_file(bib.docidentifier.first.content)
|
|
89
|
+
merge_links bib, file
|
|
90
|
+
File.write file, serialize(bib), encoding: "UTF-8"
|
|
91
|
+
index.add_or_update Pubid::Ccsds::Identifier.parse(bib.docidentifier.first.content), file
|
|
92
|
+
rescue StandardError => e
|
|
93
|
+
puts "Failed to save #{bib.docidentifier.first.content}: #{e.message}\n#{e.backtrace[0..5].join("\n")}"
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
#
|
|
97
|
+
# Search translation and instance relation
|
|
98
|
+
#
|
|
99
|
+
# @param [Relaton::Ccsds::Item] bib translation bibitem
|
|
100
|
+
#
|
|
101
|
+
# @return [void]
|
|
102
|
+
#
|
|
103
|
+
def search_instance_translation(bib)
|
|
104
|
+
bibid = bib.docidentifier.first.content.dup
|
|
105
|
+
if bibid.sub!(TRRGX, "")
|
|
106
|
+
search_relations bibid, bib
|
|
107
|
+
else
|
|
108
|
+
search_translations bibid, bib
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
#
|
|
113
|
+
# Search instance or translation relation
|
|
114
|
+
#
|
|
115
|
+
# @param [String] bibid instance bibitem id
|
|
116
|
+
# @param [Relaton::Ccsds::ItemData] bib instance or translation bibitem
|
|
117
|
+
#
|
|
118
|
+
# @return [void]
|
|
119
|
+
#
|
|
120
|
+
def search_relations(bibid, bib)
|
|
121
|
+
bibid_pid = ::Pubid::Ccsds::Identifier.parse(bibid)
|
|
122
|
+
# search(bibid_pid) narrows candidates by number via binary search first.
|
|
123
|
+
index.search(bibid_pid) do |row|
|
|
124
|
+
id = row[:id].exclude(:language)
|
|
125
|
+
# TODO: smiplify this line?
|
|
126
|
+
next if id != bibid_pid || row[:id] == bib.docidentifier.first.content
|
|
127
|
+
|
|
128
|
+
create_relations bib, row[:file]
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def search_translations(bibid, bib)
|
|
133
|
+
bibid_pid = ::Pubid::Ccsds::Identifier.parse(bibid)
|
|
134
|
+
# will call create_instance_relation if
|
|
135
|
+
# there are same identifiers in index but with word "Translated"
|
|
136
|
+
# search(bibid_pid) narrows candidates by number via binary search first.
|
|
137
|
+
index.search(bibid_pid) do |row|
|
|
138
|
+
next unless row[:id].language && row[:id].exclude(:language) == bibid_pid
|
|
139
|
+
|
|
140
|
+
create_instance_relation bib, row[:file]
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
#
|
|
145
|
+
# Create translation or instance relation and save to file
|
|
146
|
+
#
|
|
147
|
+
# @param [Relaton::Ccsds::ItemData] bib bibliographic item
|
|
148
|
+
# @param [String] file translation or instance file
|
|
149
|
+
#
|
|
150
|
+
# @return [void]
|
|
151
|
+
#
|
|
152
|
+
def create_relations(bib, file)
|
|
153
|
+
inst = parse_file file
|
|
154
|
+
type1, type2 = translation_relation_types(inst)
|
|
155
|
+
create_relation(inst, type1) { |rel| bib.relation << rel }
|
|
156
|
+
create_relation(bib, type2) { |rel| inst.relation << rel }
|
|
157
|
+
File.write file, serialize(inst), encoding: "UTF-8"
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def parse_file(file)
|
|
161
|
+
case @format
|
|
162
|
+
when "yaml" then Item.from_yaml File.read(file, encoding: "UTF-8")
|
|
163
|
+
when "xml" then Item.from_xml File.read(file, encoding: "UTF-8")
|
|
164
|
+
else
|
|
165
|
+
raise "Unknown format #{@format}"
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
#
|
|
170
|
+
# Translation or instance relation types
|
|
171
|
+
#
|
|
172
|
+
# @param [Relaton::Ccsds::ItemData] bib bibliographic item
|
|
173
|
+
#
|
|
174
|
+
# @return [Array<String>] relation types
|
|
175
|
+
#
|
|
176
|
+
def translation_relation_types(bib)
|
|
177
|
+
if bib.docidentifier.first.content.match?(TRRGX)
|
|
178
|
+
["hasTranslation"] * 2
|
|
179
|
+
else
|
|
180
|
+
["instanceOf", "hasInstance"]
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
#
|
|
185
|
+
# Create instance relation and save to file
|
|
186
|
+
#
|
|
187
|
+
# @param [Relaton::Ccsds::Item] bib bibliographic item
|
|
188
|
+
# @param [String] file file name
|
|
189
|
+
#
|
|
190
|
+
# @return [void]
|
|
191
|
+
#
|
|
192
|
+
def create_instance_relation(bib, file)
|
|
193
|
+
inst = parse_file file
|
|
194
|
+
create_relation(inst, "hasInstance") { |rel| bib.relation << rel }
|
|
195
|
+
create_relation(bib, "instanceOf") { |rel| inst.relation << rel }
|
|
196
|
+
File.write file, serialize(inst), encoding: "UTF-8"
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
#
|
|
200
|
+
# Create relation
|
|
201
|
+
#
|
|
202
|
+
# @param [Relaton::Ccsds::Item] bib the related bibliographic item
|
|
203
|
+
# @param [String] type type of relation
|
|
204
|
+
#
|
|
205
|
+
# @return [Relaton::Bib::Relation] relation
|
|
206
|
+
#
|
|
207
|
+
def create_relation(bib, type)
|
|
208
|
+
bib_docid = bib.docidentifier.first
|
|
209
|
+
return unless bib_docid
|
|
210
|
+
|
|
211
|
+
docid = Bib::Docidentifier.from_yaml(bib_docid.to_yaml)
|
|
212
|
+
rel = Relaton::Bib::ItemData.new docidentifier: [docid], formattedref: Relaton::Bib::Formattedref.new(content: bib_docid.content.dup)
|
|
213
|
+
yield Relaton::Bib::Relation.new(type: type, bibitem: rel)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
#
|
|
217
|
+
# Merge identical documents with different links (updaes given bibitem)
|
|
218
|
+
#
|
|
219
|
+
# @param [Relaton::Ccsds::Item] bib bibliographic item
|
|
220
|
+
# @param [String] file path to existing document
|
|
221
|
+
#
|
|
222
|
+
# @return [void]
|
|
223
|
+
#
|
|
224
|
+
def merge_links(bib, file) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
225
|
+
# skip merging when new file
|
|
226
|
+
unless @files.include?(file)
|
|
227
|
+
@files << file
|
|
228
|
+
return
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
puts "(#{file}) file already exists. Trying to merge links ..."
|
|
232
|
+
|
|
233
|
+
bib2 = parse_file file
|
|
234
|
+
bib2.source.each do |src|
|
|
235
|
+
next if bib.source.any? { |s| s.type == src.type }
|
|
236
|
+
|
|
237
|
+
bib.source << src
|
|
238
|
+
end
|
|
239
|
+
Util.info "links are merged.", key: file
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def to_yaml(bib) = bib.to_yaml
|
|
243
|
+
def to_xml(bib) = bib.to_xml(bibdata: true)
|
|
244
|
+
def to_bibxml(bib) = bib.to_rfcxml
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require "csv"
|
|
2
|
+
require "singleton"
|
|
3
|
+
require "mechanize"
|
|
4
|
+
|
|
5
|
+
module Relaton
|
|
6
|
+
module Ccsds
|
|
7
|
+
class IsoReferences
|
|
8
|
+
include Singleton
|
|
9
|
+
|
|
10
|
+
ISO_CSV_URL = "https://isopublicstorageprod.blob.core.windows.net/opendata/_latest"\
|
|
11
|
+
"/iso_deliverables_metadata/csv/iso_deliverables_metadata.csv".freeze
|
|
12
|
+
|
|
13
|
+
def [](key)
|
|
14
|
+
data[key]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def data
|
|
20
|
+
@data ||= begin
|
|
21
|
+
csv = Mechanize.new.get(ISO_CSV_URL).body
|
|
22
|
+
rows = CSV.parse(csv, headers: true)
|
|
23
|
+
rows.each_with_object({}) do |row, h|
|
|
24
|
+
h[row["id"]] = row["reference"]
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|