relaton 2.1.0 → 3.0.0.pre.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{docs/README.adoc → README.adoc} +109 -38
- data/lib/relaton/3gpp/bibdata.rb +9 -0
- data/lib/relaton/3gpp/bibitem.rb +9 -0
- data/lib/relaton/3gpp/bibliography.rb +48 -0
- data/lib/relaton/3gpp/data_fetcher.rb +255 -0
- data/lib/relaton/3gpp/doctype.rb +9 -0
- data/lib/relaton/3gpp/ext.rb +31 -0
- data/lib/relaton/3gpp/item.rb +12 -0
- data/lib/relaton/3gpp/item_data.rb +15 -0
- data/lib/relaton/3gpp/parser.rb +400 -0
- data/lib/relaton/3gpp/processor.rb +68 -0
- data/lib/relaton/3gpp/release.rb +34 -0
- data/lib/relaton/3gpp/util.rb +8 -0
- data/lib/relaton/3gpp.rb +25 -0
- data/lib/relaton/bib/converter/asciibib/to_asciibib.rb +663 -0
- data/lib/relaton/bib/converter/asciibib.rb +13 -0
- data/lib/relaton/bib/converter/bibtex/from_bibtex.rb +245 -0
- data/lib/relaton/bib/converter/bibtex/to_bibtex.rb +341 -0
- data/lib/relaton/bib/converter/bibtex.rb +23 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml.rb +386 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml_referencegroup.rb +71 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml.rb +308 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml_referencegroup.rb +52 -0
- data/lib/relaton/bib/converter/bibxml.rb +51 -0
- data/lib/relaton/bib/hash_parser_v1.rb +767 -0
- data/lib/relaton/bib/item_data.rb +229 -0
- data/lib/relaton/bib/model/abstract.rb +16 -0
- data/lib/relaton/bib/model/address.rb +22 -0
- data/lib/relaton/bib/model/affiliation.rb +16 -0
- data/lib/relaton/bib/model/bibdata.rb +11 -0
- data/lib/relaton/bib/model/bibdata_shared.rb +12 -0
- data/lib/relaton/bib/model/bibitem.rb +11 -0
- data/lib/relaton/bib/model/bibitem_shared.rb +12 -0
- data/lib/relaton/bib/model/contact.rb +18 -0
- data/lib/relaton/bib/model/contribution_info.rb +15 -0
- data/lib/relaton/bib/model/contributor.rb +29 -0
- data/lib/relaton/bib/model/copyright.rb +27 -0
- data/lib/relaton/bib/model/date.rb +31 -0
- data/lib/relaton/bib/model/depiction.rb +16 -0
- data/lib/relaton/bib/model/docidentifier.rb +34 -0
- data/lib/relaton/bib/model/doctype.rb +14 -0
- data/lib/relaton/bib/model/edition.rb +14 -0
- data/lib/relaton/bib/model/ext.rb +39 -0
- data/lib/relaton/bib/model/extent.rb +16 -0
- data/lib/relaton/bib/model/formattedref.rb +43 -0
- data/lib/relaton/bib/model/full_name_type.rb +64 -0
- data/lib/relaton/bib/model/fullname.rb +11 -0
- data/lib/relaton/bib/model/ics.rb +49 -0
- data/lib/relaton/bib/model/image.rb +28 -0
- data/lib/relaton/bib/model/item.rb +96 -0
- data/lib/relaton/bib/model/item_base.rb +20 -0
- data/lib/relaton/bib/model/item_shared.rb +88 -0
- data/lib/relaton/bib/model/keyword.rb +30 -0
- data/lib/relaton/bib/model/locality.rb +18 -0
- data/lib/relaton/bib/model/locality_stack.rb +14 -0
- data/lib/relaton/bib/model/localized_string.rb +48 -0
- data/lib/relaton/bib/model/localized_string_attrs.rb +24 -0
- data/lib/relaton/bib/model/logo.rb +14 -0
- data/lib/relaton/bib/model/medium.rb +22 -0
- data/lib/relaton/bib/model/note.rb +16 -0
- data/lib/relaton/bib/model/organization.rb +13 -0
- data/lib/relaton/bib/model/organization_type.rb +42 -0
- data/lib/relaton/bib/model/person.rb +36 -0
- data/lib/relaton/bib/model/phone.rb +14 -0
- data/lib/relaton/bib/model/place.rb +33 -0
- data/lib/relaton/bib/model/price.rb +14 -0
- data/lib/relaton/bib/model/relation.rb +43 -0
- data/lib/relaton/bib/model/series.rb +34 -0
- data/lib/relaton/bib/model/size.rb +23 -0
- data/lib/relaton/bib/model/source_locality_stack.rb +14 -0
- data/lib/relaton/bib/model/status.rb +27 -0
- data/lib/relaton/bib/model/structured_identifier.rb +48 -0
- data/lib/relaton/bib/model/subdivision.rb +16 -0
- data/lib/relaton/bib/model/title.rb +56 -0
- data/lib/relaton/bib/model/type/plain_date.rb +16 -0
- data/lib/relaton/bib/model/type/string_date.rb +48 -0
- data/lib/relaton/bib/model/uri.rb +18 -0
- data/lib/relaton/bib/model/validity.rb +16 -0
- data/lib/relaton/bib/model/version.rb +43 -0
- data/lib/relaton/bib/namespace_helper.rb +21 -0
- data/lib/relaton/bib/sanitizer.rb +68 -0
- data/lib/relaton/bib/util.rb +18 -0
- data/lib/relaton/bib/versions.json +35 -0
- data/lib/relaton/bib.rb +48 -0
- data/lib/relaton/bipm/bibliography.rb +82 -0
- data/lib/relaton/bipm/converter/asciibib.rb +64 -0
- data/lib/relaton/bipm/data_fetcher.rb +57 -0
- data/lib/relaton/bipm/data_outcomes_parser.rb +657 -0
- data/lib/relaton/bipm/id_parser.rb +277 -0
- data/lib/relaton/bipm/item_data.rb +47 -0
- data/lib/relaton/bipm/model/bibdata.rb +9 -0
- data/lib/relaton/bipm/model/bibitem.rb +9 -0
- data/lib/relaton/bipm/model/comment_period.rb +13 -0
- data/lib/relaton/bipm/model/doctype.rb +12 -0
- data/lib/relaton/bipm/model/ext.rb +38 -0
- data/lib/relaton/bipm/model/item.rb +11 -0
- data/lib/relaton/bipm/model/structured_identifier.rb +15 -0
- data/lib/relaton/bipm/processor.rb +69 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/affiliations.rb +111 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/fetcher.rb +174 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/niso_jats_parser.rb +353 -0
- data/lib/relaton/bipm/si_brochure_parser.rb +186 -0
- data/lib/relaton/bipm/util.rb +8 -0
- data/lib/relaton/bipm.rb +32 -0
- data/lib/relaton/bsi/bibliography.rb +124 -0
- data/lib/relaton/bsi/hit.rb +14 -0
- data/lib/relaton/bsi/hit_collection.rb +114 -0
- data/lib/relaton/bsi/item_data.rb +13 -0
- data/lib/relaton/bsi/model/bibdata.rb +8 -0
- data/lib/relaton/bsi/model/bibitem.rb +8 -0
- data/lib/relaton/bsi/model/docidentifier.rb +9 -0
- data/lib/relaton/bsi/model/doctype.rb +14 -0
- data/lib/relaton/bsi/model/ext.rb +17 -0
- data/lib/relaton/bsi/model/item.rb +17 -0
- data/lib/relaton/bsi/model/item_base.rb +22 -0
- data/lib/relaton/bsi/model/relation.rb +9 -0
- data/lib/relaton/bsi/processor.rb +42 -0
- data/lib/relaton/bsi/schema.json +24882 -0
- data/lib/relaton/bsi/scraper.rb +288 -0
- data/lib/relaton/bsi/util.rb +8 -0
- data/lib/relaton/bsi.rb +25 -0
- data/lib/relaton/calconnect/bibliography.rb +95 -0
- data/lib/relaton/calconnect/data_fetcher.rb +106 -0
- data/lib/relaton/calconnect/hit.rb +14 -0
- data/lib/relaton/calconnect/hit_collection.rb +84 -0
- data/lib/relaton/calconnect/item_data.rb +12 -0
- data/lib/relaton/calconnect/model/bibdata.rb +8 -0
- data/lib/relaton/calconnect/model/bibitem.rb +8 -0
- data/lib/relaton/calconnect/model/doctype.rb +11 -0
- data/lib/relaton/calconnect/model/ext.rb +11 -0
- data/lib/relaton/calconnect/model/item.rb +13 -0
- data/lib/relaton/calconnect/processor.rb +66 -0
- data/lib/relaton/calconnect/scraper.rb +87 -0
- data/lib/relaton/calconnect/util.rb +8 -0
- data/lib/relaton/calconnect.rb +26 -0
- data/lib/relaton/ccsds/bibliography.rb +63 -0
- data/lib/relaton/ccsds/data/fetcher.rb +247 -0
- data/lib/relaton/ccsds/data/iso_references.rb +30 -0
- data/lib/relaton/ccsds/data/parser.rb +194 -0
- data/lib/relaton/ccsds/hit.rb +24 -0
- data/lib/relaton/ccsds/hit_collection.rb +42 -0
- data/lib/relaton/ccsds/item_data.rb +9 -0
- data/lib/relaton/ccsds/model/bibdata.rb +8 -0
- data/lib/relaton/ccsds/model/bibitem.rb +8 -0
- data/lib/relaton/ccsds/model/doctype.rb +9 -0
- data/lib/relaton/ccsds/model/ext.rb +19 -0
- data/lib/relaton/ccsds/model/item.rb +13 -0
- data/lib/relaton/ccsds/processor.rb +68 -0
- data/lib/relaton/ccsds/util.rb +10 -0
- data/lib/relaton/ccsds.rb +33 -0
- data/lib/relaton/cen/bibliography.rb +121 -0
- data/lib/relaton/cen/committees.yaml +66 -0
- data/lib/relaton/cen/hit.rb +16 -0
- data/lib/relaton/cen/hit_collection.rb +68 -0
- data/lib/relaton/cen/item_data.rb +7 -0
- data/lib/relaton/cen/model/bibdata.rb +8 -0
- data/lib/relaton/cen/model/bibitem.rb +8 -0
- data/lib/relaton/cen/model/docidentifier.rb +9 -0
- data/lib/relaton/cen/model/ext.rb +11 -0
- data/lib/relaton/cen/model/item.rb +14 -0
- data/lib/relaton/cen/model/structured_identifier.rb +9 -0
- data/lib/relaton/cen/processor.rb +40 -0
- data/lib/relaton/cen/scraper.rb +210 -0
- data/lib/relaton/cen/util.rb +8 -0
- data/lib/relaton/cen.rb +29 -0
- data/lib/relaton/cie/bibdata.rb +8 -0
- data/lib/relaton/cie/bibitem.rb +8 -0
- data/lib/relaton/cie/bibliography.rb +31 -0
- data/lib/relaton/cie/data_fetcher.rb +355 -0
- data/lib/relaton/cie/ext.rb +7 -0
- data/lib/relaton/cie/item.rb +11 -0
- data/lib/relaton/cie/item_data.rb +6 -0
- data/lib/relaton/cie/processor.rb +66 -0
- data/lib/relaton/cie/scrapper.rb +39 -0
- data/lib/relaton/cie/util.rb +8 -0
- data/lib/relaton/cie.rb +28 -0
- data/lib/relaton/core/array_wrapper.rb +20 -0
- data/lib/relaton/core/data_fetcher.rb +97 -0
- data/lib/relaton/core/date_parser.rb +42 -0
- data/lib/relaton/core/hash_keys_sybolizer.rb +19 -0
- data/lib/relaton/core/hit.rb +49 -0
- data/lib/relaton/core/hit_collection.rb +118 -0
- data/lib/relaton/core/processor.rb +48 -0
- data/lib/relaton/core/workers_pool.rb +45 -0
- data/lib/relaton/core.rb +9 -0
- data/lib/relaton/db/cache.rb +232 -0
- data/lib/relaton/db/config.rb +24 -0
- data/lib/relaton/db/registry.rb +119 -0
- data/lib/relaton/db/util.rb +9 -0
- data/lib/relaton/db/workers_pool.rb +22 -0
- data/lib/relaton/db.rb +20 -206
- data/lib/relaton/doi/crossref.rb +72 -0
- data/lib/relaton/doi/parser.rb +827 -0
- data/lib/relaton/doi/processor.rb +65 -0
- data/lib/relaton/doi/util.rb +8 -0
- data/lib/relaton/doi.rb +20 -0
- data/lib/relaton/ecma/bibdata.rb +8 -0
- data/lib/relaton/ecma/bibitem.rb +8 -0
- data/lib/relaton/ecma/bibliography.rb +81 -0
- data/lib/relaton/ecma/data_fetcher.rb +103 -0
- data/lib/relaton/ecma/data_parser.rb +49 -0
- data/lib/relaton/ecma/edition_parser.rb +80 -0
- data/lib/relaton/ecma/ext.rb +7 -0
- data/lib/relaton/ecma/item.rb +11 -0
- data/lib/relaton/ecma/item_data.rb +6 -0
- data/lib/relaton/ecma/memento_parser.rb +60 -0
- data/lib/relaton/ecma/page_fetcher.rb +27 -0
- data/lib/relaton/ecma/parser_common.rb +33 -0
- data/lib/relaton/ecma/processor.rb +66 -0
- data/lib/relaton/ecma/standard_parser.rb +134 -0
- data/lib/relaton/ecma/util.rb +8 -0
- data/lib/relaton/ecma.rb +24 -0
- data/lib/relaton/etsi/bibdata.rb +10 -0
- data/lib/relaton/etsi/bibitem.rb +10 -0
- data/lib/relaton/etsi/bibliography.rb +46 -0
- data/lib/relaton/etsi/data_fetcher.rb +128 -0
- data/lib/relaton/etsi/data_parser.rb +208 -0
- data/lib/relaton/etsi/doctype.rb +30 -0
- data/lib/relaton/etsi/ext.rb +31 -0
- data/lib/relaton/etsi/item.rb +15 -0
- data/lib/relaton/etsi/item_data.rb +6 -0
- data/lib/relaton/etsi/processor.rb +69 -0
- data/lib/relaton/etsi/pubid.rb +37 -0
- data/lib/relaton/etsi/status.rb +13 -0
- data/lib/relaton/etsi/util.rb +8 -0
- data/lib/relaton/etsi.rb +25 -0
- data/lib/relaton/gb/bibdata.rb +8 -0
- data/lib/relaton/gb/bibitem.rb +8 -0
- data/lib/relaton/gb/bibliography.rb +145 -0
- data/lib/relaton/gb/ccs.rb +14 -0
- data/lib/relaton/gb/committee.rb +13 -0
- data/lib/relaton/gb/docidentifier.rb +23 -0
- data/lib/relaton/gb/doctype.rb +9 -0
- data/lib/relaton/gb/ext.rb +36 -0
- data/lib/relaton/gb/gb_scraper.rb +61 -0
- data/lib/relaton/gb/gb_type.rb +20 -0
- data/lib/relaton/gb/hit.rb +48 -0
- data/lib/relaton/gb/hit_collection.rb +19 -0
- data/lib/relaton/gb/item.rb +13 -0
- data/lib/relaton/gb/item_data.rb +6 -0
- data/lib/relaton/gb/processor.rb +46 -0
- data/lib/relaton/gb/project_number.rb +38 -0
- data/lib/relaton/gb/scraper.rb +204 -0
- data/lib/relaton/gb/sec_scraper.rb +92 -0
- data/lib/relaton/gb/stage_name.rb +13 -0
- data/lib/relaton/gb/structured_identifier.rb +26 -0
- data/lib/relaton/gb/t_scraper.rb +126 -0
- data/lib/relaton/gb/util.rb +8 -0
- data/lib/relaton/gb/yaml/prefixes.yaml +200 -0
- data/lib/relaton/gb.rb +33 -0
- data/lib/relaton/iana/bibdata.rb +8 -0
- data/lib/relaton/iana/bibitem.rb +8 -0
- data/lib/relaton/iana/bibliography.rb +47 -0
- data/lib/relaton/iana/data_fetcher.rb +71 -0
- data/lib/relaton/iana/item.rb +7 -0
- data/lib/relaton/iana/item_data.rb +6 -0
- data/lib/relaton/iana/parser.rb +146 -0
- data/lib/relaton/iana/processor.rb +68 -0
- data/lib/relaton/iana/util.rb +8 -0
- data/lib/relaton/iana.rb +29 -0
- data/lib/relaton/iec/bibliography.rb +283 -0
- data/lib/relaton/iec/data_fetcher.rb +216 -0
- data/lib/relaton/iec/data_parser.rb +391 -0
- data/lib/relaton/iec/hit.rb +26 -0
- data/lib/relaton/iec/hit_collection.rb +138 -0
- data/lib/relaton/iec/item_data.rb +7 -0
- data/lib/relaton/iec/model/bibdata.rb +8 -0
- data/lib/relaton/iec/model/bibitem.rb +8 -0
- data/lib/relaton/iec/model/docidentifier.rb +131 -0
- data/lib/relaton/iec/model/doctype.rb +12 -0
- data/lib/relaton/iec/model/ext.rb +53 -0
- data/lib/relaton/iec/model/item.rb +20 -0
- data/lib/relaton/iec/model/item_base.rb +12 -0
- data/lib/relaton/iec/model/relation.rb +7 -0
- data/lib/relaton/iec/model/stage_name.rb +13 -0
- data/lib/relaton/iec/processor.rb +73 -0
- data/lib/relaton/iec/statuses.yml +199 -0
- data/lib/relaton/iec/util.rb +8 -0
- data/lib/relaton/iec.rb +98 -0
- data/lib/relaton/ieee/balloting_group.rb +13 -0
- data/lib/relaton/ieee/bibdata.rb +8 -0
- data/lib/relaton/ieee/bibitem.rb +8 -0
- data/lib/relaton/ieee/bibliography.rb +51 -0
- data/lib/relaton/ieee/converter/bibxml/from_rfcxml.rb +10 -0
- data/lib/relaton/ieee/converter/bibxml/from_rfcxml_referencegroup.rb +10 -0
- data/lib/relaton/ieee/converter/bibxml.rb +20 -0
- data/lib/relaton/ieee/data_fetcher.rb +630 -0
- data/lib/relaton/ieee/doctype.rb +9 -0
- data/lib/relaton/ieee/editorial_group.rb +19 -0
- data/lib/relaton/ieee/ext.rb +36 -0
- data/lib/relaton/ieee/idams_parser.rb +323 -0
- data/lib/relaton/ieee/item.rb +11 -0
- data/lib/relaton/ieee/item_data.rb +7 -0
- data/lib/relaton/ieee/processor.rb +68 -0
- data/lib/relaton/ieee/pub_id.rb +161 -0
- data/lib/relaton/ieee/rawbib_id_parser.rb +548 -0
- data/lib/relaton/ieee/util.rb +8 -0
- data/lib/relaton/ieee.rb +29 -0
- data/lib/relaton/ietf/bibdata.rb +8 -0
- data/lib/relaton/ietf/bibitem.rb +8 -0
- data/lib/relaton/ietf/bibliography.rb +35 -0
- data/lib/relaton/ietf/bibxml_parser.rb +232 -0
- data/lib/relaton/ietf/data_fetcher.rb +278 -0
- data/lib/relaton/ietf/doctype.rb +9 -0
- data/lib/relaton/ietf/ext.rb +63 -0
- data/lib/relaton/ietf/item.rb +16 -0
- data/lib/relaton/ietf/item_base.rb +18 -0
- data/lib/relaton/ietf/item_data.rb +6 -0
- data/lib/relaton/ietf/processing_instructions.rb +79 -0
- data/lib/relaton/ietf/processor.rb +68 -0
- data/lib/relaton/ietf/relation.rb +9 -0
- data/lib/relaton/ietf/rfc/abstract.rb +19 -0
- data/lib/relaton/ietf/rfc/author.rb +21 -0
- data/lib/relaton/ietf/rfc/entry.rb +410 -0
- data/lib/relaton/ietf/rfc/entry_date.rb +21 -0
- data/lib/relaton/ietf/rfc/format.rb +19 -0
- data/lib/relaton/ietf/rfc/index.rb +46 -0
- data/lib/relaton/ietf/rfc/is_also.rb +21 -0
- data/lib/relaton/ietf/rfc/keywords.rb +19 -0
- data/lib/relaton/ietf/rfc/rfc_index_namespace.rb +11 -0
- data/lib/relaton/ietf/scraper.rb +68 -0
- data/lib/relaton/ietf/util.rb +8 -0
- data/lib/relaton/ietf/wg_name_resolver.rb +42 -0
- data/lib/relaton/ietf.rb +27 -0
- data/lib/relaton/iho/bibdata.rb +8 -0
- data/lib/relaton/iho/bibitem.rb +8 -0
- data/lib/relaton/iho/bibliography.rb +114 -0
- data/lib/relaton/iho/comment_period.rb +13 -0
- data/lib/relaton/iho/docidentifier.rb +31 -0
- data/lib/relaton/iho/doctype.rb +10 -0
- data/lib/relaton/iho/ext.rb +20 -0
- data/lib/relaton/iho/hash_parser_v1.rb +144 -0
- data/lib/relaton/iho/item.rb +20 -0
- data/lib/relaton/iho/item_base.rb +18 -0
- data/lib/relaton/iho/item_data.rb +6 -0
- data/lib/relaton/iho/processor.rb +54 -0
- data/lib/relaton/iho/relation.rb +9 -0
- data/lib/relaton/iho/structured_identifier.rb +20 -0
- data/lib/relaton/iho/util.rb +8 -0
- data/lib/relaton/iho.rb +27 -0
- data/lib/relaton/index/config.rb +52 -0
- data/lib/relaton/index/file_io.rb +305 -0
- data/lib/relaton/index/file_storage.rb +61 -0
- data/lib/relaton/index/id_number.rb +30 -0
- data/lib/relaton/index/pool.rb +41 -0
- data/lib/relaton/index/type.rb +159 -0
- data/lib/relaton/index/util.rb +18 -0
- data/lib/relaton/index.rb +60 -0
- data/lib/relaton/isbn/isbn.rb +61 -0
- data/lib/relaton/isbn/open_library.rb +43 -0
- data/lib/relaton/isbn/parser.rb +88 -0
- data/lib/relaton/isbn/processor.rb +48 -0
- data/lib/relaton/isbn/util.rb +8 -0
- data/lib/relaton/isbn.rb +19 -0
- data/lib/relaton/iso/bibliography.rb +407 -0
- data/lib/relaton/iso/data_fetcher.rb +338 -0
- data/lib/relaton/iso/data_parser.rb +444 -0
- data/lib/relaton/iso/hash_parser_v1.rb +177 -0
- data/lib/relaton/iso/hit.rb +57 -0
- data/lib/relaton/iso/hit_collection.rb +184 -0
- data/lib/relaton/iso/item_data.rb +28 -0
- data/lib/relaton/iso/model/bibdata.rb +10 -0
- data/lib/relaton/iso/model/bibitem.rb +8 -0
- data/lib/relaton/iso/model/contributor.rb +6 -0
- data/lib/relaton/iso/model/contributor_info.rb +9 -0
- data/lib/relaton/iso/model/docidentifier.rb +134 -0
- data/lib/relaton/iso/model/doctype.rb +13 -0
- data/lib/relaton/iso/model/ext.rb +35 -0
- data/lib/relaton/iso/model/item.rb +17 -0
- data/lib/relaton/iso/model/item_base.rb +22 -0
- data/lib/relaton/iso/model/organization.rb +9 -0
- data/lib/relaton/iso/model/project_number.rb +22 -0
- data/lib/relaton/iso/model/relation.rb +9 -0
- data/lib/relaton/iso/model/stagename.rb +14 -0
- data/lib/relaton/iso/model/structured_identifier.rb +31 -0
- data/lib/relaton/iso/processor.rb +84 -0
- data/lib/relaton/iso/scraper.rb +619 -0
- data/lib/relaton/iso/type/pubid.rb +50 -0
- data/lib/relaton/iso/util.rb +8 -0
- data/lib/relaton/iso.rb +30 -0
- data/lib/relaton/itu/bibliography.rb +90 -0
- data/lib/relaton/itu/data_fetcher.rb +104 -0
- data/lib/relaton/itu/data_parser_r.rb +140 -0
- data/lib/relaton/itu/hit.rb +22 -0
- data/lib/relaton/itu/hit_collection.rb +127 -0
- data/lib/relaton/itu/item_data.rb +6 -0
- data/lib/relaton/itu/model/approval_stage.rb +13 -0
- data/lib/relaton/itu/model/bibdata.rb +8 -0
- data/lib/relaton/itu/model/bibitem.rb +8 -0
- data/lib/relaton/itu/model/docidentifier.rb +9 -0
- data/lib/relaton/itu/model/doctype.rb +13 -0
- data/lib/relaton/itu/model/ext.rb +47 -0
- data/lib/relaton/itu/model/item.rb +13 -0
- data/lib/relaton/itu/model/meeting.rb +13 -0
- data/lib/relaton/itu/model/meeting_date.rb +15 -0
- data/lib/relaton/itu/model/question.rb +13 -0
- data/lib/relaton/itu/model/recommendation_status.rb +11 -0
- data/lib/relaton/itu/model/structured_identifier.rb +19 -0
- data/lib/relaton/itu/processor.rb +66 -0
- data/lib/relaton/itu/pubid.rb +177 -0
- data/lib/relaton/itu/radio_regulations_parser.rb +70 -0
- data/lib/relaton/itu/recommendation_parser.rb +161 -0
- data/lib/relaton/itu/scraper.rb +193 -0
- data/lib/relaton/itu/util.rb +8 -0
- data/lib/relaton/itu.rb +33 -0
- data/lib/relaton/jis/bibdata.rb +8 -0
- data/lib/relaton/jis/bibitem.rb +8 -0
- data/lib/relaton/jis/bibliography.rb +75 -0
- data/lib/relaton/jis/data_fetcher.rb +181 -0
- data/lib/relaton/jis/docidentifier.rb +21 -0
- data/lib/relaton/jis/doctype.rb +9 -0
- data/lib/relaton/jis/ext.rb +13 -0
- data/lib/relaton/jis/hit.rb +93 -0
- data/lib/relaton/jis/hit_collection.rb +127 -0
- data/lib/relaton/jis/item.rb +22 -0
- data/lib/relaton/jis/item_base.rb +26 -0
- data/lib/relaton/jis/item_data.rb +8 -0
- data/lib/relaton/jis/processor.rb +55 -0
- data/lib/relaton/jis/relation.rb +11 -0
- data/lib/relaton/jis/scraper.rb +232 -0
- data/lib/relaton/jis/structured_identifier.rb +13 -0
- data/lib/relaton/jis/util.rb +8 -0
- data/lib/relaton/jis.rb +33 -0
- data/lib/relaton/logger/channels/gh_issue.rb +78 -0
- data/lib/relaton/logger/config.rb +34 -0
- data/lib/relaton/logger/formatter_json.rb +8 -0
- data/lib/relaton/logger/formatter_string.rb +12 -0
- data/lib/relaton/logger/log.rb +64 -0
- data/lib/relaton/logger/log_device.rb +27 -0
- data/lib/relaton/logger/pool.rb +24 -0
- data/lib/relaton/logger.rb +18 -0
- data/lib/relaton/nist/bibdata.rb +8 -0
- data/lib/relaton/nist/bibitem.rb +8 -0
- data/lib/relaton/nist/bibliography.rb +191 -0
- data/lib/relaton/nist/comment_period.rb +15 -0
- data/lib/relaton/nist/data_fetcher.rb +84 -0
- data/lib/relaton/nist/date.rb +7 -0
- data/lib/relaton/nist/doctype.rb +7 -0
- data/lib/relaton/nist/ext.rb +16 -0
- data/lib/relaton/nist/hit.rb +18 -0
- data/lib/relaton/nist/hit_collection.rb +362 -0
- data/lib/relaton/nist/item.rb +17 -0
- data/lib/relaton/nist/item_data.rb +6 -0
- data/lib/relaton/nist/mods_parser.rb +276 -0
- data/lib/relaton/nist/processor.rb +68 -0
- data/lib/relaton/nist/pubs_export.rb +69 -0
- data/lib/relaton/nist/relation.rb +7 -0
- data/lib/relaton/nist/scraper.rb +290 -0
- data/lib/relaton/nist/series.yaml +49 -0
- data/lib/relaton/nist/util.rb +8 -0
- data/lib/relaton/nist.rb +34 -0
- data/lib/relaton/oasis/bibdata.rb +8 -0
- data/lib/relaton/oasis/bibitem.rb +8 -0
- data/lib/relaton/oasis/bibliography.rb +60 -0
- data/lib/relaton/oasis/browser_agent.rb +71 -0
- data/lib/relaton/oasis/data_fetcher.rb +94 -0
- data/lib/relaton/oasis/data_parser.rb +305 -0
- data/lib/relaton/oasis/data_parser_utils.rb +296 -0
- data/lib/relaton/oasis/data_part_parser.rb +239 -0
- data/lib/relaton/oasis/doctype.rb +7 -0
- data/lib/relaton/oasis/ext.rb +19 -0
- data/lib/relaton/oasis/item.rb +11 -0
- data/lib/relaton/oasis/item_data.rb +6 -0
- data/lib/relaton/oasis/processor.rb +68 -0
- data/lib/relaton/oasis/util.rb +8 -0
- data/lib/relaton/oasis.rb +28 -0
- data/lib/relaton/ogc/bibdata.rb +8 -0
- data/lib/relaton/ogc/bibitem.rb +8 -0
- data/lib/relaton/ogc/bibliography.rb +64 -0
- data/lib/relaton/ogc/data_fetcher.rb +110 -0
- data/lib/relaton/ogc/docidentifier.rb +6 -0
- data/lib/relaton/ogc/doctype.rb +12 -0
- data/lib/relaton/ogc/ext.rb +15 -0
- data/lib/relaton/ogc/hit.rb +18 -0
- data/lib/relaton/ogc/hit_collection.rb +36 -0
- data/lib/relaton/ogc/item.rb +13 -0
- data/lib/relaton/ogc/item_data.rb +6 -0
- data/lib/relaton/ogc/processor.rb +58 -0
- data/lib/relaton/ogc/scraper.rb +225 -0
- data/lib/relaton/ogc/util.rb +8 -0
- data/lib/relaton/ogc.rb +26 -0
- data/lib/relaton/oiml/bibdata.rb +8 -0
- data/lib/relaton/oiml/bibitem.rb +8 -0
- data/lib/relaton/oiml/bibliography.rb +94 -0
- data/lib/relaton/oiml/docidentifier.rb +33 -0
- data/lib/relaton/oiml/doctype.rb +13 -0
- data/lib/relaton/oiml/ext.rb +42 -0
- data/lib/relaton/oiml/item.rb +20 -0
- data/lib/relaton/oiml/item_base.rb +18 -0
- data/lib/relaton/oiml/item_data.rb +6 -0
- data/lib/relaton/oiml/processor.rb +54 -0
- data/lib/relaton/oiml/relation.rb +9 -0
- data/lib/relaton/oiml/util.rb +8 -0
- data/lib/relaton/oiml.rb +24 -0
- data/lib/relaton/omg/bibdata.rb +8 -0
- data/lib/relaton/omg/bibitem.rb +8 -0
- data/lib/relaton/omg/bibliography.rb +31 -0
- data/lib/relaton/omg/ext.rb +7 -0
- data/lib/relaton/omg/item.rb +8 -0
- data/lib/relaton/omg/item_data.rb +6 -0
- data/lib/relaton/omg/processor.rb +34 -0
- data/lib/relaton/omg/scraper.rb +141 -0
- data/lib/relaton/omg/util.rb +8 -0
- data/lib/relaton/omg.rb +24 -0
- data/lib/relaton/plateau/bibdata.rb +8 -0
- data/lib/relaton/plateau/bibitem.rb +8 -0
- data/lib/relaton/plateau/bibliography.rb +24 -0
- data/lib/relaton/plateau/data_fetcher.rb +153 -0
- data/lib/relaton/plateau/doctype.rb +7 -0
- data/lib/relaton/plateau/ext.rb +23 -0
- data/lib/relaton/plateau/handbook_parser.rb +95 -0
- data/lib/relaton/plateau/hit.rb +13 -0
- data/lib/relaton/plateau/hit_collection.rb +59 -0
- data/lib/relaton/plateau/item.rb +12 -0
- data/lib/relaton/plateau/item_data.rb +6 -0
- data/lib/relaton/plateau/parser.rb +101 -0
- data/lib/relaton/plateau/processor.rb +49 -0
- data/lib/relaton/plateau/technical_report_parser.rb +91 -0
- data/lib/relaton/plateau/util.rb +8 -0
- data/lib/relaton/plateau.rb +28 -0
- data/lib/relaton/un/bibdata.rb +8 -0
- data/lib/relaton/un/bibitem.rb +8 -0
- data/lib/relaton/un/bibliography.rb +48 -0
- data/lib/relaton/un/doctype.rb +10 -0
- data/lib/relaton/un/ext.rb +30 -0
- data/lib/relaton/un/hit.rb +56 -0
- data/lib/relaton/un/hit_collection.rb +61 -0
- data/lib/relaton/un/item.rb +11 -0
- data/lib/relaton/un/item_data.rb +6 -0
- data/lib/relaton/un/parser.rb +108 -0
- data/lib/relaton/un/processor.rb +38 -0
- data/lib/relaton/un/session.rb +25 -0
- data/lib/relaton/un/token_generator.rb +105 -0
- data/lib/relaton/un/util.rb +8 -0
- data/lib/relaton/un/wasm/decoder.rb +434 -0
- data/lib/relaton/un/wasm/instance.rb +101 -0
- data/lib/relaton/un/wasm/interpreter.rb +613 -0
- data/lib/relaton/un/wasm/memory.rb +112 -0
- data/lib/relaton/un/wasm/module.rb +47 -0
- data/lib/relaton/un/wasm.rb +17 -0
- data/lib/relaton/un/wasm_v_bg.wasm +0 -0
- data/lib/relaton/un.rb +28 -0
- data/lib/relaton/version.rb +1 -1
- data/lib/relaton/w3c/bibdata.rb +8 -0
- data/lib/relaton/w3c/bibitem.rb +8 -0
- data/lib/relaton/w3c/bibliography.rb +54 -0
- data/lib/relaton/w3c/data_fetcher.rb +309 -0
- data/lib/relaton/w3c/data_parser.rb +379 -0
- data/lib/relaton/w3c/doctype.rb +7 -0
- data/lib/relaton/w3c/ext.rb +11 -0
- data/lib/relaton/w3c/item.rb +12 -0
- data/lib/relaton/w3c/item_data.rb +6 -0
- data/lib/relaton/w3c/processor.rb +49 -0
- data/lib/relaton/w3c/pubid.rb +73 -0
- data/lib/relaton/w3c/safe_realize.rb +59 -0
- data/lib/relaton/w3c/util.rb +8 -0
- data/lib/relaton/w3c.rb +25 -0
- data/lib/relaton/xsf/bibdata.rb +8 -0
- data/lib/relaton/xsf/bibitem.rb +8 -0
- data/lib/relaton/xsf/bibliography.rb +24 -0
- data/lib/relaton/xsf/data_fetcher.rb +56 -0
- data/lib/relaton/xsf/hit.rb +17 -0
- data/lib/relaton/xsf/hit_collection.rb +24 -0
- data/lib/relaton/xsf/item.rb +7 -0
- data/lib/relaton/xsf/item_data.rb +6 -0
- data/lib/relaton/xsf/processor.rb +50 -0
- data/lib/relaton/xsf/util.rb +9 -0
- data/lib/relaton/xsf.rb +30 -0
- data/lib/relaton-core.rb +1 -0
- data/lib/relaton.rb +44 -9
- metadata +708 -150
- data/.github/workflows/rake.yml +0 -14
- data/.github/workflows/release.yml +0 -24
- data/.github/workflows/rubocop.yml +0 -48
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/.rubocop.yml +0 -12
- data/CLAUDE.md +0 -70
- data/Gemfile +0 -21
- data/Rakefile +0 -6
- data/docs/CHANGELOG.adoc +0 -16
- data/docs/VERSIONING_POLICY.adoc +0 -38
- data/docs/navigation.adoc +0 -6
- data/lib/relaton/config.rb +0 -24
- data/lib/relaton/db_cache.rb +0 -230
- data/lib/relaton/registry.rb +0 -118
- data/lib/relaton/util.rb +0 -7
- data/lib/relaton/workers_pool.rb +0 -21
- data/relaton.gemspec +0 -61
- data/spec/relaton/config_spec.rb +0 -10
- data/spec/relaton/db_cache_spec.rb +0 -51
- data/spec/relaton/db_spec.rb +0 -556
- data/spec/relaton/registry_spec.rb +0 -178
- data/spec/relaton/util_spec.rb +0 -3
- data/spec/relaton_spec.rb +0 -725
- data/spec/spec_helper.rb +0 -45
- data/spec/support/gb_t_20223_2006.xml +0 -33
- data/spec/support/iso_111111119115_1.xml +0 -0
- data/spec/support/iso_19115_1.xml +0 -115
- data/spec/support/iso_19115_2.xml +0 -95
- data/spec/support/rfc_8341.xml +0 -46
- data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +0 -12720
- data/spec/vcr_cassetes/api_relaton_org.yml +0 -121
- data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +0 -143
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +0 -199
- data/spec/vcr_cassetes/cie_001_1980.yml +0 -401
- data/spec/vcr_cassetes/cipm_meeting_43.yml +0 -1513
- data/spec/vcr_cassetes/doi_10_6028_nist_ir_8245.yml +0 -86
- data/spec/vcr_cassetes/ecma_6.yml +0 -112
- data/spec/vcr_cassetes/en_10160_1999.yml +0 -13624
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +0 -733
- data/spec/vcr_cassetes/ieee_528_2019.yml +0 -2786
- data/spec/vcr_cassetes/iso_111111119115_1.yml +0 -12951
- data/spec/vcr_cassetes/iso_19115_1.yml +0 -13177
- data/spec/vcr_cassetes/iso_19115_1_2.yml +0 -369
- data/spec/vcr_cassetes/iso_19115_1_std.yml +0 -13177
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +0 -229
- data/spec/vcr_cassetes/iso_19133_2005.yml +0 -148
- data/spec/vcr_cassetes/iso_combined_applied.yml +0 -364
- data/spec/vcr_cassetes/iso_combined_included.yml +0 -364
- data/spec/vcr_cassetes/iso_dis.yml +0 -157
- data/spec/vcr_cassetes/ogc_19_025r1.yml +0 -371
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +0 -317
- data/spec/vcr_cassetes/rfc_8341.yml +0 -1272
data/lib/relaton/db.rb
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
require "relaton/bib"
|
|
2
|
+
require "yaml"
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "nokogiri"
|
|
5
|
+
require "fileutils"
|
|
6
|
+
require "date"
|
|
7
|
+
|
|
1
8
|
module Relaton
|
|
2
9
|
class Db
|
|
3
10
|
# @param global_cache [String] directory of global DB
|
|
4
11
|
# @param local_cache [String] directory of local DB
|
|
5
12
|
def initialize(global_cache, local_cache)
|
|
6
|
-
@registry =
|
|
13
|
+
@registry = Registry.instance
|
|
7
14
|
gpath = global_cache && File.expand_path(global_cache)
|
|
8
15
|
@db = open_cache_biblio(gpath)
|
|
9
16
|
lpath = local_cache && File.expand_path(local_cache)
|
|
@@ -53,14 +60,7 @@ module Relaton
|
|
|
53
60
|
# after this date (inclusive, formats: "YYYY", "YYYY-MM",
|
|
54
61
|
# or "YYYY-MM-DD")
|
|
55
62
|
#
|
|
56
|
-
# @return [nil, RelatonBib::BibliographicItem,
|
|
57
|
-
# RelatonIsoBib::IsoBibliographicItem, RelatonItu::ItuBibliographicItem,
|
|
58
|
-
# RelatonIetf::IetfBibliographicItem, RelatonIec::IecBibliographicItem,
|
|
59
|
-
# RelatonIeee::IeeeBibliographicItem, RelatonNist::NistBibliongraphicItem,
|
|
60
|
-
# RelatonGb::GbbibliographicItem, RelatonOgc::OgcBibliographicItem,
|
|
61
|
-
# RelatonCalconnect::CcBibliographicItem, RelatinUn::UnBibliographicItem,
|
|
62
|
-
# RelatonBipm::BipmBibliographicItem, RelatonIho::IhoBibliographicItem,
|
|
63
|
-
# RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
|
|
63
|
+
# @return [nil, RelatonBib::BibliographicItem, ...]
|
|
64
64
|
##
|
|
65
65
|
def fetch(text, year = nil, opts = {})
|
|
66
66
|
reference = text.strip
|
|
@@ -132,24 +132,6 @@ module Relaton
|
|
|
132
132
|
end
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
-
# @param code [String]
|
|
136
|
-
# @param year [String, NilClass]
|
|
137
|
-
# @param stdclass [Symbol, NilClass]
|
|
138
|
-
#
|
|
139
|
-
# @param opts [Hash]
|
|
140
|
-
# @option opts [Boolean] :all_parts If all-parts reference is required
|
|
141
|
-
# @option opts [Boolean] :keep_year If undated reference should return
|
|
142
|
-
# actual reference with year
|
|
143
|
-
# @option opts [Integer] :retries (1) Number of network retries
|
|
144
|
-
#
|
|
145
|
-
# @return [nil, RelatonBib::BibliographicItem,
|
|
146
|
-
# RelatonIsoBib::IsoBibliographicItem, RelatonItu::ItuBibliographicItem,
|
|
147
|
-
# RelatonIetf::IetfBibliographicItem, RelatonIec::IecBibliographicItem,
|
|
148
|
-
# RelatonIeee::IeeeBibliographicItem, RelatonNist::NistBibliongraphicItem,
|
|
149
|
-
# RelatonGb::GbbibliographicItem, RelatonOgc::OgcBibliographicItem,
|
|
150
|
-
# RelatonCalconnect::CcBibliographicItem, RelatinUn::UnBibliographicItem,
|
|
151
|
-
# RelatonBipm::BipmBibliographicItem, RelatonIho::IhoBibliographicItem,
|
|
152
|
-
# RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
|
|
153
135
|
def fetch_std(code, year = nil, stdclass = nil, opts = {})
|
|
154
136
|
std = nil
|
|
155
137
|
@registry.processors.each do |name, processor|
|
|
@@ -194,28 +176,14 @@ module Relaton
|
|
|
194
176
|
|
|
195
177
|
private
|
|
196
178
|
|
|
197
|
-
# @param (see #fetch_api)
|
|
198
|
-
# @return (see #fetch_api)
|
|
199
179
|
def fetch_doc(code, year, opts, processor)
|
|
200
|
-
if
|
|
201
|
-
processor)
|
|
180
|
+
if Db.configuration.use_api then fetch_api(code, year, opts, processor)
|
|
202
181
|
else processor.get(code, year, opts)
|
|
203
182
|
end
|
|
204
183
|
end
|
|
205
184
|
|
|
206
|
-
#
|
|
207
|
-
# @param code [String]
|
|
208
|
-
# @param year [String]
|
|
209
|
-
#
|
|
210
|
-
# @param opts [Hash]
|
|
211
|
-
# @option opts [Boolean] :all_parts If all-parts reference is required
|
|
212
|
-
# @option opts [Boolean] :keep_year If undated reference should return
|
|
213
|
-
# actual reference with year
|
|
214
|
-
#
|
|
215
|
-
# @param processor [Relaton::Processor]
|
|
216
|
-
# @return [RelatonBib::BibliographicItem, nil]
|
|
217
185
|
def fetch_api(code, year, opts, processor)
|
|
218
|
-
url = "#{
|
|
186
|
+
url = "#{Db.configuration.api_host}" \
|
|
219
187
|
"/api/v1/document?#{params(code, year, opts)}"
|
|
220
188
|
rsp = Net::HTTP.get_response URI(url)
|
|
221
189
|
processor.from_xml rsp.body if rsp.code == "200"
|
|
@@ -223,36 +191,16 @@ module Relaton
|
|
|
223
191
|
processor.get(code, year, opts)
|
|
224
192
|
end
|
|
225
193
|
|
|
226
|
-
#
|
|
227
|
-
# Make string of parametrs
|
|
228
|
-
#
|
|
229
|
-
# @param [String] code
|
|
230
|
-
# @param [String] year
|
|
231
|
-
# @param [Hash] opts
|
|
232
|
-
#
|
|
233
|
-
# @return [String]
|
|
234
|
-
#
|
|
235
194
|
def params(code, year, opts)
|
|
236
195
|
opts.merge(code: code, year: year).map { |k, v| "#{k}=#{v}" }.join "&"
|
|
237
196
|
end
|
|
238
197
|
|
|
239
|
-
# @param file [String] file path
|
|
240
|
-
# @param xml [String] content in XML format
|
|
241
|
-
# @param text [String, nil] text to serach
|
|
242
|
-
# @param edition [String, nil] edition to filter
|
|
243
|
-
# @param year [Integer, nil] year to filter
|
|
244
|
-
# @return [BibliographicItem, nil]
|
|
245
198
|
def search_xml(file, xml, text, edition, year)
|
|
246
199
|
return unless text.nil? || match_xml_text?(xml, text)
|
|
247
200
|
|
|
248
201
|
search_edition_year(file, xml, edition, year)
|
|
249
202
|
end
|
|
250
203
|
|
|
251
|
-
# @param file [String] file path
|
|
252
|
-
# @param content [String] content in XML or YAML format
|
|
253
|
-
# @param edition [String, nil] edition to filter
|
|
254
|
-
# @param year [Integer, nil] year to filter
|
|
255
|
-
# @return [BibliographicItem, nil]
|
|
256
204
|
def search_edition_year(file, content, edition, year) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
257
205
|
processor = @registry.processor_by_ref(file.split("/")[-2])
|
|
258
206
|
item = if file.match?(/xml$/) then processor.from_xml(content)
|
|
@@ -264,14 +212,6 @@ module Relaton
|
|
|
264
212
|
end)
|
|
265
213
|
end
|
|
266
214
|
|
|
267
|
-
#
|
|
268
|
-
# Look up text in the XML elements attributes and content
|
|
269
|
-
#
|
|
270
|
-
# @param xml [String] content in XML format
|
|
271
|
-
# @param text [String, nil] text to serach
|
|
272
|
-
#
|
|
273
|
-
# @return [Boolean]
|
|
274
|
-
#
|
|
275
215
|
def match_xml_text?(xml, text)
|
|
276
216
|
esc = Regexp.escape(text)
|
|
277
217
|
pat = "((?<attr>=((?<apstr>')|\"" \
|
|
@@ -281,18 +221,6 @@ module Relaton
|
|
|
281
221
|
.match?(xml)
|
|
282
222
|
end
|
|
283
223
|
|
|
284
|
-
# @param code [String]
|
|
285
|
-
# @param year [String, nil]
|
|
286
|
-
# @param stdslass [String]
|
|
287
|
-
#
|
|
288
|
-
# @param opts [Hash] options
|
|
289
|
-
# @option opts [Boolean] :all_parts If all-parts reference is required
|
|
290
|
-
# @option opts [Boolean] :keep_year If undated reference should return
|
|
291
|
-
# actual reference with year
|
|
292
|
-
# @option opts [Integer] :retries (1) Number of network retries
|
|
293
|
-
#
|
|
294
|
-
# @return [nil, Relaton::Bib::ItemData
|
|
295
|
-
#
|
|
296
224
|
def combine_doc(code, year, opts, stdclass) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
297
225
|
return if stdclass == :relaton_bipm
|
|
298
226
|
|
|
@@ -323,19 +251,6 @@ module Relaton
|
|
|
323
251
|
end
|
|
324
252
|
end
|
|
325
253
|
|
|
326
|
-
# TODO: i18n
|
|
327
|
-
# Fofmat ID
|
|
328
|
-
# @param code [String]
|
|
329
|
-
# @param year [String]
|
|
330
|
-
#
|
|
331
|
-
# @param opts [Hash]
|
|
332
|
-
# @option opts [Boolean] :all_parts If all-parts reference is required
|
|
333
|
-
# @option opts [Boolean] :keep_year If undated reference should return
|
|
334
|
-
# actual reference with year
|
|
335
|
-
# @option opts [Integer] :retries (1) Number of network retries
|
|
336
|
-
#
|
|
337
|
-
# @param stdClass [Symbol]
|
|
338
|
-
# @return [Array<String>] docid and code
|
|
339
254
|
def std_id(code, year, opts, stdclass)
|
|
340
255
|
prefix, code = strip_id_wrapper(code, stdclass)
|
|
341
256
|
ret = code
|
|
@@ -348,59 +263,23 @@ module Relaton
|
|
|
348
263
|
["#{prefix}(#{ret.strip})", code]
|
|
349
264
|
end
|
|
350
265
|
|
|
351
|
-
# Find prefix and clean code
|
|
352
|
-
# @param code [String]
|
|
353
|
-
# @param stdClass [Symbol]
|
|
354
|
-
# @return [Array]
|
|
355
266
|
def strip_id_wrapper(code, stdclass)
|
|
356
267
|
prefix = @registry[stdclass].prefix
|
|
357
268
|
code =
|
|
358
269
|
if code.is_a?(String)
|
|
359
|
-
code.sub("
|
|
270
|
+
code.sub("–", "-").sub(/^#{prefix}\((.+)\)$/, "\\1")
|
|
360
271
|
else code.to_s
|
|
361
272
|
end
|
|
362
273
|
[prefix, code]
|
|
363
274
|
end
|
|
364
275
|
|
|
365
|
-
#
|
|
366
|
-
# @param entry [String, nil] XML string
|
|
367
|
-
# @param stdclass [Symbol]
|
|
368
|
-
#
|
|
369
|
-
# @return [nil, RelatonBib::BibliographicItem,
|
|
370
|
-
# RelatonIsoBib::IsoBibliographicItem, RelatonItu::ItuBibliographicItem,
|
|
371
|
-
# RelatonIetf::IetfBibliographicItem, RelatonIec::IecBibliographicItem,
|
|
372
|
-
# RelatonIeee::IeeeBibliographicItem, RelatonNist::NistBibliongraphicItem,
|
|
373
|
-
# RelatonGb::GbbibliographicItem, RelatonOgc::OgcBibliographicItem,
|
|
374
|
-
# RelatonCalconnect::CcBibliographicItem, RelatinUn::UnBibliographicItem,
|
|
375
|
-
# RelatonBipm::BipmBibliographicItem, RelatonIho::IhoBibliographicItem,
|
|
376
|
-
# RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
|
|
377
276
|
def bib_retval(entry, stdclass)
|
|
378
277
|
if entry && !entry.match?(/^not_found/)
|
|
379
278
|
@registry[stdclass].from_xml(entry)
|
|
380
279
|
end
|
|
381
280
|
end
|
|
382
281
|
|
|
383
|
-
# @param code [String]
|
|
384
|
-
# @param year [String]
|
|
385
|
-
#
|
|
386
|
-
# @param opts [Hash]
|
|
387
|
-
# @option opts [Boolean] :all_parts If all-parts reference is required
|
|
388
|
-
# @option opts [Boolean] :keep_year If undated reference should return
|
|
389
|
-
# actual reference with year
|
|
390
|
-
# @option opts [Integer] :retries (1) Number of network retries
|
|
391
|
-
#
|
|
392
|
-
# @param stdclass [Symbol]
|
|
393
|
-
# @return [nil, RelatonBib::BibliographicItem,
|
|
394
|
-
# RelatonIsoBib::IsoBibliographicItem, RelatonItu::ItuBibliographicItem,
|
|
395
|
-
# RelatonIetf::IetfBibliographicItem, RelatonIec::IecBibliographicItem,
|
|
396
|
-
# RelatonIeee::IeeeBibliographicItem, RelatonNist::NistBibliongraphicItem,
|
|
397
|
-
# RelatonGb::GbbibliographicItem, RelatonOgc::OgcBibliographicItem,
|
|
398
|
-
# RelatonCalconnect::CcBibliographicItem, RelatinUn::UnBibliographicItem,
|
|
399
|
-
# RelatonBipm::BipmBibliographicItem, RelatonIho::IhoBibliographicItem,
|
|
400
|
-
# RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
|
|
401
282
|
def check_bibliocache(code, year, opts, stdclass) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
|
402
|
-
# When date filters are present, check if the base
|
|
403
|
-
# (non-date-filtered) cache entry satisfies the range
|
|
404
283
|
if opts[:publication_date_before] || opts[:publication_date_after]
|
|
405
284
|
base_opts = opts.except(
|
|
406
285
|
:publication_date_before, :publication_date_after
|
|
@@ -447,27 +326,6 @@ module Relaton
|
|
|
447
326
|
bib_retval(db[id], stdclass)
|
|
448
327
|
end
|
|
449
328
|
|
|
450
|
-
#
|
|
451
|
-
# Create new bibliographic entry if it doesn't exist in database
|
|
452
|
-
#
|
|
453
|
-
# @param code [String]
|
|
454
|
-
# @param year [String]
|
|
455
|
-
#
|
|
456
|
-
# @param opts [Hash]
|
|
457
|
-
# @option opts [Boolean, nil] :all_parts If true then all-parts reference is
|
|
458
|
-
# requested
|
|
459
|
-
# @option opts [Boolean, nil] :keep_year If true then undated reference
|
|
460
|
-
# should return actual reference with year
|
|
461
|
-
# @option opts [Integer] :retries (1) Number of network retries
|
|
462
|
-
# @option opts [Boolean] :no_cache If true then don't use cache
|
|
463
|
-
#
|
|
464
|
-
# @param stdclass [Symbol]
|
|
465
|
-
# @param db [Relaton::DbCache,`nil]
|
|
466
|
-
# @param id [String, nil] docid
|
|
467
|
-
#
|
|
468
|
-
# @return [String] bibliographic entry
|
|
469
|
-
# XML or "redirection ID" or "not_found YYYY-MM-DD" string
|
|
470
|
-
#
|
|
471
329
|
def new_bib_entry(code, year, opts, stdclass, **args)
|
|
472
330
|
entry = @semaphore.synchronize { args[:db] && args[:db][args[:id]] }
|
|
473
331
|
if !entry || opts[:no_cache]
|
|
@@ -493,21 +351,9 @@ module Relaton
|
|
|
493
351
|
args[:no_cache] ? bib_entry(bib) : entry
|
|
494
352
|
end
|
|
495
353
|
|
|
496
|
-
#
|
|
497
|
-
# If the reference isn't equal to the document identifier
|
|
498
|
-
# then store the document in the cache and create
|
|
499
|
-
# for the reference a redirection to the document
|
|
500
|
-
#
|
|
501
|
-
# @param [<Type>] bib <description>
|
|
502
|
-
# @param [<Type>] stdclass <description>
|
|
503
|
-
# @param [<Type>] **args <description>
|
|
504
|
-
#
|
|
505
|
-
# @return [<Type>] <description>
|
|
506
|
-
#
|
|
507
354
|
def check_entry(bib, stdclass, **args) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
508
355
|
bib_id = bib && bib.docidentifier.first&.content
|
|
509
356
|
|
|
510
|
-
# when ref isn't equal to bib's id then return a redirection to bib's id
|
|
511
357
|
quoted = Regexp.quote("(#{bib_id})")
|
|
512
358
|
if args[:db] && args[:id] && bib_id &&
|
|
513
359
|
args[:id] !~ /#{quoted}/
|
|
@@ -518,21 +364,6 @@ module Relaton
|
|
|
518
364
|
end
|
|
519
365
|
end
|
|
520
366
|
|
|
521
|
-
#
|
|
522
|
-
# @param code [String]
|
|
523
|
-
# @param year [String]
|
|
524
|
-
#
|
|
525
|
-
# @param opts [Hash]
|
|
526
|
-
# @option opts [Boolean] :all_parts If all-parts reference is required
|
|
527
|
-
# @option opts [Boolean] :keep_year If undated reference should return
|
|
528
|
-
# actual reference with year
|
|
529
|
-
#
|
|
530
|
-
# @param processor [Relaton::Processor]
|
|
531
|
-
# @param retries [Integer] remain Number of network retries
|
|
532
|
-
#
|
|
533
|
-
# @raise [RelatonBib::RequestError]
|
|
534
|
-
# @return [RelatonBib::BibliographicItem]
|
|
535
|
-
#
|
|
536
367
|
def net_retry(code, year, opts, processor, retries)
|
|
537
368
|
fetch_doc code, year, opts, processor
|
|
538
369
|
rescue Relaton::RequestError => e
|
|
@@ -541,15 +372,6 @@ module Relaton
|
|
|
541
372
|
net_retry(code, year, opts, processor, retries - 1)
|
|
542
373
|
end
|
|
543
374
|
|
|
544
|
-
# @param bib [RelatonBib::BibliographicItem,
|
|
545
|
-
# RelatonIsoBib::IsoBibliographicItem, RelatonItu::ItuBibliographicItem,
|
|
546
|
-
# RelatonIetf::IetfBibliographicItem, RelatonIec::IecBibliographicItem,
|
|
547
|
-
# RelatonIeee::IeeeBibliographicItem, RelatonNist::NistBibliongraphicItem,
|
|
548
|
-
# RelatonGb::GbbibliographicItem, RelatonOgc::OgcBibliographicItem,
|
|
549
|
-
# RelatonCalconnect::CcBibliographicItem, RelatinUn::UnBibliographicItem,
|
|
550
|
-
# RelatonBipm::BipmBibliographicItem, RelatonIho::IhoBibliographicItem,
|
|
551
|
-
# RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
|
|
552
|
-
# @return [String] XML or "not_found mm-dd-yyyy"
|
|
553
375
|
def bib_entry(bib)
|
|
554
376
|
if bib.respond_to?(:to_xml)
|
|
555
377
|
bib.to_xml(bibdata: true)
|
|
@@ -558,12 +380,6 @@ module Relaton
|
|
|
558
380
|
end
|
|
559
381
|
end
|
|
560
382
|
|
|
561
|
-
# Check if an XML entry's published date falls within the requested range.
|
|
562
|
-
# Range semantics: [after, before) — inclusive start, exclusive end.
|
|
563
|
-
#
|
|
564
|
-
# @param entry [String] XML string
|
|
565
|
-
# @param opts [Hash]
|
|
566
|
-
# @return [Boolean]
|
|
567
383
|
def pub_date_in_range?(entry, opts) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
568
384
|
doc = Nokogiri::XML(entry)
|
|
569
385
|
date_str = doc.at("//date[@type='published']/on")&.text
|
|
@@ -581,9 +397,6 @@ module Relaton
|
|
|
581
397
|
true
|
|
582
398
|
end
|
|
583
399
|
|
|
584
|
-
# @param str [String] date string in "YYYY", "YYYY-MM",
|
|
585
|
-
# or "YYYY-MM-DD" format
|
|
586
|
-
# @return [Date, nil]
|
|
587
400
|
def parse_pub_date(str)
|
|
588
401
|
case str
|
|
589
402
|
when /^\d{4}-\d{1,2}-\d{1,2}/ then Date.parse(str)
|
|
@@ -594,12 +407,10 @@ module Relaton
|
|
|
594
407
|
nil
|
|
595
408
|
end
|
|
596
409
|
|
|
597
|
-
# @param dir [String, nil] DB directory
|
|
598
|
-
# @return [Relaton::DbCache, NilClass]
|
|
599
410
|
def open_cache_biblio(dir) # rubocop:disable Metrics/MethodLength
|
|
600
411
|
return nil if dir.nil?
|
|
601
412
|
|
|
602
|
-
db =
|
|
413
|
+
db = Cache.new dir
|
|
603
414
|
|
|
604
415
|
Dir["#{dir}/*/"].each do |fdir|
|
|
605
416
|
next if db.check_version?(fdir)
|
|
@@ -610,9 +421,6 @@ module Relaton
|
|
|
610
421
|
db
|
|
611
422
|
end
|
|
612
423
|
|
|
613
|
-
# @param qwp [Hash]
|
|
614
|
-
# @option qwp [Queue] :queue The queue of references to fetch
|
|
615
|
-
# @option qwp [Relaton::WorkersPool] :workers_pool The pool of workers
|
|
616
424
|
def process_queue(qwp)
|
|
617
425
|
while args = qwp[:queue].pop; qwp[:workers_pool] << args end
|
|
618
426
|
end
|
|
@@ -632,7 +440,7 @@ module Relaton
|
|
|
632
440
|
globalname = global_bibliocache_name if opts[:global_cache]
|
|
633
441
|
localname = local_bibliocache_name(opts[:local_cache])
|
|
634
442
|
flush_caches globalname, localname if opts[:flush_caches]
|
|
635
|
-
|
|
443
|
+
new(globalname, localname)
|
|
636
444
|
end
|
|
637
445
|
|
|
638
446
|
def flush_caches(gcache, lcache)
|
|
@@ -653,3 +461,9 @@ module Relaton
|
|
|
653
461
|
end
|
|
654
462
|
end
|
|
655
463
|
end
|
|
464
|
+
|
|
465
|
+
require_relative "db/util"
|
|
466
|
+
require_relative "db/config"
|
|
467
|
+
require_relative "db/workers_pool"
|
|
468
|
+
require_relative "db/cache"
|
|
469
|
+
require_relative "db/registry"
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require "mechanize"
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Doi
|
|
5
|
+
module Crossref
|
|
6
|
+
extend self
|
|
7
|
+
|
|
8
|
+
USER_AGENT = "Relaton::Doi (https://www.relaton.org/guides/doi/; mailto:open.source@ribose.com)"
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
# Get a document by DOI from the CrossRef API.
|
|
12
|
+
#
|
|
13
|
+
# @param [String] doi The DOI.
|
|
14
|
+
#
|
|
15
|
+
# @return [RelatonBib::BibliographicItem, RelatonIetf::IetfBibliographicItem,
|
|
16
|
+
# RelatonBipm::BipmBibliographicItem, RelatonIeee::IeeeBibliographicItem,
|
|
17
|
+
# RelatonNist::NistBibliographicItem] The bibitem.
|
|
18
|
+
#
|
|
19
|
+
def get(doi)
|
|
20
|
+
Util.info "Fetching from search.crossref.org ...", key: doi
|
|
21
|
+
id = doi.sub(%r{^doi:}, "")
|
|
22
|
+
message = get_by_id id
|
|
23
|
+
if message
|
|
24
|
+
Util.info "Found: `#{message['DOI']}`", key: doi
|
|
25
|
+
Parser.parse message
|
|
26
|
+
else
|
|
27
|
+
Util.info "Not found.", key: doi
|
|
28
|
+
nil
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
#
|
|
33
|
+
# Get a document by DOI from the CrossRef API.
|
|
34
|
+
#
|
|
35
|
+
# @param [String] id The DOI.
|
|
36
|
+
#
|
|
37
|
+
# @return [Hash] The document.
|
|
38
|
+
#
|
|
39
|
+
def get_by_id(id) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
40
|
+
n = 0
|
|
41
|
+
url = "https://api.crossref.org/works/#{CGI.escape(id)}"
|
|
42
|
+
loop do
|
|
43
|
+
resp = agent.get url
|
|
44
|
+
work = JSON.parse resp.body
|
|
45
|
+
return work["message"] if work["status"] == "ok"
|
|
46
|
+
|
|
47
|
+
if n > 1
|
|
48
|
+
raise Relaton::RequestError, "Crossref error: #{resp.body}"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
n += 1
|
|
52
|
+
sleep resp.response["x-rate-limit-interval"].to_i * n
|
|
53
|
+
rescue Mechanize::ResponseCodeError => e
|
|
54
|
+
return nil if e.response_code == "404"
|
|
55
|
+
|
|
56
|
+
if n > 1
|
|
57
|
+
raise Relaton::RequestError, "Crossref error: #{e.page.body}"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
n += 1
|
|
61
|
+
sleep e.page.response["x-rate-limit-interval"].to_i * n
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def agent
|
|
66
|
+
@agent ||= Mechanize.new do |a|
|
|
67
|
+
a.user_agent = USER_AGENT
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|