relaton 2.2.0.pre.alpha.1 → 3.0.0.pre.alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{docs/README.adoc → README.adoc} +165 -38
- data/bin/console +0 -1
- data/lib/relaton/3gpp/bibdata.rb +9 -0
- data/lib/relaton/3gpp/bibitem.rb +9 -0
- data/lib/relaton/3gpp/bibliography.rb +123 -0
- data/lib/relaton/3gpp/data_fetcher.rb +303 -0
- data/lib/relaton/3gpp/docidentifier.rb +114 -0
- data/lib/relaton/3gpp/doctype.rb +9 -0
- data/lib/relaton/3gpp/ext.rb +31 -0
- data/lib/relaton/3gpp/item.rb +18 -0
- data/lib/relaton/3gpp/item_data.rb +15 -0
- data/lib/relaton/3gpp/parser.rb +400 -0
- data/lib/relaton/3gpp/processor.rb +71 -0
- data/lib/relaton/3gpp/release.rb +34 -0
- data/lib/relaton/3gpp/util.rb +8 -0
- data/lib/relaton/3gpp.rb +29 -0
- data/lib/relaton/adobe/bibdata.rb +8 -0
- data/lib/relaton/adobe/bibitem.rb +8 -0
- data/lib/relaton/adobe/bibliography.rb +92 -0
- data/lib/relaton/adobe/docidentifier.rb +49 -0
- data/lib/relaton/adobe/doctype.rb +14 -0
- data/lib/relaton/adobe/ext.rb +32 -0
- data/lib/relaton/adobe/item.rb +15 -0
- data/lib/relaton/adobe/item_base.rb +18 -0
- data/lib/relaton/adobe/item_data.rb +6 -0
- data/lib/relaton/adobe/processor.rb +45 -0
- data/lib/relaton/adobe/util.rb +8 -0
- data/lib/relaton/adobe.rb +37 -0
- data/lib/relaton/bib/converter/asciibib/to_asciibib.rb +663 -0
- data/lib/relaton/bib/converter/asciibib.rb +13 -0
- data/lib/relaton/bib/converter/bibtex/from_bibtex.rb +245 -0
- data/lib/relaton/bib/converter/bibtex/to_bibtex.rb +341 -0
- data/lib/relaton/bib/converter/bibtex.rb +23 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml.rb +386 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml_referencegroup.rb +71 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml.rb +308 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml_referencegroup.rb +52 -0
- data/lib/relaton/bib/converter/bibxml.rb +51 -0
- data/lib/relaton/bib/hash_parser_v1.rb +767 -0
- data/lib/relaton/bib/item_data.rb +229 -0
- data/lib/relaton/bib/model/abstract.rb +16 -0
- data/lib/relaton/bib/model/address.rb +22 -0
- data/lib/relaton/bib/model/affiliation.rb +16 -0
- data/lib/relaton/bib/model/bibdata.rb +11 -0
- data/lib/relaton/bib/model/bibdata_shared.rb +12 -0
- data/lib/relaton/bib/model/bibitem.rb +11 -0
- data/lib/relaton/bib/model/bibitem_shared.rb +12 -0
- data/lib/relaton/bib/model/contact.rb +18 -0
- data/lib/relaton/bib/model/contribution_info.rb +15 -0
- data/lib/relaton/bib/model/contributor.rb +29 -0
- data/lib/relaton/bib/model/copyright.rb +27 -0
- data/lib/relaton/bib/model/date.rb +31 -0
- data/lib/relaton/bib/model/depiction.rb +16 -0
- data/lib/relaton/bib/model/docidentifier.rb +49 -0
- data/lib/relaton/bib/model/doctype.rb +14 -0
- data/lib/relaton/bib/model/edition.rb +14 -0
- data/lib/relaton/bib/model/ext.rb +39 -0
- data/lib/relaton/bib/model/extent.rb +16 -0
- data/lib/relaton/bib/model/formattedref.rb +43 -0
- data/lib/relaton/bib/model/full_name_type.rb +64 -0
- data/lib/relaton/bib/model/fullname.rb +11 -0
- data/lib/relaton/bib/model/ics.rb +49 -0
- data/lib/relaton/bib/model/image.rb +28 -0
- data/lib/relaton/bib/model/item.rb +96 -0
- data/lib/relaton/bib/model/item_base.rb +20 -0
- data/lib/relaton/bib/model/item_shared.rb +88 -0
- data/lib/relaton/bib/model/keyword.rb +30 -0
- data/lib/relaton/bib/model/locality.rb +18 -0
- data/lib/relaton/bib/model/locality_stack.rb +14 -0
- data/lib/relaton/bib/model/localized_string.rb +48 -0
- data/lib/relaton/bib/model/localized_string_attrs.rb +24 -0
- data/lib/relaton/bib/model/logo.rb +14 -0
- data/lib/relaton/bib/model/medium.rb +22 -0
- data/lib/relaton/bib/model/note.rb +16 -0
- data/lib/relaton/bib/model/organization.rb +13 -0
- data/lib/relaton/bib/model/organization_type.rb +42 -0
- data/lib/relaton/bib/model/person.rb +36 -0
- data/lib/relaton/bib/model/phone.rb +14 -0
- data/lib/relaton/bib/model/place.rb +33 -0
- data/lib/relaton/bib/model/price.rb +14 -0
- data/lib/relaton/bib/model/relation.rb +43 -0
- data/lib/relaton/bib/model/series.rb +34 -0
- data/lib/relaton/bib/model/size.rb +23 -0
- data/lib/relaton/bib/model/source_locality_stack.rb +14 -0
- data/lib/relaton/bib/model/status.rb +27 -0
- data/lib/relaton/bib/model/structured_identifier.rb +49 -0
- data/lib/relaton/bib/model/subdivision.rb +16 -0
- data/lib/relaton/bib/model/title.rb +56 -0
- data/lib/relaton/bib/model/type/plain_date.rb +16 -0
- data/lib/relaton/bib/model/type/string_date.rb +48 -0
- data/lib/relaton/bib/model/uri.rb +18 -0
- data/lib/relaton/bib/model/validity.rb +16 -0
- data/lib/relaton/bib/model/version.rb +43 -0
- data/lib/relaton/bib/namespace_helper.rb +21 -0
- data/lib/relaton/bib/sanitizer.rb +264 -0
- data/lib/relaton/bib/util.rb +18 -0
- data/lib/relaton/bib/versions.json +35 -0
- data/lib/relaton/bib.rb +46 -0
- data/lib/relaton/bipm/bibliography.rb +231 -0
- data/lib/relaton/bipm/converter/asciibib.rb +64 -0
- data/lib/relaton/bipm/data_fetcher.rb +81 -0
- data/lib/relaton/bipm/data_outcomes_parser.rb +656 -0
- data/lib/relaton/bipm/id_parser.rb +278 -0
- data/lib/relaton/bipm/item_data.rb +47 -0
- data/lib/relaton/bipm/model/bibdata.rb +9 -0
- data/lib/relaton/bipm/model/bibitem.rb +9 -0
- data/lib/relaton/bipm/model/comment_period.rb +13 -0
- data/lib/relaton/bipm/model/doctype.rb +12 -0
- data/lib/relaton/bipm/model/ext.rb +38 -0
- data/lib/relaton/bipm/model/item.rb +11 -0
- data/lib/relaton/bipm/model/structured_identifier.rb +36 -0
- data/lib/relaton/bipm/processor.rb +69 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/affiliations.rb +111 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/fetcher.rb +172 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/niso_jats_parser.rb +353 -0
- data/lib/relaton/bipm/si_brochure_parser.rb +188 -0
- data/lib/relaton/bipm/util.rb +8 -0
- data/lib/relaton/bipm.rb +38 -0
- data/lib/relaton/bsi/bibliography.rb +196 -0
- data/lib/relaton/bsi/hit.rb +28 -0
- data/lib/relaton/bsi/hit_collection.rb +113 -0
- data/lib/relaton/bsi/item_data.rb +13 -0
- data/lib/relaton/bsi/model/bibdata.rb +8 -0
- data/lib/relaton/bsi/model/bibitem.rb +8 -0
- data/lib/relaton/bsi/model/docidentifier.rb +107 -0
- data/lib/relaton/bsi/model/doctype.rb +14 -0
- data/lib/relaton/bsi/model/ext.rb +17 -0
- data/lib/relaton/bsi/model/item.rb +17 -0
- data/lib/relaton/bsi/model/item_base.rb +22 -0
- data/lib/relaton/bsi/model/relation.rb +9 -0
- data/lib/relaton/bsi/processor.rb +43 -0
- data/lib/relaton/bsi/schema.json +24882 -0
- data/lib/relaton/bsi/scraper.rb +288 -0
- data/lib/relaton/bsi/util.rb +8 -0
- data/lib/relaton/bsi.rb +25 -0
- data/lib/relaton/calconnect/bibliography.rb +93 -0
- data/lib/relaton/calconnect/data_fetcher.rb +174 -0
- data/lib/relaton/calconnect/docidentifier.rb +80 -0
- data/lib/relaton/calconnect/hit.rb +14 -0
- data/lib/relaton/calconnect/hit_collection.rb +92 -0
- data/lib/relaton/calconnect/item_data.rb +12 -0
- data/lib/relaton/calconnect/model/bibdata.rb +8 -0
- data/lib/relaton/calconnect/model/bibitem.rb +8 -0
- data/lib/relaton/calconnect/model/doctype.rb +11 -0
- data/lib/relaton/calconnect/model/ext.rb +11 -0
- data/lib/relaton/calconnect/model/item.rb +20 -0
- data/lib/relaton/calconnect/processor.rb +72 -0
- data/lib/relaton/calconnect/scraper.rb +87 -0
- data/lib/relaton/calconnect/util.rb +8 -0
- data/lib/relaton/calconnect.rb +36 -0
- data/lib/relaton/ccsds/bibliography.rb +63 -0
- data/lib/relaton/ccsds/data/fetcher.rb +252 -0
- data/lib/relaton/ccsds/data/iso_references.rb +30 -0
- data/lib/relaton/ccsds/data/parser.rb +194 -0
- data/lib/relaton/ccsds/hit.rb +24 -0
- data/lib/relaton/ccsds/hit_collection.rb +47 -0
- data/lib/relaton/ccsds/item_data.rb +9 -0
- data/lib/relaton/ccsds/model/bibdata.rb +8 -0
- data/lib/relaton/ccsds/model/bibitem.rb +8 -0
- data/lib/relaton/ccsds/model/docidentifier.rb +121 -0
- data/lib/relaton/ccsds/model/doctype.rb +9 -0
- data/lib/relaton/ccsds/model/ext.rb +19 -0
- data/lib/relaton/ccsds/model/item.rb +15 -0
- data/lib/relaton/ccsds/processor.rb +68 -0
- data/lib/relaton/ccsds/util.rb +10 -0
- data/lib/relaton/ccsds.rb +33 -0
- data/lib/relaton/cen/bibliography.rb +149 -0
- data/lib/relaton/cen/committees.yaml +66 -0
- data/lib/relaton/cen/hit.rb +31 -0
- data/lib/relaton/cen/hit_collection.rb +116 -0
- data/lib/relaton/cen/item_data.rb +7 -0
- data/lib/relaton/cen/model/bibdata.rb +8 -0
- data/lib/relaton/cen/model/bibitem.rb +8 -0
- data/lib/relaton/cen/model/docidentifier.rb +100 -0
- data/lib/relaton/cen/model/ext.rb +11 -0
- data/lib/relaton/cen/model/item.rb +14 -0
- data/lib/relaton/cen/model/structured_identifier.rb +9 -0
- data/lib/relaton/cen/processor.rb +45 -0
- data/lib/relaton/cen/scraper.rb +218 -0
- data/lib/relaton/cen/util.rb +8 -0
- data/lib/relaton/cen.rb +30 -0
- data/lib/relaton/cie/bibdata.rb +8 -0
- data/lib/relaton/cie/bibitem.rb +8 -0
- data/lib/relaton/cie/bibliography.rb +31 -0
- data/lib/relaton/cie/data_fetcher.rb +540 -0
- data/lib/relaton/cie/ext.rb +7 -0
- data/lib/relaton/cie/item.rb +11 -0
- data/lib/relaton/cie/item_data.rb +6 -0
- data/lib/relaton/cie/processor.rb +68 -0
- data/lib/relaton/cie/scrapper.rb +52 -0
- data/lib/relaton/cie/util.rb +8 -0
- data/lib/relaton/cie.rb +29 -0
- data/lib/relaton/core/array_wrapper.rb +20 -0
- data/lib/relaton/core/data_fetcher.rb +244 -0
- data/lib/relaton/core/date_parser.rb +42 -0
- data/lib/relaton/core/governor.rb +320 -0
- data/lib/relaton/core/hash_keys_sybolizer.rb +19 -0
- data/lib/relaton/core/hit.rb +49 -0
- data/lib/relaton/core/hit_collection.rb +118 -0
- data/lib/relaton/core/pacer.rb +134 -0
- data/lib/relaton/core/processor.rb +67 -0
- data/lib/relaton/core/request_error.rb +14 -0
- data/lib/relaton/core/workers_pool.rb +45 -0
- data/lib/relaton/core.rb +12 -0
- data/lib/relaton/db/registry.rb +44 -4
- data/lib/relaton/db.rb +0 -1
- data/lib/relaton/doi/crossref.rb +89 -0
- data/lib/relaton/doi/parser.rb +921 -0
- data/lib/relaton/doi/processor.rb +65 -0
- data/lib/relaton/doi/util.rb +8 -0
- data/lib/relaton/doi.rb +20 -0
- data/lib/relaton/easc/bibdata.rb +8 -0
- data/lib/relaton/easc/bibitem.rb +8 -0
- data/lib/relaton/easc/bibliography.rb +95 -0
- data/lib/relaton/easc/docidentifier.rb +100 -0
- data/lib/relaton/easc/doctype.rb +14 -0
- data/lib/relaton/easc/ext.rb +44 -0
- data/lib/relaton/easc/item.rb +13 -0
- data/lib/relaton/easc/item_base.rb +18 -0
- data/lib/relaton/easc/item_data.rb +6 -0
- data/lib/relaton/easc/processor.rb +46 -0
- data/lib/relaton/easc/util.rb +8 -0
- data/lib/relaton/easc.rb +35 -0
- data/lib/relaton/ecma/bibdata.rb +8 -0
- data/lib/relaton/ecma/bibitem.rb +8 -0
- data/lib/relaton/ecma/bibliography.rb +149 -0
- data/lib/relaton/ecma/data_fetcher.rb +162 -0
- data/lib/relaton/ecma/data_parser.rb +49 -0
- data/lib/relaton/ecma/docidentifier.rb +124 -0
- data/lib/relaton/ecma/edition_parser.rb +80 -0
- data/lib/relaton/ecma/ext.rb +7 -0
- data/lib/relaton/ecma/item.rb +13 -0
- data/lib/relaton/ecma/item_data.rb +6 -0
- data/lib/relaton/ecma/memento_parser.rb +60 -0
- data/lib/relaton/ecma/page_fetcher.rb +39 -0
- data/lib/relaton/ecma/parser_common.rb +33 -0
- data/lib/relaton/ecma/processor.rb +69 -0
- data/lib/relaton/ecma/standard_parser.rb +134 -0
- data/lib/relaton/ecma/util.rb +8 -0
- data/lib/relaton/ecma.rb +33 -0
- data/lib/relaton/etsi/bibdata.rb +10 -0
- data/lib/relaton/etsi/bibitem.rb +10 -0
- data/lib/relaton/etsi/bibliography.rb +111 -0
- data/lib/relaton/etsi/data_fetcher.rb +167 -0
- data/lib/relaton/etsi/data_parser.rb +208 -0
- data/lib/relaton/etsi/doctype.rb +30 -0
- data/lib/relaton/etsi/ext.rb +31 -0
- data/lib/relaton/etsi/item.rb +15 -0
- data/lib/relaton/etsi/item_data.rb +6 -0
- data/lib/relaton/etsi/processor.rb +71 -0
- data/lib/relaton/etsi/pubid.rb +37 -0
- data/lib/relaton/etsi/status.rb +13 -0
- data/lib/relaton/etsi/util.rb +8 -0
- data/lib/relaton/etsi.rb +26 -0
- data/lib/relaton/gb/bibdata.rb +8 -0
- data/lib/relaton/gb/bibitem.rb +8 -0
- data/lib/relaton/gb/bibliography.rb +171 -0
- data/lib/relaton/gb/ccs.rb +14 -0
- data/lib/relaton/gb/committee.rb +13 -0
- data/lib/relaton/gb/docidentifier.rb +72 -0
- data/lib/relaton/gb/doctype.rb +9 -0
- data/lib/relaton/gb/ext.rb +36 -0
- data/lib/relaton/gb/gb_scraper.rb +61 -0
- data/lib/relaton/gb/gb_type.rb +20 -0
- data/lib/relaton/gb/hit.rb +48 -0
- data/lib/relaton/gb/hit_collection.rb +19 -0
- data/lib/relaton/gb/item.rb +13 -0
- data/lib/relaton/gb/item_data.rb +6 -0
- data/lib/relaton/gb/processor.rb +49 -0
- data/lib/relaton/gb/project_number.rb +38 -0
- data/lib/relaton/gb/scraper.rb +221 -0
- data/lib/relaton/gb/sec_scraper.rb +92 -0
- data/lib/relaton/gb/stage_name.rb +13 -0
- data/lib/relaton/gb/structured_identifier.rb +26 -0
- data/lib/relaton/gb/t_scraper.rb +126 -0
- data/lib/relaton/gb/util.rb +8 -0
- data/lib/relaton/gb/yaml/prefixes.yaml +200 -0
- data/lib/relaton/gb.rb +33 -0
- data/lib/relaton/gost/bibdata.rb +8 -0
- data/lib/relaton/gost/bibitem.rb +8 -0
- data/lib/relaton/gost/bibliography.rb +107 -0
- data/lib/relaton/gost/docidentifier.rb +80 -0
- data/lib/relaton/gost/doctype.rb +16 -0
- data/lib/relaton/gost/ext.rb +46 -0
- data/lib/relaton/gost/item.rb +15 -0
- data/lib/relaton/gost/item_base.rb +18 -0
- data/lib/relaton/gost/item_data.rb +6 -0
- data/lib/relaton/gost/processor.rb +49 -0
- data/lib/relaton/gost/util.rb +8 -0
- data/lib/relaton/gost.rb +36 -0
- data/lib/relaton/iala/bibdata.rb +8 -0
- data/lib/relaton/iala/bibitem.rb +8 -0
- data/lib/relaton/iala/bibliography.rb +146 -0
- data/lib/relaton/iala/docidentifier.rb +89 -0
- data/lib/relaton/iala/doctype.rb +18 -0
- data/lib/relaton/iala/ext.rb +32 -0
- data/lib/relaton/iala/item.rb +21 -0
- data/lib/relaton/iala/item_base.rb +18 -0
- data/lib/relaton/iala/item_data.rb +6 -0
- data/lib/relaton/iala/processor.rb +43 -0
- data/lib/relaton/iala/relation.rb +7 -0
- data/lib/relaton/iala/util.rb +8 -0
- data/lib/relaton/iala.rb +35 -0
- data/lib/relaton/iana/bibdata.rb +8 -0
- data/lib/relaton/iana/bibitem.rb +8 -0
- data/lib/relaton/iana/bibliography.rb +100 -0
- data/lib/relaton/iana/data_fetcher.rb +101 -0
- data/lib/relaton/iana/item.rb +7 -0
- data/lib/relaton/iana/item_data.rb +6 -0
- data/lib/relaton/iana/parser.rb +146 -0
- data/lib/relaton/iana/processor.rb +70 -0
- data/lib/relaton/iana/util.rb +8 -0
- data/lib/relaton/iana.rb +40 -0
- data/lib/relaton/iec/bibliography.rb +283 -0
- data/lib/relaton/iec/data_fetcher.rb +222 -0
- data/lib/relaton/iec/data_parser.rb +391 -0
- data/lib/relaton/iec/hit.rb +26 -0
- data/lib/relaton/iec/hit_collection.rb +138 -0
- data/lib/relaton/iec/item_data.rb +7 -0
- data/lib/relaton/iec/model/bibdata.rb +8 -0
- data/lib/relaton/iec/model/bibitem.rb +8 -0
- data/lib/relaton/iec/model/docidentifier.rb +135 -0
- data/lib/relaton/iec/model/doctype.rb +12 -0
- data/lib/relaton/iec/model/ext.rb +53 -0
- data/lib/relaton/iec/model/item.rb +20 -0
- data/lib/relaton/iec/model/item_base.rb +12 -0
- data/lib/relaton/iec/model/relation.rb +7 -0
- data/lib/relaton/iec/model/stage_name.rb +13 -0
- data/lib/relaton/iec/processor.rb +74 -0
- data/lib/relaton/iec/statuses.yml +199 -0
- data/lib/relaton/iec/util.rb +8 -0
- data/lib/relaton/iec.rb +98 -0
- data/lib/relaton/ieee/balloting_group.rb +13 -0
- data/lib/relaton/ieee/bibdata.rb +8 -0
- data/lib/relaton/ieee/bibitem.rb +8 -0
- data/lib/relaton/ieee/bibliography.rb +73 -0
- data/lib/relaton/ieee/converter/bibxml/from_rfcxml.rb +10 -0
- data/lib/relaton/ieee/converter/bibxml/from_rfcxml_referencegroup.rb +10 -0
- data/lib/relaton/ieee/converter/bibxml.rb +20 -0
- data/lib/relaton/ieee/data_fetcher.rb +771 -0
- data/lib/relaton/ieee/doctype.rb +9 -0
- data/lib/relaton/ieee/editorial_group.rb +19 -0
- data/lib/relaton/ieee/ext.rb +36 -0
- data/lib/relaton/ieee/idams_parser.rb +330 -0
- data/lib/relaton/ieee/item.rb +11 -0
- data/lib/relaton/ieee/item_data.rb +7 -0
- data/lib/relaton/ieee/processor.rb +71 -0
- data/lib/relaton/ieee/rawbib_id_parser.rb +753 -0
- data/lib/relaton/ieee/util.rb +8 -0
- data/lib/relaton/ieee.rb +30 -0
- data/lib/relaton/ietf/bibdata.rb +8 -0
- data/lib/relaton/ietf/bibitem.rb +8 -0
- data/lib/relaton/ietf/bibliography.rb +35 -0
- data/lib/relaton/ietf/bibxml_parser.rb +232 -0
- data/lib/relaton/ietf/data_fetcher.rb +561 -0
- data/lib/relaton/ietf/doctype.rb +9 -0
- data/lib/relaton/ietf/ext.rb +63 -0
- data/lib/relaton/ietf/item.rb +16 -0
- data/lib/relaton/ietf/item_base.rb +18 -0
- data/lib/relaton/ietf/item_data.rb +6 -0
- data/lib/relaton/ietf/processing_instructions.rb +79 -0
- data/lib/relaton/ietf/processor.rb +72 -0
- data/lib/relaton/ietf/relation.rb +9 -0
- data/lib/relaton/ietf/rfc/abstract.rb +19 -0
- data/lib/relaton/ietf/rfc/author.rb +21 -0
- data/lib/relaton/ietf/rfc/entry.rb +446 -0
- data/lib/relaton/ietf/rfc/entry_date.rb +21 -0
- data/lib/relaton/ietf/rfc/format.rb +19 -0
- data/lib/relaton/ietf/rfc/index.rb +46 -0
- data/lib/relaton/ietf/rfc/is_also.rb +21 -0
- data/lib/relaton/ietf/rfc/keywords.rb +19 -0
- data/lib/relaton/ietf/rfc/rfc_index_namespace.rb +11 -0
- data/lib/relaton/ietf/scraper.rb +101 -0
- data/lib/relaton/ietf/util.rb +8 -0
- data/lib/relaton/ietf/wg_name_resolver.rb +42 -0
- data/lib/relaton/ietf.rb +30 -0
- data/lib/relaton/iho/bibdata.rb +8 -0
- data/lib/relaton/iho/bibitem.rb +8 -0
- data/lib/relaton/iho/bibliography.rb +114 -0
- data/lib/relaton/iho/comment_period.rb +13 -0
- data/lib/relaton/iho/docidentifier.rb +31 -0
- data/lib/relaton/iho/doctype.rb +10 -0
- data/lib/relaton/iho/ext.rb +20 -0
- data/lib/relaton/iho/hash_parser_v1.rb +144 -0
- data/lib/relaton/iho/item.rb +20 -0
- data/lib/relaton/iho/item_base.rb +18 -0
- data/lib/relaton/iho/item_data.rb +6 -0
- data/lib/relaton/iho/processor.rb +54 -0
- data/lib/relaton/iho/relation.rb +9 -0
- data/lib/relaton/iho/structured_identifier.rb +20 -0
- data/lib/relaton/iho/util.rb +8 -0
- data/lib/relaton/iho.rb +27 -0
- data/lib/relaton/index/config.rb +52 -0
- data/lib/relaton/index/file_io.rb +305 -0
- data/lib/relaton/index/file_storage.rb +66 -0
- data/lib/relaton/index/pool.rb +46 -0
- data/lib/relaton/index/shard_source.rb +201 -0
- data/lib/relaton/index/type.rb +210 -0
- data/lib/relaton/index/util.rb +18 -0
- data/lib/relaton/index.rb +61 -0
- data/lib/relaton/isbn/isbn.rb +61 -0
- data/lib/relaton/isbn/open_library.rb +43 -0
- data/lib/relaton/isbn/parser.rb +88 -0
- data/lib/relaton/isbn/processor.rb +48 -0
- data/lib/relaton/isbn/util.rb +8 -0
- data/lib/relaton/isbn.rb +19 -0
- data/lib/relaton/iso/bibliography.rb +412 -0
- data/lib/relaton/iso/data_fetcher.rb +338 -0
- data/lib/relaton/iso/data_parser.rb +458 -0
- data/lib/relaton/iso/hash_parser_v1.rb +177 -0
- data/lib/relaton/iso/hit.rb +57 -0
- data/lib/relaton/iso/hit_collection.rb +196 -0
- data/lib/relaton/iso/item_data.rb +50 -0
- data/lib/relaton/iso/model/bibdata.rb +10 -0
- data/lib/relaton/iso/model/bibitem.rb +8 -0
- data/lib/relaton/iso/model/contributor.rb +6 -0
- data/lib/relaton/iso/model/contributor_info.rb +9 -0
- data/lib/relaton/iso/model/docidentifier.rb +146 -0
- data/lib/relaton/iso/model/doctype.rb +13 -0
- data/lib/relaton/iso/model/ext.rb +35 -0
- data/lib/relaton/iso/model/item.rb +17 -0
- data/lib/relaton/iso/model/item_base.rb +22 -0
- data/lib/relaton/iso/model/organization.rb +9 -0
- data/lib/relaton/iso/model/project_number.rb +22 -0
- data/lib/relaton/iso/model/relation.rb +9 -0
- data/lib/relaton/iso/model/stagename.rb +14 -0
- data/lib/relaton/iso/model/structured_identifier.rb +31 -0
- data/lib/relaton/iso/processor.rb +85 -0
- data/lib/relaton/iso/scraper.rb +635 -0
- data/lib/relaton/iso/type/pubid.rb +50 -0
- data/lib/relaton/iso/util.rb +8 -0
- data/lib/relaton/iso.rb +30 -0
- data/lib/relaton/itu/bibliography.rb +95 -0
- data/lib/relaton/itu/data_crawler_r.rb +664 -0
- data/lib/relaton/itu/data_fetcher.rb +550 -0
- data/lib/relaton/itu/data_merge_r.rb +149 -0
- data/lib/relaton/itu/data_parser_r.rb +214 -0
- data/lib/relaton/itu/data_parser_t.rb +228 -0
- data/lib/relaton/itu/family_cache.rb +177 -0
- data/lib/relaton/itu/governor.rb +56 -0
- data/lib/relaton/itu/hit.rb +28 -0
- data/lib/relaton/itu/hit_collection.rb +299 -0
- data/lib/relaton/itu/item_data.rb +6 -0
- data/lib/relaton/itu/model/approval_stage.rb +13 -0
- data/lib/relaton/itu/model/bibdata.rb +8 -0
- data/lib/relaton/itu/model/bibitem.rb +8 -0
- data/lib/relaton/itu/model/docidentifier.rb +75 -0
- data/lib/relaton/itu/model/doctype.rb +13 -0
- data/lib/relaton/itu/model/ext.rb +47 -0
- data/lib/relaton/itu/model/item.rb +13 -0
- data/lib/relaton/itu/model/meeting.rb +13 -0
- data/lib/relaton/itu/model/meeting_date.rb +15 -0
- data/lib/relaton/itu/model/question.rb +13 -0
- data/lib/relaton/itu/model/recommendation_status.rb +11 -0
- data/lib/relaton/itu/model/structured_identifier.rb +38 -0
- data/lib/relaton/itu/processor.rb +72 -0
- data/lib/relaton/itu/pubid.rb +199 -0
- data/lib/relaton/itu/radio_regulations_parser.rb +70 -0
- data/lib/relaton/itu/recommendation_fields.rb +334 -0
- data/lib/relaton/itu/recommendation_parser.rb +30 -0
- data/lib/relaton/itu/scraper.rb +203 -0
- data/lib/relaton/itu/util.rb +8 -0
- data/lib/relaton/itu.rb +34 -0
- data/lib/relaton/jcgm/bibdata.rb +8 -0
- data/lib/relaton/jcgm/bibitem.rb +8 -0
- data/lib/relaton/jcgm/bibliography.rb +97 -0
- data/lib/relaton/jcgm/data_fetcher.rb +81 -0
- data/lib/relaton/jcgm/docidentifier.rb +102 -0
- data/lib/relaton/jcgm/doctype.rb +12 -0
- data/lib/relaton/jcgm/ext.rb +23 -0
- data/lib/relaton/jcgm/item.rb +20 -0
- data/lib/relaton/jcgm/item_base.rb +18 -0
- data/lib/relaton/jcgm/item_data.rb +6 -0
- data/lib/relaton/jcgm/meetings_parser.rb +175 -0
- data/lib/relaton/jcgm/processor.rb +71 -0
- data/lib/relaton/jcgm/relation.rb +9 -0
- data/lib/relaton/jcgm/structured_identifier.rb +40 -0
- data/lib/relaton/jcgm/util.rb +8 -0
- data/lib/relaton/jcgm.rb +24 -0
- data/lib/relaton/jis/bibdata.rb +8 -0
- data/lib/relaton/jis/bibitem.rb +8 -0
- data/lib/relaton/jis/bibliography.rb +73 -0
- data/lib/relaton/jis/data_fetcher.rb +183 -0
- data/lib/relaton/jis/docidentifier.rb +120 -0
- data/lib/relaton/jis/doctype.rb +9 -0
- data/lib/relaton/jis/ext.rb +13 -0
- data/lib/relaton/jis/hit.rb +88 -0
- data/lib/relaton/jis/hit_collection.rb +128 -0
- data/lib/relaton/jis/item.rb +22 -0
- data/lib/relaton/jis/item_base.rb +26 -0
- data/lib/relaton/jis/item_data.rb +8 -0
- data/lib/relaton/jis/processor.rb +55 -0
- data/lib/relaton/jis/relation.rb +11 -0
- data/lib/relaton/jis/scraper.rb +232 -0
- data/lib/relaton/jis/structured_identifier.rb +13 -0
- data/lib/relaton/jis/util.rb +8 -0
- data/lib/relaton/jis.rb +32 -0
- data/lib/relaton/logger/channels/gh_issue.rb +143 -0
- data/lib/relaton/logger/config.rb +34 -0
- data/lib/relaton/logger/formatter_json.rb +8 -0
- data/lib/relaton/logger/formatter_string.rb +12 -0
- data/lib/relaton/logger/log.rb +64 -0
- data/lib/relaton/logger/log_device.rb +27 -0
- data/lib/relaton/logger/pool.rb +24 -0
- data/lib/relaton/logger.rb +18 -0
- data/lib/relaton/nist/bibdata.rb +8 -0
- data/lib/relaton/nist/bibitem.rb +8 -0
- data/lib/relaton/nist/bibliography.rb +191 -0
- data/lib/relaton/nist/comment_period.rb +15 -0
- data/lib/relaton/nist/data_fetcher.rb +134 -0
- data/lib/relaton/nist/date.rb +7 -0
- data/lib/relaton/nist/docidentifier.rb +165 -0
- data/lib/relaton/nist/doctype.rb +7 -0
- data/lib/relaton/nist/ext.rb +16 -0
- data/lib/relaton/nist/hit.rb +18 -0
- data/lib/relaton/nist/hit_collection.rb +362 -0
- data/lib/relaton/nist/item.rb +19 -0
- data/lib/relaton/nist/item_base.rb +16 -0
- data/lib/relaton/nist/item_data.rb +6 -0
- data/lib/relaton/nist/mods_parser.rb +302 -0
- data/lib/relaton/nist/processor.rb +69 -0
- data/lib/relaton/nist/pubs_export.rb +69 -0
- data/lib/relaton/nist/relation.rb +10 -0
- data/lib/relaton/nist/scraper.rb +293 -0
- data/lib/relaton/nist/series.yaml +49 -0
- data/lib/relaton/nist/util.rb +8 -0
- data/lib/relaton/nist.rb +34 -0
- data/lib/relaton/oasis/bibdata.rb +8 -0
- data/lib/relaton/oasis/bibitem.rb +8 -0
- data/lib/relaton/oasis/bibliography.rb +201 -0
- data/lib/relaton/oasis/browser_agent.rb +71 -0
- data/lib/relaton/oasis/data_fetcher.rb +130 -0
- data/lib/relaton/oasis/data_parser.rb +305 -0
- data/lib/relaton/oasis/data_parser_utils.rb +330 -0
- data/lib/relaton/oasis/data_part_parser.rb +239 -0
- data/lib/relaton/oasis/docidentifier.rb +54 -0
- data/lib/relaton/oasis/doctype.rb +7 -0
- data/lib/relaton/oasis/ext.rb +19 -0
- data/lib/relaton/oasis/item.rb +14 -0
- data/lib/relaton/oasis/item_data.rb +6 -0
- data/lib/relaton/oasis/processor.rb +74 -0
- data/lib/relaton/oasis/util.rb +8 -0
- data/lib/relaton/oasis.rb +41 -0
- data/lib/relaton/ogc/bibdata.rb +8 -0
- data/lib/relaton/ogc/bibitem.rb +8 -0
- data/lib/relaton/ogc/bibliography.rb +64 -0
- data/lib/relaton/ogc/data_fetcher.rb +131 -0
- data/lib/relaton/ogc/docidentifier.rb +111 -0
- data/lib/relaton/ogc/doctype.rb +12 -0
- data/lib/relaton/ogc/ext.rb +15 -0
- data/lib/relaton/ogc/hit.rb +18 -0
- data/lib/relaton/ogc/hit_collection.rb +111 -0
- data/lib/relaton/ogc/item.rb +13 -0
- data/lib/relaton/ogc/item_data.rb +6 -0
- data/lib/relaton/ogc/processor.rb +59 -0
- data/lib/relaton/ogc/scraper.rb +225 -0
- data/lib/relaton/ogc/util.rb +8 -0
- data/lib/relaton/ogc.rb +30 -0
- data/lib/relaton/oiml/bibdata.rb +8 -0
- data/lib/relaton/oiml/bibitem.rb +8 -0
- data/lib/relaton/oiml/bibliography.rb +169 -0
- data/lib/relaton/oiml/docidentifier.rb +48 -0
- data/lib/relaton/oiml/doctype.rb +13 -0
- data/lib/relaton/oiml/ext.rb +42 -0
- data/lib/relaton/oiml/item.rb +20 -0
- data/lib/relaton/oiml/item_base.rb +18 -0
- data/lib/relaton/oiml/item_data.rb +6 -0
- data/lib/relaton/oiml/processor.rb +54 -0
- data/lib/relaton/oiml/relation.rb +9 -0
- data/lib/relaton/oiml/util.rb +8 -0
- data/lib/relaton/oiml.rb +24 -0
- data/lib/relaton/omg/bibdata.rb +8 -0
- data/lib/relaton/omg/bibitem.rb +8 -0
- data/lib/relaton/omg/bibliography.rb +31 -0
- data/lib/relaton/omg/docidentifier.rb +67 -0
- data/lib/relaton/omg/ext.rb +7 -0
- data/lib/relaton/omg/item.rb +9 -0
- data/lib/relaton/omg/item_data.rb +6 -0
- data/lib/relaton/omg/processor.rb +35 -0
- data/lib/relaton/omg/scraper.rb +186 -0
- data/lib/relaton/omg/util.rb +8 -0
- data/lib/relaton/omg.rb +25 -0
- data/lib/relaton/plateau/bibdata.rb +8 -0
- data/lib/relaton/plateau/bibitem.rb +8 -0
- data/lib/relaton/plateau/bibliography.rb +31 -0
- data/lib/relaton/plateau/data_fetcher.rb +176 -0
- data/lib/relaton/plateau/doctype.rb +7 -0
- data/lib/relaton/plateau/ext.rb +23 -0
- data/lib/relaton/plateau/handbook_parser.rb +102 -0
- data/lib/relaton/plateau/hit.rb +21 -0
- data/lib/relaton/plateau/hit_collection.rb +79 -0
- data/lib/relaton/plateau/item.rb +12 -0
- data/lib/relaton/plateau/item_data.rb +6 -0
- data/lib/relaton/plateau/parser.rb +101 -0
- data/lib/relaton/plateau/processor.rb +51 -0
- data/lib/relaton/plateau/technical_report_parser.rb +98 -0
- data/lib/relaton/plateau/util.rb +8 -0
- data/lib/relaton/plateau.rb +29 -0
- data/lib/relaton/sdo/config.rb +34 -0
- data/lib/relaton/sdo/fetcher.rb +52 -0
- data/lib/relaton/sdo/logo.rb +95 -0
- data/lib/relaton/sdo/name.rb +26 -0
- data/lib/relaton/sdo/organization.rb +71 -0
- data/lib/relaton/sdo/store.rb +49 -0
- data/lib/relaton/sdo.rb +29 -0
- data/lib/relaton/un/bibdata.rb +8 -0
- data/lib/relaton/un/bibitem.rb +8 -0
- data/lib/relaton/un/bibliography.rb +48 -0
- data/lib/relaton/un/doctype.rb +10 -0
- data/lib/relaton/un/ext.rb +30 -0
- data/lib/relaton/un/hit.rb +56 -0
- data/lib/relaton/un/hit_collection.rb +61 -0
- data/lib/relaton/un/item.rb +11 -0
- data/lib/relaton/un/item_data.rb +6 -0
- data/lib/relaton/un/parser.rb +108 -0
- data/lib/relaton/un/processor.rb +38 -0
- data/lib/relaton/un/session.rb +25 -0
- data/lib/relaton/un/token_generator.rb +105 -0
- data/lib/relaton/un/util.rb +8 -0
- data/lib/relaton/un/wasm/decoder.rb +434 -0
- data/lib/relaton/un/wasm/instance.rb +101 -0
- data/lib/relaton/un/wasm/interpreter.rb +613 -0
- data/lib/relaton/un/wasm/memory.rb +112 -0
- data/lib/relaton/un/wasm/module.rb +47 -0
- data/lib/relaton/un/wasm.rb +17 -0
- data/lib/relaton/un/wasm_v_bg.wasm +0 -0
- data/lib/relaton/un.rb +28 -0
- data/lib/relaton/version.rb +1 -1
- data/lib/relaton/w3c/bibdata.rb +8 -0
- data/lib/relaton/w3c/bibitem.rb +8 -0
- data/lib/relaton/w3c/bibliography.rb +174 -0
- data/lib/relaton/w3c/data_fetcher.rb +487 -0
- data/lib/relaton/w3c/data_parser.rb +379 -0
- data/lib/relaton/w3c/docidentifier.rb +48 -0
- data/lib/relaton/w3c/doctype.rb +7 -0
- data/lib/relaton/w3c/ext.rb +11 -0
- data/lib/relaton/w3c/governor.rb +32 -0
- data/lib/relaton/w3c/item.rb +15 -0
- data/lib/relaton/w3c/item_data.rb +6 -0
- data/lib/relaton/w3c/processor.rb +49 -0
- data/lib/relaton/w3c/pubid.rb +85 -0
- data/lib/relaton/w3c/safe_realize.rb +148 -0
- data/lib/relaton/w3c/util.rb +8 -0
- data/lib/relaton/w3c.rb +36 -0
- data/lib/relaton/xsf/bibdata.rb +8 -0
- data/lib/relaton/xsf/bibitem.rb +8 -0
- data/lib/relaton/xsf/bibliography.rb +84 -0
- data/lib/relaton/xsf/data_fetcher.rb +106 -0
- data/lib/relaton/xsf/docidentifier.rb +46 -0
- data/lib/relaton/xsf/hit.rb +17 -0
- data/lib/relaton/xsf/hit_collection.rb +52 -0
- data/lib/relaton/xsf/item.rb +13 -0
- data/lib/relaton/xsf/item_data.rb +6 -0
- data/lib/relaton/xsf/processor.rb +51 -0
- data/lib/relaton/xsf/util.rb +9 -0
- data/lib/relaton/xsf.rb +34 -0
- data/lib/relaton-core.rb +1 -0
- data/lib/relaton.rb +85 -0
- metadata +775 -161
- data/.github/workflows/rake.yml +0 -14
- data/.github/workflows/release.yml +0 -24
- data/.github/workflows/rubocop.yml +0 -48
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/CLAUDE.md +0 -78
- data/Gemfile +0 -29
- data/Rakefile +0 -6
- data/docs/CHANGELOG.adoc +0 -16
- data/docs/VERSIONING_POLICY.adoc +0 -38
- data/docs/navigation.adoc +0 -6
- data/lib/relaton/db/version.rb +0 -5
- data/relaton.gemspec +0 -72
- data/spec/relaton/config_spec.rb +0 -10
- data/spec/relaton/db_cache_spec.rb +0 -51
- data/spec/relaton/db_spec.rb +0 -567
- data/spec/relaton/registry_spec.rb +0 -178
- data/spec/relaton/util_spec.rb +0 -3
- data/spec/relaton_meta_spec.rb +0 -25
- data/spec/relaton_spec.rb +0 -800
- data/spec/spec_helper.rb +0 -45
- data/spec/support/gb_t_20223_2006.xml +0 -33
- data/spec/support/iso_111111119115_1.xml +0 -0
- data/spec/support/iso_19115_1.xml +0 -115
- data/spec/support/iso_19115_2.xml +0 -95
- data/spec/support/rfc_8341.xml +0 -46
- data/spec/vcr_cassetes/api_relaton_org.yml +0 -121
- data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +0 -140
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +0 -202
- data/spec/vcr_cassetes/cipm_meeting_43.yml +0 -1505
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +0 -729
- data/spec/vcr_cassetes/iso_111111119115_1.yml +0 -12951
- data/spec/vcr_cassetes/iso_19115_1.yml +0 -17334
- data/spec/vcr_cassetes/iso_19115_1_2.yml +0 -322
- data/spec/vcr_cassetes/iso_19115_1_std.yml +0 -17334
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +0 -185
- data/spec/vcr_cassetes/iso_19133_2005.yml +0 -144
- data/spec/vcr_cassetes/iso_combined_applied.yml +0 -318
- data/spec/vcr_cassetes/iso_combined_included.yml +0 -318
- data/spec/vcr_cassetes/ogc_19_025r1.yml +0 -374
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +0 -317
- data/spec/vcr_cassetes/rfc_8341.yml +0 -1278
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
module Relaton::Calconnect
|
|
2
|
+
class HitCollection < Relaton::Core::HitCollection
|
|
3
|
+
GHURL = "https://raw.githubusercontent.com/relaton/relaton-data-calconnect/refs/heads/v2/".freeze
|
|
4
|
+
|
|
5
|
+
# @param ref [Strig]
|
|
6
|
+
# @param year [String]
|
|
7
|
+
def initialize(ref, year = nil)
|
|
8
|
+
super
|
|
9
|
+
@array = search_index(ref).map { |row| Hit.new(row, self) }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
# @return [Relaton::Index::Type]
|
|
15
|
+
def index
|
|
16
|
+
Relaton::Index.find_or_create :CC, url: "#{GHURL}#{INDEXFILE}.zip",
|
|
17
|
+
file: "#{INDEXFILE}.yaml",
|
|
18
|
+
pubid_class: ::Pubid::Calconnect::Identifier
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
#
|
|
22
|
+
# The index rows matching a reference, most recent first.
|
|
23
|
+
#
|
|
24
|
+
# **The pubid is passed to `Index::Type#search`, not the string.**
|
|
25
|
+
# `search_candidates` narrows only when the argument is not a `String`, and
|
|
26
|
+
# a block alone never narrows — so the plain string this used to pass
|
|
27
|
+
# disabled the binary search however the index was built. `pubid_class:` on
|
|
28
|
+
# the index alone fixes nothing; both had to change together.
|
|
29
|
+
#
|
|
30
|
+
# This also ends the substring scan the old string search did, which was
|
|
31
|
+
# silently ambiguous: `CC/DIR 1000` answered with all five `CC/DIR 1000x`
|
|
32
|
+
# documents and `CC/A 1` with every `CC/A 1xxx`. A number now matches
|
|
33
|
+
# exactly, and a leading zero is significant (`CC/A 0001` is not `CC/A 1`).
|
|
34
|
+
#
|
|
35
|
+
# The rows are selected with pubid's subset match `pubid === row`, the
|
|
36
|
+
# default of `Index::Type#search`. A date that the reference omits matches
|
|
37
|
+
# any value. pubid declares `series` strict for CalConnect, so the series
|
|
38
|
+
# keeps `CC/CD 51016` and `CC/WD 51016` apart, and a series-less
|
|
39
|
+
# `CC 36010` does not match `CC/WD 36010`.
|
|
40
|
+
#
|
|
41
|
+
# @param ref [String]
|
|
42
|
+
# @return [Array<Hash>] matching index rows
|
|
43
|
+
#
|
|
44
|
+
def search_index(ref)
|
|
45
|
+
pubid = parse_ref ref
|
|
46
|
+
return [] unless pubid
|
|
47
|
+
|
|
48
|
+
index.search(pubid).sort_by { |row| [recency_key(row[:id]), row[:file]] }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
#
|
|
52
|
+
# Parse a user reference into a `Pubid::Calconnect::Identifier`, or nil.
|
|
53
|
+
#
|
|
54
|
+
# A reference pubid rejects is a **miss, not an error**: this returns nil
|
|
55
|
+
# outside the transport rescue in `Bibliography.search`, so it never becomes
|
|
56
|
+
# a `Relaton::RequestError`.
|
|
57
|
+
#
|
|
58
|
+
# @param ref [String]
|
|
59
|
+
# @return [Pubid::Calconnect::Identifier, nil]
|
|
60
|
+
#
|
|
61
|
+
# An unrecognized reference **raises**; like ISO, ETSI and 3GPP we let it
|
|
62
|
+
# propagate. relaton-cli rescues `Pubid::Errors::Error` and renders
|
|
63
|
+
# `"..." is not a recognized standards identifier`
|
|
64
|
+
# (`gems/relaton-cli/lib/relaton/cli/command.rb:324`), and `Db#fetch`
|
|
65
|
+
# logs it through the `StandardError` arm at `lib/relaton/db.rb:122`.
|
|
66
|
+
# Rescuing here would collapse "this identifier is malformed" into "no
|
|
67
|
+
# such document", leaving a caller unable to tell them apart.
|
|
68
|
+
def parse_ref(ref)
|
|
69
|
+
::Pubid::Calconnect::Identifier.parse ref.to_s.strip
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
#
|
|
73
|
+
# Sort key placing the most recent document first.
|
|
74
|
+
#
|
|
75
|
+
# The index is sorted by number, so rows sharing a number arrive in no
|
|
76
|
+
# meaningful order — without this, `Bibliography.get "CC/S 0601"` would
|
|
77
|
+
# answer with an arbitrary one of the 2005 and 2006 documents. Segments are
|
|
78
|
+
# compared as integers and negated for descending order; an absent month or
|
|
79
|
+
# day sorts as 0, which is right because only one row in the corpus carries
|
|
80
|
+
# either.
|
|
81
|
+
#
|
|
82
|
+
# @param id [Pubid::Calconnect::Identifier]
|
|
83
|
+
# @return [Array<Integer>]
|
|
84
|
+
#
|
|
85
|
+
def recency_key(id)
|
|
86
|
+
date = id.date
|
|
87
|
+
return [0, 0, 0] unless date
|
|
88
|
+
|
|
89
|
+
[date.year, date.month, date.day].map { |part| -part.to_i }
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Calconnect
|
|
3
|
+
class ItemData < Relaton::Bib::ItemData
|
|
4
|
+
def create_id(without_date: false)
|
|
5
|
+
docid = docidentifier.find(&:primary) || docidentifier.first
|
|
6
|
+
return unless docid
|
|
7
|
+
|
|
8
|
+
self.id = docid.content.gsub(/\W+/, "")
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Calconnect
|
|
3
|
+
class Doctype < Bib::Doctype
|
|
4
|
+
TYPES = %W[
|
|
5
|
+
directive guide specification standard report administrative amendment technical\scorrigendum advisory
|
|
6
|
+
].freeze
|
|
7
|
+
|
|
8
|
+
attribute :type, :string, values: TYPES
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "relaton/bib"
|
|
2
|
+
require_relative "../item_data"
|
|
3
|
+
require_relative "../docidentifier"
|
|
4
|
+
require_relative "ext"
|
|
5
|
+
|
|
6
|
+
module Relaton
|
|
7
|
+
module Calconnect
|
|
8
|
+
class Item < Bib::Item
|
|
9
|
+
model ItemData
|
|
10
|
+
|
|
11
|
+
# The flavor's own Docidentifier, so every parsed record carries a
|
|
12
|
+
# `#pubid` for `DataFetcher#index_id` to key the index-v2 on. Bibitem and
|
|
13
|
+
# Bibdata subclass Item, so they inherit it.
|
|
14
|
+
attribute :docidentifier, Docidentifier, collection: true,
|
|
15
|
+
initialize_empty: true
|
|
16
|
+
|
|
17
|
+
attribute :ext, Ext
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
@pubid_flavor = :Calconnect
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @param code [String]
|
|
17
|
+
# @param date [String, nil] year
|
|
18
|
+
# @param opts [Hash]
|
|
19
|
+
# @return [Relaton::Calconnect::ItemData, nil]
|
|
20
|
+
def get(code, date, opts)
|
|
21
|
+
require_relative "../calconnect"
|
|
22
|
+
Bibliography.get(code, date, opts)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# Fetch all the documents from a source
|
|
27
|
+
#
|
|
28
|
+
# @param [String] _source source name
|
|
29
|
+
# @param [Hash] opts
|
|
30
|
+
# @option opts [String] :output directory to output documents
|
|
31
|
+
# @option opts [String] :format
|
|
32
|
+
#
|
|
33
|
+
def fetch_data(_source, opts)
|
|
34
|
+
require_relative "data_fetcher"
|
|
35
|
+
DataFetcher.fetch(**opts)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# @param xml [String]
|
|
39
|
+
# @return [Relaton::Calconnect::ItemData]
|
|
40
|
+
def from_xml(xml)
|
|
41
|
+
require_relative "../calconnect"
|
|
42
|
+
Item.from_xml xml
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# @param hash [Hash]
|
|
46
|
+
# @return [Relaton::Calconnect::ItemData]
|
|
47
|
+
def hash_to_bib(hash)
|
|
48
|
+
require_relative "../calconnect"
|
|
49
|
+
Item.from_yaml hash.to_yaml
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Returns hash of XML grammar
|
|
53
|
+
# @return [String]
|
|
54
|
+
def grammar_hash
|
|
55
|
+
require_relative "../calconnect"
|
|
56
|
+
@grammar_hash ||= ::Relaton::Calconnect.grammar_hash
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
#
|
|
60
|
+
# Remove index file
|
|
61
|
+
#
|
|
62
|
+
# `url: true` names the cached file. No `pubid_class:`: `Type#remove_file`
|
|
63
|
+
# deletes the file and never reads the index.
|
|
64
|
+
#
|
|
65
|
+
def remove_index_file
|
|
66
|
+
require_relative "../calconnect"
|
|
67
|
+
Relaton::Index.find_or_create(
|
|
68
|
+
:CC, url: true, file: "#{INDEXFILE}.yaml"
|
|
69
|
+
).remove_file
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
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,36 @@
|
|
|
1
|
+
# Not lazy: DataFetcher names ::Pubid::Calconnect::Identifier as the index
|
|
2
|
+
# `pubid_class:`, and Docidentifier parses every docid through it.
|
|
3
|
+
# (The ECMA/IANA/IHO/OGC form; spec/relaton/lazy_loading_spec.rb guards that
|
|
4
|
+
# this file is not itself loaded when a Db is built.)
|
|
5
|
+
require "pubid"
|
|
6
|
+
require "relaton/index"
|
|
7
|
+
require "relaton/core"
|
|
8
|
+
require_relative "version"
|
|
9
|
+
require_relative "calconnect/model/item"
|
|
10
|
+
require_relative "calconnect/util"
|
|
11
|
+
require_relative "calconnect/model/bibitem"
|
|
12
|
+
require_relative "calconnect/model/bibdata"
|
|
13
|
+
require_relative "calconnect/bibliography"
|
|
14
|
+
require_relative "calconnect/hit_collection"
|
|
15
|
+
require_relative "calconnect/hit"
|
|
16
|
+
require_relative "calconnect/scraper"
|
|
17
|
+
|
|
18
|
+
module Relaton
|
|
19
|
+
module Calconnect
|
|
20
|
+
# The one index this flavor builds and reads: pubid-keyed rows
|
|
21
|
+
# (`_type: pubid:calconnect:standard`), via
|
|
22
|
+
# `pubid_class: ::Pubid::Calconnect::Identifier`.
|
|
23
|
+
# `relaton-data-calconnect`'s crawler derives the legacy `index-v1` from
|
|
24
|
+
# these rows for released consumers, so it is not produced or read here.
|
|
25
|
+
INDEXFILE = "index-v2".freeze
|
|
26
|
+
|
|
27
|
+
# Returns hash of XML reammar
|
|
28
|
+
# @return [String]
|
|
29
|
+
def self.grammar_hash
|
|
30
|
+
# gem_path = File.expand_path "..", __dir__
|
|
31
|
+
# grammars_path = File.join gem_path, "grammars", "*"
|
|
32
|
+
# grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
|
33
|
+
Digest::MD5.hexdigest Relaton::VERSION # grammars
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
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,252 @@
|
|
|
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
|
+
pubid = bib.docidentifier.first.pubid
|
|
105
|
+
return unless pubid # unparseable content: no relation to search
|
|
106
|
+
|
|
107
|
+
bibid = pubid.exclude(:language)
|
|
108
|
+
if bibid == pubid
|
|
109
|
+
search_translations bibid, bib # no language: this is an instance
|
|
110
|
+
else
|
|
111
|
+
search_relations bibid, bib # has a language: this is a translation
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
#
|
|
116
|
+
# Search instance or translation relation
|
|
117
|
+
#
|
|
118
|
+
# @param [Pubid::Ccsds::Identifier] bibid_pid language-less instance id
|
|
119
|
+
# @param [Relaton::Ccsds::ItemData] bib instance or translation bibitem
|
|
120
|
+
#
|
|
121
|
+
# @return [void]
|
|
122
|
+
#
|
|
123
|
+
def search_relations(bibid_pid, bib)
|
|
124
|
+
# search(bibid_pid) narrows candidates by number via binary search first.
|
|
125
|
+
index.search(bibid_pid) do |row|
|
|
126
|
+
# Match language-agnostically: `bibid_pid` is language-less, so a
|
|
127
|
+
# translated row and the instance both match. `===` cannot do this —
|
|
128
|
+
# pubid declares CCSDS `language` `subset_strict`, so a nil reference
|
|
129
|
+
# language means "has none" instead of "any". Mirrors `HitCollection`.
|
|
130
|
+
next unless row[:id].exclude(:language) == bibid_pid
|
|
131
|
+
next if row[:id] == bib.docidentifier.first.pubid # exclude the document's own row
|
|
132
|
+
|
|
133
|
+
create_relations bib, row[:file]
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def search_translations(bibid_pid, bib)
|
|
138
|
+
# will call create_instance_relation if
|
|
139
|
+
# there are same identifiers in index but with word "Translated"
|
|
140
|
+
# search(bibid_pid) narrows candidates by number via binary search first.
|
|
141
|
+
index.search(bibid_pid) do |row|
|
|
142
|
+
# Only translated rows (`row[:id].language`), matched language-agnostically.
|
|
143
|
+
next unless row[:id].language && row[:id].exclude(:language) == bibid_pid
|
|
144
|
+
|
|
145
|
+
create_instance_relation bib, row[:file]
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
#
|
|
150
|
+
# Create translation or instance relation and save to file
|
|
151
|
+
#
|
|
152
|
+
# @param [Relaton::Ccsds::ItemData] bib bibliographic item
|
|
153
|
+
# @param [String] file translation or instance file
|
|
154
|
+
#
|
|
155
|
+
# @return [void]
|
|
156
|
+
#
|
|
157
|
+
def create_relations(bib, file)
|
|
158
|
+
inst = parse_file file
|
|
159
|
+
type1, type2 = translation_relation_types(inst)
|
|
160
|
+
create_relation(inst, type1) { |rel| bib.relation << rel }
|
|
161
|
+
create_relation(bib, type2) { |rel| inst.relation << rel }
|
|
162
|
+
File.write file, serialize(inst), encoding: "UTF-8"
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def parse_file(file)
|
|
166
|
+
case @format
|
|
167
|
+
when "yaml" then Item.from_yaml File.read(file, encoding: "UTF-8")
|
|
168
|
+
when "xml" then Item.from_xml File.read(file, encoding: "UTF-8")
|
|
169
|
+
else
|
|
170
|
+
raise "Unknown format #{@format}"
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
#
|
|
175
|
+
# Translation or instance relation types
|
|
176
|
+
#
|
|
177
|
+
# @param [Relaton::Ccsds::ItemData] bib bibliographic item
|
|
178
|
+
#
|
|
179
|
+
# @return [Array<String>] relation types
|
|
180
|
+
#
|
|
181
|
+
def translation_relation_types(bib)
|
|
182
|
+
if bib.docidentifier.first.content.match?(TRRGX)
|
|
183
|
+
["hasTranslation"] * 2
|
|
184
|
+
else
|
|
185
|
+
["instanceOf", "hasInstance"]
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
#
|
|
190
|
+
# Create instance relation and save to file
|
|
191
|
+
#
|
|
192
|
+
# @param [Relaton::Ccsds::Item] bib bibliographic item
|
|
193
|
+
# @param [String] file file name
|
|
194
|
+
#
|
|
195
|
+
# @return [void]
|
|
196
|
+
#
|
|
197
|
+
def create_instance_relation(bib, file)
|
|
198
|
+
inst = parse_file file
|
|
199
|
+
create_relation(inst, "hasInstance") { |rel| bib.relation << rel }
|
|
200
|
+
create_relation(bib, "instanceOf") { |rel| inst.relation << rel }
|
|
201
|
+
File.write file, serialize(inst), encoding: "UTF-8"
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
#
|
|
205
|
+
# Create relation
|
|
206
|
+
#
|
|
207
|
+
# @param [Relaton::Ccsds::Item] bib the related bibliographic item
|
|
208
|
+
# @param [String] type type of relation
|
|
209
|
+
#
|
|
210
|
+
# @return [Relaton::Bib::Relation] relation
|
|
211
|
+
#
|
|
212
|
+
def create_relation(bib, type)
|
|
213
|
+
bib_docid = bib.docidentifier.first
|
|
214
|
+
return unless bib_docid
|
|
215
|
+
|
|
216
|
+
docid = Bib::Docidentifier.from_yaml(bib_docid.to_yaml)
|
|
217
|
+
rel = Relaton::Bib::ItemData.new docidentifier: [docid], formattedref: Relaton::Bib::Formattedref.new(content: bib_docid.content.dup)
|
|
218
|
+
yield Relaton::Bib::Relation.new(type: type, bibitem: rel)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
#
|
|
222
|
+
# Merge identical documents with different links (updaes given bibitem)
|
|
223
|
+
#
|
|
224
|
+
# @param [Relaton::Ccsds::Item] bib bibliographic item
|
|
225
|
+
# @param [String] file path to existing document
|
|
226
|
+
#
|
|
227
|
+
# @return [void]
|
|
228
|
+
#
|
|
229
|
+
def merge_links(bib, file) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
230
|
+
# skip merging when new file
|
|
231
|
+
unless @files.include?(file)
|
|
232
|
+
@files << file
|
|
233
|
+
return
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
puts "(#{file}) file already exists. Trying to merge links ..."
|
|
237
|
+
|
|
238
|
+
bib2 = parse_file file
|
|
239
|
+
bib2.source.each do |src|
|
|
240
|
+
next if bib.source.any? { |s| s.type == src.type }
|
|
241
|
+
|
|
242
|
+
bib.source << src
|
|
243
|
+
end
|
|
244
|
+
Util.info "links are merged.", key: file
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def to_yaml(bib) = bib.to_yaml
|
|
248
|
+
def to_xml(bib) = bib.to_xml(bibdata: true)
|
|
249
|
+
def to_bibxml(bib) = bib.to_rfcxml
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
end
|