relaton 2.1.0 → 3.0.0.pre.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{docs/README.adoc → README.adoc} +109 -38
- data/lib/relaton/3gpp/bibdata.rb +9 -0
- data/lib/relaton/3gpp/bibitem.rb +9 -0
- data/lib/relaton/3gpp/bibliography.rb +48 -0
- data/lib/relaton/3gpp/data_fetcher.rb +255 -0
- data/lib/relaton/3gpp/doctype.rb +9 -0
- data/lib/relaton/3gpp/ext.rb +31 -0
- data/lib/relaton/3gpp/item.rb +12 -0
- data/lib/relaton/3gpp/item_data.rb +15 -0
- data/lib/relaton/3gpp/parser.rb +400 -0
- data/lib/relaton/3gpp/processor.rb +68 -0
- data/lib/relaton/3gpp/release.rb +34 -0
- data/lib/relaton/3gpp/util.rb +8 -0
- data/lib/relaton/3gpp.rb +25 -0
- data/lib/relaton/bib/converter/asciibib/to_asciibib.rb +663 -0
- data/lib/relaton/bib/converter/asciibib.rb +13 -0
- data/lib/relaton/bib/converter/bibtex/from_bibtex.rb +245 -0
- data/lib/relaton/bib/converter/bibtex/to_bibtex.rb +341 -0
- data/lib/relaton/bib/converter/bibtex.rb +23 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml.rb +386 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml_referencegroup.rb +71 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml.rb +308 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml_referencegroup.rb +52 -0
- data/lib/relaton/bib/converter/bibxml.rb +51 -0
- data/lib/relaton/bib/hash_parser_v1.rb +767 -0
- data/lib/relaton/bib/item_data.rb +229 -0
- data/lib/relaton/bib/model/abstract.rb +16 -0
- data/lib/relaton/bib/model/address.rb +22 -0
- data/lib/relaton/bib/model/affiliation.rb +16 -0
- data/lib/relaton/bib/model/bibdata.rb +11 -0
- data/lib/relaton/bib/model/bibdata_shared.rb +12 -0
- data/lib/relaton/bib/model/bibitem.rb +11 -0
- data/lib/relaton/bib/model/bibitem_shared.rb +12 -0
- data/lib/relaton/bib/model/contact.rb +18 -0
- data/lib/relaton/bib/model/contribution_info.rb +15 -0
- data/lib/relaton/bib/model/contributor.rb +29 -0
- data/lib/relaton/bib/model/copyright.rb +27 -0
- data/lib/relaton/bib/model/date.rb +31 -0
- data/lib/relaton/bib/model/depiction.rb +16 -0
- data/lib/relaton/bib/model/docidentifier.rb +34 -0
- data/lib/relaton/bib/model/doctype.rb +14 -0
- data/lib/relaton/bib/model/edition.rb +14 -0
- data/lib/relaton/bib/model/ext.rb +39 -0
- data/lib/relaton/bib/model/extent.rb +16 -0
- data/lib/relaton/bib/model/formattedref.rb +43 -0
- data/lib/relaton/bib/model/full_name_type.rb +64 -0
- data/lib/relaton/bib/model/fullname.rb +11 -0
- data/lib/relaton/bib/model/ics.rb +49 -0
- data/lib/relaton/bib/model/image.rb +28 -0
- data/lib/relaton/bib/model/item.rb +96 -0
- data/lib/relaton/bib/model/item_base.rb +20 -0
- data/lib/relaton/bib/model/item_shared.rb +88 -0
- data/lib/relaton/bib/model/keyword.rb +30 -0
- data/lib/relaton/bib/model/locality.rb +18 -0
- data/lib/relaton/bib/model/locality_stack.rb +14 -0
- data/lib/relaton/bib/model/localized_string.rb +48 -0
- data/lib/relaton/bib/model/localized_string_attrs.rb +24 -0
- data/lib/relaton/bib/model/logo.rb +14 -0
- data/lib/relaton/bib/model/medium.rb +22 -0
- data/lib/relaton/bib/model/note.rb +16 -0
- data/lib/relaton/bib/model/organization.rb +13 -0
- data/lib/relaton/bib/model/organization_type.rb +42 -0
- data/lib/relaton/bib/model/person.rb +36 -0
- data/lib/relaton/bib/model/phone.rb +14 -0
- data/lib/relaton/bib/model/place.rb +33 -0
- data/lib/relaton/bib/model/price.rb +14 -0
- data/lib/relaton/bib/model/relation.rb +43 -0
- data/lib/relaton/bib/model/series.rb +34 -0
- data/lib/relaton/bib/model/size.rb +23 -0
- data/lib/relaton/bib/model/source_locality_stack.rb +14 -0
- data/lib/relaton/bib/model/status.rb +27 -0
- data/lib/relaton/bib/model/structured_identifier.rb +48 -0
- data/lib/relaton/bib/model/subdivision.rb +16 -0
- data/lib/relaton/bib/model/title.rb +56 -0
- data/lib/relaton/bib/model/type/plain_date.rb +16 -0
- data/lib/relaton/bib/model/type/string_date.rb +48 -0
- data/lib/relaton/bib/model/uri.rb +18 -0
- data/lib/relaton/bib/model/validity.rb +16 -0
- data/lib/relaton/bib/model/version.rb +43 -0
- data/lib/relaton/bib/namespace_helper.rb +21 -0
- data/lib/relaton/bib/sanitizer.rb +68 -0
- data/lib/relaton/bib/util.rb +18 -0
- data/lib/relaton/bib/versions.json +35 -0
- data/lib/relaton/bib.rb +48 -0
- data/lib/relaton/bipm/bibliography.rb +82 -0
- data/lib/relaton/bipm/converter/asciibib.rb +64 -0
- data/lib/relaton/bipm/data_fetcher.rb +57 -0
- data/lib/relaton/bipm/data_outcomes_parser.rb +657 -0
- data/lib/relaton/bipm/id_parser.rb +277 -0
- data/lib/relaton/bipm/item_data.rb +47 -0
- data/lib/relaton/bipm/model/bibdata.rb +9 -0
- data/lib/relaton/bipm/model/bibitem.rb +9 -0
- data/lib/relaton/bipm/model/comment_period.rb +13 -0
- data/lib/relaton/bipm/model/doctype.rb +12 -0
- data/lib/relaton/bipm/model/ext.rb +38 -0
- data/lib/relaton/bipm/model/item.rb +11 -0
- data/lib/relaton/bipm/model/structured_identifier.rb +15 -0
- data/lib/relaton/bipm/processor.rb +69 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/affiliations.rb +111 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/fetcher.rb +174 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/niso_jats_parser.rb +353 -0
- data/lib/relaton/bipm/si_brochure_parser.rb +186 -0
- data/lib/relaton/bipm/util.rb +8 -0
- data/lib/relaton/bipm.rb +32 -0
- data/lib/relaton/bsi/bibliography.rb +124 -0
- data/lib/relaton/bsi/hit.rb +14 -0
- data/lib/relaton/bsi/hit_collection.rb +114 -0
- data/lib/relaton/bsi/item_data.rb +13 -0
- data/lib/relaton/bsi/model/bibdata.rb +8 -0
- data/lib/relaton/bsi/model/bibitem.rb +8 -0
- data/lib/relaton/bsi/model/docidentifier.rb +9 -0
- data/lib/relaton/bsi/model/doctype.rb +14 -0
- data/lib/relaton/bsi/model/ext.rb +17 -0
- data/lib/relaton/bsi/model/item.rb +17 -0
- data/lib/relaton/bsi/model/item_base.rb +22 -0
- data/lib/relaton/bsi/model/relation.rb +9 -0
- data/lib/relaton/bsi/processor.rb +42 -0
- data/lib/relaton/bsi/schema.json +24882 -0
- data/lib/relaton/bsi/scraper.rb +288 -0
- data/lib/relaton/bsi/util.rb +8 -0
- data/lib/relaton/bsi.rb +25 -0
- data/lib/relaton/calconnect/bibliography.rb +95 -0
- data/lib/relaton/calconnect/data_fetcher.rb +106 -0
- data/lib/relaton/calconnect/hit.rb +14 -0
- data/lib/relaton/calconnect/hit_collection.rb +84 -0
- data/lib/relaton/calconnect/item_data.rb +12 -0
- data/lib/relaton/calconnect/model/bibdata.rb +8 -0
- data/lib/relaton/calconnect/model/bibitem.rb +8 -0
- data/lib/relaton/calconnect/model/doctype.rb +11 -0
- data/lib/relaton/calconnect/model/ext.rb +11 -0
- data/lib/relaton/calconnect/model/item.rb +13 -0
- data/lib/relaton/calconnect/processor.rb +66 -0
- data/lib/relaton/calconnect/scraper.rb +87 -0
- data/lib/relaton/calconnect/util.rb +8 -0
- data/lib/relaton/calconnect.rb +26 -0
- data/lib/relaton/ccsds/bibliography.rb +63 -0
- data/lib/relaton/ccsds/data/fetcher.rb +247 -0
- data/lib/relaton/ccsds/data/iso_references.rb +30 -0
- data/lib/relaton/ccsds/data/parser.rb +194 -0
- data/lib/relaton/ccsds/hit.rb +24 -0
- data/lib/relaton/ccsds/hit_collection.rb +42 -0
- data/lib/relaton/ccsds/item_data.rb +9 -0
- data/lib/relaton/ccsds/model/bibdata.rb +8 -0
- data/lib/relaton/ccsds/model/bibitem.rb +8 -0
- data/lib/relaton/ccsds/model/doctype.rb +9 -0
- data/lib/relaton/ccsds/model/ext.rb +19 -0
- data/lib/relaton/ccsds/model/item.rb +13 -0
- data/lib/relaton/ccsds/processor.rb +68 -0
- data/lib/relaton/ccsds/util.rb +10 -0
- data/lib/relaton/ccsds.rb +33 -0
- data/lib/relaton/cen/bibliography.rb +121 -0
- data/lib/relaton/cen/committees.yaml +66 -0
- data/lib/relaton/cen/hit.rb +16 -0
- data/lib/relaton/cen/hit_collection.rb +68 -0
- data/lib/relaton/cen/item_data.rb +7 -0
- data/lib/relaton/cen/model/bibdata.rb +8 -0
- data/lib/relaton/cen/model/bibitem.rb +8 -0
- data/lib/relaton/cen/model/docidentifier.rb +9 -0
- data/lib/relaton/cen/model/ext.rb +11 -0
- data/lib/relaton/cen/model/item.rb +14 -0
- data/lib/relaton/cen/model/structured_identifier.rb +9 -0
- data/lib/relaton/cen/processor.rb +40 -0
- data/lib/relaton/cen/scraper.rb +210 -0
- data/lib/relaton/cen/util.rb +8 -0
- data/lib/relaton/cen.rb +29 -0
- data/lib/relaton/cie/bibdata.rb +8 -0
- data/lib/relaton/cie/bibitem.rb +8 -0
- data/lib/relaton/cie/bibliography.rb +31 -0
- data/lib/relaton/cie/data_fetcher.rb +355 -0
- data/lib/relaton/cie/ext.rb +7 -0
- data/lib/relaton/cie/item.rb +11 -0
- data/lib/relaton/cie/item_data.rb +6 -0
- data/lib/relaton/cie/processor.rb +66 -0
- data/lib/relaton/cie/scrapper.rb +39 -0
- data/lib/relaton/cie/util.rb +8 -0
- data/lib/relaton/cie.rb +28 -0
- data/lib/relaton/core/array_wrapper.rb +20 -0
- data/lib/relaton/core/data_fetcher.rb +97 -0
- data/lib/relaton/core/date_parser.rb +42 -0
- data/lib/relaton/core/hash_keys_sybolizer.rb +19 -0
- data/lib/relaton/core/hit.rb +49 -0
- data/lib/relaton/core/hit_collection.rb +118 -0
- data/lib/relaton/core/processor.rb +48 -0
- data/lib/relaton/core/workers_pool.rb +45 -0
- data/lib/relaton/core.rb +9 -0
- data/lib/relaton/db/cache.rb +232 -0
- data/lib/relaton/db/config.rb +24 -0
- data/lib/relaton/db/registry.rb +119 -0
- data/lib/relaton/db/util.rb +9 -0
- data/lib/relaton/db/workers_pool.rb +22 -0
- data/lib/relaton/db.rb +20 -206
- data/lib/relaton/doi/crossref.rb +72 -0
- data/lib/relaton/doi/parser.rb +827 -0
- data/lib/relaton/doi/processor.rb +65 -0
- data/lib/relaton/doi/util.rb +8 -0
- data/lib/relaton/doi.rb +20 -0
- data/lib/relaton/ecma/bibdata.rb +8 -0
- data/lib/relaton/ecma/bibitem.rb +8 -0
- data/lib/relaton/ecma/bibliography.rb +81 -0
- data/lib/relaton/ecma/data_fetcher.rb +103 -0
- data/lib/relaton/ecma/data_parser.rb +49 -0
- data/lib/relaton/ecma/edition_parser.rb +80 -0
- data/lib/relaton/ecma/ext.rb +7 -0
- data/lib/relaton/ecma/item.rb +11 -0
- data/lib/relaton/ecma/item_data.rb +6 -0
- data/lib/relaton/ecma/memento_parser.rb +60 -0
- data/lib/relaton/ecma/page_fetcher.rb +27 -0
- data/lib/relaton/ecma/parser_common.rb +33 -0
- data/lib/relaton/ecma/processor.rb +66 -0
- data/lib/relaton/ecma/standard_parser.rb +134 -0
- data/lib/relaton/ecma/util.rb +8 -0
- data/lib/relaton/ecma.rb +24 -0
- data/lib/relaton/etsi/bibdata.rb +10 -0
- data/lib/relaton/etsi/bibitem.rb +10 -0
- data/lib/relaton/etsi/bibliography.rb +46 -0
- data/lib/relaton/etsi/data_fetcher.rb +128 -0
- data/lib/relaton/etsi/data_parser.rb +208 -0
- data/lib/relaton/etsi/doctype.rb +30 -0
- data/lib/relaton/etsi/ext.rb +31 -0
- data/lib/relaton/etsi/item.rb +15 -0
- data/lib/relaton/etsi/item_data.rb +6 -0
- data/lib/relaton/etsi/processor.rb +69 -0
- data/lib/relaton/etsi/pubid.rb +37 -0
- data/lib/relaton/etsi/status.rb +13 -0
- data/lib/relaton/etsi/util.rb +8 -0
- data/lib/relaton/etsi.rb +25 -0
- data/lib/relaton/gb/bibdata.rb +8 -0
- data/lib/relaton/gb/bibitem.rb +8 -0
- data/lib/relaton/gb/bibliography.rb +145 -0
- data/lib/relaton/gb/ccs.rb +14 -0
- data/lib/relaton/gb/committee.rb +13 -0
- data/lib/relaton/gb/docidentifier.rb +23 -0
- data/lib/relaton/gb/doctype.rb +9 -0
- data/lib/relaton/gb/ext.rb +36 -0
- data/lib/relaton/gb/gb_scraper.rb +61 -0
- data/lib/relaton/gb/gb_type.rb +20 -0
- data/lib/relaton/gb/hit.rb +48 -0
- data/lib/relaton/gb/hit_collection.rb +19 -0
- data/lib/relaton/gb/item.rb +13 -0
- data/lib/relaton/gb/item_data.rb +6 -0
- data/lib/relaton/gb/processor.rb +46 -0
- data/lib/relaton/gb/project_number.rb +38 -0
- data/lib/relaton/gb/scraper.rb +204 -0
- data/lib/relaton/gb/sec_scraper.rb +92 -0
- data/lib/relaton/gb/stage_name.rb +13 -0
- data/lib/relaton/gb/structured_identifier.rb +26 -0
- data/lib/relaton/gb/t_scraper.rb +126 -0
- data/lib/relaton/gb/util.rb +8 -0
- data/lib/relaton/gb/yaml/prefixes.yaml +200 -0
- data/lib/relaton/gb.rb +33 -0
- data/lib/relaton/iana/bibdata.rb +8 -0
- data/lib/relaton/iana/bibitem.rb +8 -0
- data/lib/relaton/iana/bibliography.rb +47 -0
- data/lib/relaton/iana/data_fetcher.rb +71 -0
- data/lib/relaton/iana/item.rb +7 -0
- data/lib/relaton/iana/item_data.rb +6 -0
- data/lib/relaton/iana/parser.rb +146 -0
- data/lib/relaton/iana/processor.rb +68 -0
- data/lib/relaton/iana/util.rb +8 -0
- data/lib/relaton/iana.rb +29 -0
- data/lib/relaton/iec/bibliography.rb +283 -0
- data/lib/relaton/iec/data_fetcher.rb +216 -0
- data/lib/relaton/iec/data_parser.rb +391 -0
- data/lib/relaton/iec/hit.rb +26 -0
- data/lib/relaton/iec/hit_collection.rb +138 -0
- data/lib/relaton/iec/item_data.rb +7 -0
- data/lib/relaton/iec/model/bibdata.rb +8 -0
- data/lib/relaton/iec/model/bibitem.rb +8 -0
- data/lib/relaton/iec/model/docidentifier.rb +131 -0
- data/lib/relaton/iec/model/doctype.rb +12 -0
- data/lib/relaton/iec/model/ext.rb +53 -0
- data/lib/relaton/iec/model/item.rb +20 -0
- data/lib/relaton/iec/model/item_base.rb +12 -0
- data/lib/relaton/iec/model/relation.rb +7 -0
- data/lib/relaton/iec/model/stage_name.rb +13 -0
- data/lib/relaton/iec/processor.rb +73 -0
- data/lib/relaton/iec/statuses.yml +199 -0
- data/lib/relaton/iec/util.rb +8 -0
- data/lib/relaton/iec.rb +98 -0
- data/lib/relaton/ieee/balloting_group.rb +13 -0
- data/lib/relaton/ieee/bibdata.rb +8 -0
- data/lib/relaton/ieee/bibitem.rb +8 -0
- data/lib/relaton/ieee/bibliography.rb +51 -0
- data/lib/relaton/ieee/converter/bibxml/from_rfcxml.rb +10 -0
- data/lib/relaton/ieee/converter/bibxml/from_rfcxml_referencegroup.rb +10 -0
- data/lib/relaton/ieee/converter/bibxml.rb +20 -0
- data/lib/relaton/ieee/data_fetcher.rb +630 -0
- data/lib/relaton/ieee/doctype.rb +9 -0
- data/lib/relaton/ieee/editorial_group.rb +19 -0
- data/lib/relaton/ieee/ext.rb +36 -0
- data/lib/relaton/ieee/idams_parser.rb +323 -0
- data/lib/relaton/ieee/item.rb +11 -0
- data/lib/relaton/ieee/item_data.rb +7 -0
- data/lib/relaton/ieee/processor.rb +68 -0
- data/lib/relaton/ieee/pub_id.rb +161 -0
- data/lib/relaton/ieee/rawbib_id_parser.rb +548 -0
- data/lib/relaton/ieee/util.rb +8 -0
- data/lib/relaton/ieee.rb +29 -0
- data/lib/relaton/ietf/bibdata.rb +8 -0
- data/lib/relaton/ietf/bibitem.rb +8 -0
- data/lib/relaton/ietf/bibliography.rb +35 -0
- data/lib/relaton/ietf/bibxml_parser.rb +232 -0
- data/lib/relaton/ietf/data_fetcher.rb +278 -0
- data/lib/relaton/ietf/doctype.rb +9 -0
- data/lib/relaton/ietf/ext.rb +63 -0
- data/lib/relaton/ietf/item.rb +16 -0
- data/lib/relaton/ietf/item_base.rb +18 -0
- data/lib/relaton/ietf/item_data.rb +6 -0
- data/lib/relaton/ietf/processing_instructions.rb +79 -0
- data/lib/relaton/ietf/processor.rb +68 -0
- data/lib/relaton/ietf/relation.rb +9 -0
- data/lib/relaton/ietf/rfc/abstract.rb +19 -0
- data/lib/relaton/ietf/rfc/author.rb +21 -0
- data/lib/relaton/ietf/rfc/entry.rb +410 -0
- data/lib/relaton/ietf/rfc/entry_date.rb +21 -0
- data/lib/relaton/ietf/rfc/format.rb +19 -0
- data/lib/relaton/ietf/rfc/index.rb +46 -0
- data/lib/relaton/ietf/rfc/is_also.rb +21 -0
- data/lib/relaton/ietf/rfc/keywords.rb +19 -0
- data/lib/relaton/ietf/rfc/rfc_index_namespace.rb +11 -0
- data/lib/relaton/ietf/scraper.rb +68 -0
- data/lib/relaton/ietf/util.rb +8 -0
- data/lib/relaton/ietf/wg_name_resolver.rb +42 -0
- data/lib/relaton/ietf.rb +27 -0
- data/lib/relaton/iho/bibdata.rb +8 -0
- data/lib/relaton/iho/bibitem.rb +8 -0
- data/lib/relaton/iho/bibliography.rb +114 -0
- data/lib/relaton/iho/comment_period.rb +13 -0
- data/lib/relaton/iho/docidentifier.rb +31 -0
- data/lib/relaton/iho/doctype.rb +10 -0
- data/lib/relaton/iho/ext.rb +20 -0
- data/lib/relaton/iho/hash_parser_v1.rb +144 -0
- data/lib/relaton/iho/item.rb +20 -0
- data/lib/relaton/iho/item_base.rb +18 -0
- data/lib/relaton/iho/item_data.rb +6 -0
- data/lib/relaton/iho/processor.rb +54 -0
- data/lib/relaton/iho/relation.rb +9 -0
- data/lib/relaton/iho/structured_identifier.rb +20 -0
- data/lib/relaton/iho/util.rb +8 -0
- data/lib/relaton/iho.rb +27 -0
- data/lib/relaton/index/config.rb +52 -0
- data/lib/relaton/index/file_io.rb +305 -0
- data/lib/relaton/index/file_storage.rb +61 -0
- data/lib/relaton/index/id_number.rb +30 -0
- data/lib/relaton/index/pool.rb +41 -0
- data/lib/relaton/index/type.rb +159 -0
- data/lib/relaton/index/util.rb +18 -0
- data/lib/relaton/index.rb +60 -0
- data/lib/relaton/isbn/isbn.rb +61 -0
- data/lib/relaton/isbn/open_library.rb +43 -0
- data/lib/relaton/isbn/parser.rb +88 -0
- data/lib/relaton/isbn/processor.rb +48 -0
- data/lib/relaton/isbn/util.rb +8 -0
- data/lib/relaton/isbn.rb +19 -0
- data/lib/relaton/iso/bibliography.rb +407 -0
- data/lib/relaton/iso/data_fetcher.rb +338 -0
- data/lib/relaton/iso/data_parser.rb +444 -0
- data/lib/relaton/iso/hash_parser_v1.rb +177 -0
- data/lib/relaton/iso/hit.rb +57 -0
- data/lib/relaton/iso/hit_collection.rb +184 -0
- data/lib/relaton/iso/item_data.rb +28 -0
- data/lib/relaton/iso/model/bibdata.rb +10 -0
- data/lib/relaton/iso/model/bibitem.rb +8 -0
- data/lib/relaton/iso/model/contributor.rb +6 -0
- data/lib/relaton/iso/model/contributor_info.rb +9 -0
- data/lib/relaton/iso/model/docidentifier.rb +134 -0
- data/lib/relaton/iso/model/doctype.rb +13 -0
- data/lib/relaton/iso/model/ext.rb +35 -0
- data/lib/relaton/iso/model/item.rb +17 -0
- data/lib/relaton/iso/model/item_base.rb +22 -0
- data/lib/relaton/iso/model/organization.rb +9 -0
- data/lib/relaton/iso/model/project_number.rb +22 -0
- data/lib/relaton/iso/model/relation.rb +9 -0
- data/lib/relaton/iso/model/stagename.rb +14 -0
- data/lib/relaton/iso/model/structured_identifier.rb +31 -0
- data/lib/relaton/iso/processor.rb +84 -0
- data/lib/relaton/iso/scraper.rb +619 -0
- data/lib/relaton/iso/type/pubid.rb +50 -0
- data/lib/relaton/iso/util.rb +8 -0
- data/lib/relaton/iso.rb +30 -0
- data/lib/relaton/itu/bibliography.rb +90 -0
- data/lib/relaton/itu/data_fetcher.rb +104 -0
- data/lib/relaton/itu/data_parser_r.rb +140 -0
- data/lib/relaton/itu/hit.rb +22 -0
- data/lib/relaton/itu/hit_collection.rb +127 -0
- data/lib/relaton/itu/item_data.rb +6 -0
- data/lib/relaton/itu/model/approval_stage.rb +13 -0
- data/lib/relaton/itu/model/bibdata.rb +8 -0
- data/lib/relaton/itu/model/bibitem.rb +8 -0
- data/lib/relaton/itu/model/docidentifier.rb +9 -0
- data/lib/relaton/itu/model/doctype.rb +13 -0
- data/lib/relaton/itu/model/ext.rb +47 -0
- data/lib/relaton/itu/model/item.rb +13 -0
- data/lib/relaton/itu/model/meeting.rb +13 -0
- data/lib/relaton/itu/model/meeting_date.rb +15 -0
- data/lib/relaton/itu/model/question.rb +13 -0
- data/lib/relaton/itu/model/recommendation_status.rb +11 -0
- data/lib/relaton/itu/model/structured_identifier.rb +19 -0
- data/lib/relaton/itu/processor.rb +66 -0
- data/lib/relaton/itu/pubid.rb +177 -0
- data/lib/relaton/itu/radio_regulations_parser.rb +70 -0
- data/lib/relaton/itu/recommendation_parser.rb +161 -0
- data/lib/relaton/itu/scraper.rb +193 -0
- data/lib/relaton/itu/util.rb +8 -0
- data/lib/relaton/itu.rb +33 -0
- data/lib/relaton/jis/bibdata.rb +8 -0
- data/lib/relaton/jis/bibitem.rb +8 -0
- data/lib/relaton/jis/bibliography.rb +75 -0
- data/lib/relaton/jis/data_fetcher.rb +181 -0
- data/lib/relaton/jis/docidentifier.rb +21 -0
- data/lib/relaton/jis/doctype.rb +9 -0
- data/lib/relaton/jis/ext.rb +13 -0
- data/lib/relaton/jis/hit.rb +93 -0
- data/lib/relaton/jis/hit_collection.rb +127 -0
- data/lib/relaton/jis/item.rb +22 -0
- data/lib/relaton/jis/item_base.rb +26 -0
- data/lib/relaton/jis/item_data.rb +8 -0
- data/lib/relaton/jis/processor.rb +55 -0
- data/lib/relaton/jis/relation.rb +11 -0
- data/lib/relaton/jis/scraper.rb +232 -0
- data/lib/relaton/jis/structured_identifier.rb +13 -0
- data/lib/relaton/jis/util.rb +8 -0
- data/lib/relaton/jis.rb +33 -0
- data/lib/relaton/logger/channels/gh_issue.rb +78 -0
- data/lib/relaton/logger/config.rb +34 -0
- data/lib/relaton/logger/formatter_json.rb +8 -0
- data/lib/relaton/logger/formatter_string.rb +12 -0
- data/lib/relaton/logger/log.rb +64 -0
- data/lib/relaton/logger/log_device.rb +27 -0
- data/lib/relaton/logger/pool.rb +24 -0
- data/lib/relaton/logger.rb +18 -0
- data/lib/relaton/nist/bibdata.rb +8 -0
- data/lib/relaton/nist/bibitem.rb +8 -0
- data/lib/relaton/nist/bibliography.rb +191 -0
- data/lib/relaton/nist/comment_period.rb +15 -0
- data/lib/relaton/nist/data_fetcher.rb +84 -0
- data/lib/relaton/nist/date.rb +7 -0
- data/lib/relaton/nist/doctype.rb +7 -0
- data/lib/relaton/nist/ext.rb +16 -0
- data/lib/relaton/nist/hit.rb +18 -0
- data/lib/relaton/nist/hit_collection.rb +362 -0
- data/lib/relaton/nist/item.rb +17 -0
- data/lib/relaton/nist/item_data.rb +6 -0
- data/lib/relaton/nist/mods_parser.rb +276 -0
- data/lib/relaton/nist/processor.rb +68 -0
- data/lib/relaton/nist/pubs_export.rb +69 -0
- data/lib/relaton/nist/relation.rb +7 -0
- data/lib/relaton/nist/scraper.rb +290 -0
- data/lib/relaton/nist/series.yaml +49 -0
- data/lib/relaton/nist/util.rb +8 -0
- data/lib/relaton/nist.rb +34 -0
- data/lib/relaton/oasis/bibdata.rb +8 -0
- data/lib/relaton/oasis/bibitem.rb +8 -0
- data/lib/relaton/oasis/bibliography.rb +60 -0
- data/lib/relaton/oasis/browser_agent.rb +71 -0
- data/lib/relaton/oasis/data_fetcher.rb +94 -0
- data/lib/relaton/oasis/data_parser.rb +305 -0
- data/lib/relaton/oasis/data_parser_utils.rb +296 -0
- data/lib/relaton/oasis/data_part_parser.rb +239 -0
- data/lib/relaton/oasis/doctype.rb +7 -0
- data/lib/relaton/oasis/ext.rb +19 -0
- data/lib/relaton/oasis/item.rb +11 -0
- data/lib/relaton/oasis/item_data.rb +6 -0
- data/lib/relaton/oasis/processor.rb +68 -0
- data/lib/relaton/oasis/util.rb +8 -0
- data/lib/relaton/oasis.rb +28 -0
- data/lib/relaton/ogc/bibdata.rb +8 -0
- data/lib/relaton/ogc/bibitem.rb +8 -0
- data/lib/relaton/ogc/bibliography.rb +64 -0
- data/lib/relaton/ogc/data_fetcher.rb +110 -0
- data/lib/relaton/ogc/docidentifier.rb +6 -0
- data/lib/relaton/ogc/doctype.rb +12 -0
- data/lib/relaton/ogc/ext.rb +15 -0
- data/lib/relaton/ogc/hit.rb +18 -0
- data/lib/relaton/ogc/hit_collection.rb +36 -0
- data/lib/relaton/ogc/item.rb +13 -0
- data/lib/relaton/ogc/item_data.rb +6 -0
- data/lib/relaton/ogc/processor.rb +58 -0
- data/lib/relaton/ogc/scraper.rb +225 -0
- data/lib/relaton/ogc/util.rb +8 -0
- data/lib/relaton/ogc.rb +26 -0
- data/lib/relaton/oiml/bibdata.rb +8 -0
- data/lib/relaton/oiml/bibitem.rb +8 -0
- data/lib/relaton/oiml/bibliography.rb +94 -0
- data/lib/relaton/oiml/docidentifier.rb +33 -0
- data/lib/relaton/oiml/doctype.rb +13 -0
- data/lib/relaton/oiml/ext.rb +42 -0
- data/lib/relaton/oiml/item.rb +20 -0
- data/lib/relaton/oiml/item_base.rb +18 -0
- data/lib/relaton/oiml/item_data.rb +6 -0
- data/lib/relaton/oiml/processor.rb +54 -0
- data/lib/relaton/oiml/relation.rb +9 -0
- data/lib/relaton/oiml/util.rb +8 -0
- data/lib/relaton/oiml.rb +24 -0
- data/lib/relaton/omg/bibdata.rb +8 -0
- data/lib/relaton/omg/bibitem.rb +8 -0
- data/lib/relaton/omg/bibliography.rb +31 -0
- data/lib/relaton/omg/ext.rb +7 -0
- data/lib/relaton/omg/item.rb +8 -0
- data/lib/relaton/omg/item_data.rb +6 -0
- data/lib/relaton/omg/processor.rb +34 -0
- data/lib/relaton/omg/scraper.rb +141 -0
- data/lib/relaton/omg/util.rb +8 -0
- data/lib/relaton/omg.rb +24 -0
- data/lib/relaton/plateau/bibdata.rb +8 -0
- data/lib/relaton/plateau/bibitem.rb +8 -0
- data/lib/relaton/plateau/bibliography.rb +24 -0
- data/lib/relaton/plateau/data_fetcher.rb +153 -0
- data/lib/relaton/plateau/doctype.rb +7 -0
- data/lib/relaton/plateau/ext.rb +23 -0
- data/lib/relaton/plateau/handbook_parser.rb +95 -0
- data/lib/relaton/plateau/hit.rb +13 -0
- data/lib/relaton/plateau/hit_collection.rb +59 -0
- data/lib/relaton/plateau/item.rb +12 -0
- data/lib/relaton/plateau/item_data.rb +6 -0
- data/lib/relaton/plateau/parser.rb +101 -0
- data/lib/relaton/plateau/processor.rb +49 -0
- data/lib/relaton/plateau/technical_report_parser.rb +91 -0
- data/lib/relaton/plateau/util.rb +8 -0
- data/lib/relaton/plateau.rb +28 -0
- data/lib/relaton/un/bibdata.rb +8 -0
- data/lib/relaton/un/bibitem.rb +8 -0
- data/lib/relaton/un/bibliography.rb +48 -0
- data/lib/relaton/un/doctype.rb +10 -0
- data/lib/relaton/un/ext.rb +30 -0
- data/lib/relaton/un/hit.rb +56 -0
- data/lib/relaton/un/hit_collection.rb +61 -0
- data/lib/relaton/un/item.rb +11 -0
- data/lib/relaton/un/item_data.rb +6 -0
- data/lib/relaton/un/parser.rb +108 -0
- data/lib/relaton/un/processor.rb +38 -0
- data/lib/relaton/un/session.rb +25 -0
- data/lib/relaton/un/token_generator.rb +105 -0
- data/lib/relaton/un/util.rb +8 -0
- data/lib/relaton/un/wasm/decoder.rb +434 -0
- data/lib/relaton/un/wasm/instance.rb +101 -0
- data/lib/relaton/un/wasm/interpreter.rb +613 -0
- data/lib/relaton/un/wasm/memory.rb +112 -0
- data/lib/relaton/un/wasm/module.rb +47 -0
- data/lib/relaton/un/wasm.rb +17 -0
- data/lib/relaton/un/wasm_v_bg.wasm +0 -0
- data/lib/relaton/un.rb +28 -0
- data/lib/relaton/version.rb +1 -1
- data/lib/relaton/w3c/bibdata.rb +8 -0
- data/lib/relaton/w3c/bibitem.rb +8 -0
- data/lib/relaton/w3c/bibliography.rb +54 -0
- data/lib/relaton/w3c/data_fetcher.rb +309 -0
- data/lib/relaton/w3c/data_parser.rb +379 -0
- data/lib/relaton/w3c/doctype.rb +7 -0
- data/lib/relaton/w3c/ext.rb +11 -0
- data/lib/relaton/w3c/item.rb +12 -0
- data/lib/relaton/w3c/item_data.rb +6 -0
- data/lib/relaton/w3c/processor.rb +49 -0
- data/lib/relaton/w3c/pubid.rb +73 -0
- data/lib/relaton/w3c/safe_realize.rb +59 -0
- data/lib/relaton/w3c/util.rb +8 -0
- data/lib/relaton/w3c.rb +25 -0
- data/lib/relaton/xsf/bibdata.rb +8 -0
- data/lib/relaton/xsf/bibitem.rb +8 -0
- data/lib/relaton/xsf/bibliography.rb +24 -0
- data/lib/relaton/xsf/data_fetcher.rb +56 -0
- data/lib/relaton/xsf/hit.rb +17 -0
- data/lib/relaton/xsf/hit_collection.rb +24 -0
- data/lib/relaton/xsf/item.rb +7 -0
- data/lib/relaton/xsf/item_data.rb +6 -0
- data/lib/relaton/xsf/processor.rb +50 -0
- data/lib/relaton/xsf/util.rb +9 -0
- data/lib/relaton/xsf.rb +30 -0
- data/lib/relaton-core.rb +1 -0
- data/lib/relaton.rb +44 -9
- metadata +708 -150
- data/.github/workflows/rake.yml +0 -14
- data/.github/workflows/release.yml +0 -24
- data/.github/workflows/rubocop.yml +0 -48
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/.rubocop.yml +0 -12
- data/CLAUDE.md +0 -70
- data/Gemfile +0 -21
- data/Rakefile +0 -6
- data/docs/CHANGELOG.adoc +0 -16
- data/docs/VERSIONING_POLICY.adoc +0 -38
- data/docs/navigation.adoc +0 -6
- data/lib/relaton/config.rb +0 -24
- data/lib/relaton/db_cache.rb +0 -230
- data/lib/relaton/registry.rb +0 -118
- data/lib/relaton/util.rb +0 -7
- data/lib/relaton/workers_pool.rb +0 -21
- data/relaton.gemspec +0 -61
- data/spec/relaton/config_spec.rb +0 -10
- data/spec/relaton/db_cache_spec.rb +0 -51
- data/spec/relaton/db_spec.rb +0 -556
- data/spec/relaton/registry_spec.rb +0 -178
- data/spec/relaton/util_spec.rb +0 -3
- data/spec/relaton_spec.rb +0 -725
- data/spec/spec_helper.rb +0 -45
- data/spec/support/gb_t_20223_2006.xml +0 -33
- data/spec/support/iso_111111119115_1.xml +0 -0
- data/spec/support/iso_19115_1.xml +0 -115
- data/spec/support/iso_19115_2.xml +0 -95
- data/spec/support/rfc_8341.xml +0 -46
- data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +0 -12720
- data/spec/vcr_cassetes/api_relaton_org.yml +0 -121
- data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +0 -143
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +0 -199
- data/spec/vcr_cassetes/cie_001_1980.yml +0 -401
- data/spec/vcr_cassetes/cipm_meeting_43.yml +0 -1513
- data/spec/vcr_cassetes/doi_10_6028_nist_ir_8245.yml +0 -86
- data/spec/vcr_cassetes/ecma_6.yml +0 -112
- data/spec/vcr_cassetes/en_10160_1999.yml +0 -13624
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +0 -733
- data/spec/vcr_cassetes/ieee_528_2019.yml +0 -2786
- data/spec/vcr_cassetes/iso_111111119115_1.yml +0 -12951
- data/spec/vcr_cassetes/iso_19115_1.yml +0 -13177
- data/spec/vcr_cassetes/iso_19115_1_2.yml +0 -369
- data/spec/vcr_cassetes/iso_19115_1_std.yml +0 -13177
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +0 -229
- data/spec/vcr_cassetes/iso_19133_2005.yml +0 -148
- data/spec/vcr_cassetes/iso_combined_applied.yml +0 -364
- data/spec/vcr_cassetes/iso_combined_included.yml +0 -364
- data/spec/vcr_cassetes/iso_dis.yml +0 -157
- data/spec/vcr_cassetes/ogc_19_025r1.yml +0 -371
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +0 -317
- data/spec/vcr_cassetes/rfc_8341.yml +0 -1272
|
@@ -0,0 +1,767 @@
|
|
|
1
|
+
require_relative "../bib"
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Bib
|
|
5
|
+
module HashParserV1
|
|
6
|
+
include Core::ArrayWrapper
|
|
7
|
+
include Core::DateParser
|
|
8
|
+
extend self
|
|
9
|
+
|
|
10
|
+
# @param args [Hash]
|
|
11
|
+
# @return [Hash]
|
|
12
|
+
def hash_to_bib(args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
13
|
+
return nil unless args.is_a?(Hash)
|
|
14
|
+
|
|
15
|
+
ret = Marshal.load(Marshal.dump(symbolize(args))) # deep copy
|
|
16
|
+
ret[:fetched] &&= ::Date.parse(ret[:fetched])
|
|
17
|
+
ret.delete(:"schema-version")
|
|
18
|
+
ret.delete(:schema_version)
|
|
19
|
+
id_hash_to_bib ret
|
|
20
|
+
title_hash_to_bib(ret)
|
|
21
|
+
link_hash_to_bib(ret)
|
|
22
|
+
language_hash_to_bib(ret)
|
|
23
|
+
script_hash_to_bib(ret)
|
|
24
|
+
dates_hash_to_bib(ret)
|
|
25
|
+
docid_hash_to_bib(ret)
|
|
26
|
+
version_hash_to_bib(ret)
|
|
27
|
+
biblionote_hash_to_bib(ret)
|
|
28
|
+
abstract_hash_to_bib(ret)
|
|
29
|
+
formattedref_hash_to_bib(ret)
|
|
30
|
+
docstatus_hash_to_bib(ret)
|
|
31
|
+
contributors_hash_to_bib(ret)
|
|
32
|
+
editorialgroup_hash_to_bib(ret)
|
|
33
|
+
edition_hash_to_bib(ret)
|
|
34
|
+
copyright_hash_to_bib(ret)
|
|
35
|
+
relations_hash_to_bib(ret)
|
|
36
|
+
series_hash_to_bib(ret)
|
|
37
|
+
medium_hash_to_bib(ret)
|
|
38
|
+
place_hash_to_bib(ret)
|
|
39
|
+
extent_hash_to_bib(ret)
|
|
40
|
+
size_hash_to_bib(ret)
|
|
41
|
+
accesslocation_hash_to_bib(ret)
|
|
42
|
+
classification_hash_to_bib(ret)
|
|
43
|
+
validity_hash_to_bib(ret)
|
|
44
|
+
keyword_hash_to_bib(ret)
|
|
45
|
+
ret[:license] = array(ret[:license])
|
|
46
|
+
ext_hash_to_bib ret
|
|
47
|
+
ret
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def id_hash_to_bib(ret)
|
|
51
|
+
return unless ret[:id]
|
|
52
|
+
|
|
53
|
+
ret[:id] = ret[:id].gsub(/\W+/, "")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def ext_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize
|
|
57
|
+
ret[:ext] ||= {}
|
|
58
|
+
doctype_hash_to_bib ret
|
|
59
|
+
ret[:ext][:subdoctype] = ret.delete(:subdoctype) if ret[:subdoctype]
|
|
60
|
+
ret[:ext][:flavor] ||= flavor(ret)
|
|
61
|
+
ics_hash_to_bib ret
|
|
62
|
+
structuredidentifier_hash_to_bib ret
|
|
63
|
+
ret[:ext] = Bib::Ext.new(**ret[:ext])
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def flavor(ret)
|
|
67
|
+
return unless ret[:docid]
|
|
68
|
+
|
|
69
|
+
docid = ret[:docidentifier].find(&:primary)
|
|
70
|
+
return unless docid
|
|
71
|
+
|
|
72
|
+
docid.type.downcase
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def keyword_hash_to_bib(ret)
|
|
76
|
+
ret[:keyword] = array(ret[:keyword]).map do |keyword|
|
|
77
|
+
Bib::Keyword.new vocab: localizedstring(keyword)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def extent_hash_to_bib(ret)
|
|
82
|
+
return unless ret[:extent]
|
|
83
|
+
|
|
84
|
+
ret[:extent] = array(ret[:extent]).map do |e|
|
|
85
|
+
Relaton::Bib::Extent.new locality: locality(e[:locality]),
|
|
86
|
+
locality_stack: locality_stack(e[:locality_stack])
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def locality(locality)
|
|
91
|
+
array(locality).map { |l| Bib::Locality.new(**l) }
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def locality_stack(locality_stack)
|
|
95
|
+
array(locality_stack).map { |l| Bib::LocalityStack.new locality: locality(l[:locality]) }
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def size_hash_to_bib(ret)
|
|
99
|
+
return unless ret[:size]
|
|
100
|
+
|
|
101
|
+
ret[:size] = array(ret[:size])
|
|
102
|
+
value = ret[:size]&.map do |val|
|
|
103
|
+
val[:content] = val.delete(:value)
|
|
104
|
+
Bib::Size::Value.new(**val)
|
|
105
|
+
end
|
|
106
|
+
ret[:size] = Bib::Size.new(value: value)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def title_hash_to_bib(ret)
|
|
110
|
+
# return unless ret[:title]
|
|
111
|
+
|
|
112
|
+
# ret[:title] = array(ret[:title]).reduce(Bib::TitleCollection.new) do |m, t|
|
|
113
|
+
# m << (t.is_a?(Hash) ? Bib::Title.new(**t) : Bib::Title.new(content: t))
|
|
114
|
+
# end
|
|
115
|
+
ret[:title] &&= title_collection(ret[:title])
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def language_hash_to_bib(ret)
|
|
119
|
+
return unless ret[:language]
|
|
120
|
+
|
|
121
|
+
ret[:language] = array(ret[:language])
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def script_hash_to_bib(ret)
|
|
125
|
+
return unless ret[:script]
|
|
126
|
+
|
|
127
|
+
ret[:script] = array(ret[:script])
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def abstract_hash_to_bib(ret)
|
|
131
|
+
ret[:abstract] &&= array(ret[:abstract]).map do |a|
|
|
132
|
+
a = { content: a } if a.is_a?(String)
|
|
133
|
+
lang_scrip_array_to_string(a)
|
|
134
|
+
Bib::Abstract.new(**a)
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def link_hash_to_bib(ret)
|
|
139
|
+
return unless ret[:link]
|
|
140
|
+
|
|
141
|
+
ret[:source] = array(ret[:link]).map do |l|
|
|
142
|
+
Bib::Uri.new(**l)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def place_hash_to_bib(ret)
|
|
147
|
+
ret[:place] &&= array(ret[:place]).map { |pl| create_place(pl) }
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def create_place(place)
|
|
151
|
+
if place.is_a?(String)
|
|
152
|
+
Bib::Place.new(formatted_place: place)
|
|
153
|
+
else
|
|
154
|
+
place[:region] &&= create_region(place[:region])
|
|
155
|
+
place[:country] &&= create_region(place[:country])
|
|
156
|
+
Bib::Place.new(**place)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def create_region(region)
|
|
161
|
+
array(region).map do |r|
|
|
162
|
+
r[:content] ||= r.delete(:name)
|
|
163
|
+
r[:iso] ||= r.delete(:code)
|
|
164
|
+
Bib::Place::RegionType.new(**r)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def accesslocation_hash_to_bib(ret)
|
|
169
|
+
return unless ret[:accesslocation]
|
|
170
|
+
|
|
171
|
+
ret[:accesslocation] = array(ret[:accesslocation])
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def dates_hash_to_bib(ret)
|
|
175
|
+
ret[:date] &&= array(ret[:date]).map do |d|
|
|
176
|
+
# `at` is synonym of `on`, which is reserved word in YAML
|
|
177
|
+
d[:at] = d.delete(:value) if d[:value]
|
|
178
|
+
Bib::Date.new(**d)
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def docid_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize
|
|
183
|
+
return unless ret[:docid]
|
|
184
|
+
|
|
185
|
+
ret[:docidentifier] = array(ret[:docid]).map do |id|
|
|
186
|
+
id[:type] ||= id[:id].match(/^\w+(?=\s)/)&.to_s
|
|
187
|
+
id[:content] = id[:id]
|
|
188
|
+
create_docid(**id)
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def create_docid(**args)
|
|
193
|
+
Bib::Docidentifier.new(**args)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def version_hash_to_bib(ret)
|
|
197
|
+
return unless ret[:version]
|
|
198
|
+
|
|
199
|
+
ret[:version] = array(ret[:version]).map { |v| version_entry(v) }
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def version_entry(hash)
|
|
203
|
+
return Bib::Version.new(**hash) if hash[:content]
|
|
204
|
+
|
|
205
|
+
attrs = { content: legacy_version_content(hash) }
|
|
206
|
+
attrs[:type] = hash[:type] if hash[:type]
|
|
207
|
+
Bib::Version.new(**attrs)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def legacy_version_content(hash)
|
|
211
|
+
draft = hash[:draft]
|
|
212
|
+
revdate = hash[:revision_date]
|
|
213
|
+
return "#{draft} (#{revdate})" if draft && revdate
|
|
214
|
+
|
|
215
|
+
draft || revdate
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def biblionote_hash_to_bib(ret)
|
|
219
|
+
ret[:note] = array(ret.delete(:biblionote)).map do |n|
|
|
220
|
+
n.is_a?(String) ? Bib::Note.new(content: n) : Bib::Note.new(**n)
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def formattedref_hash_to_bib(ret)
|
|
225
|
+
ret[:formattedref] &&
|
|
226
|
+
ret[:formattedref] = formattedref(ret[:formattedref])
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def docstatus_hash_to_bib(ret)
|
|
230
|
+
ret[:docstatus] && ret[:status]= Bib::Status.new(
|
|
231
|
+
stage: stage(ret[:docstatus][:stage]),
|
|
232
|
+
substage: stage(ret[:docstatus][:substage]),
|
|
233
|
+
iteration: ret[:docstatus][:iteration],
|
|
234
|
+
)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# @param stg [Hash]
|
|
238
|
+
# @return [Relaton::Bib::DocumentStatus::Stage]
|
|
239
|
+
def stage(stg)
|
|
240
|
+
return unless stg
|
|
241
|
+
|
|
242
|
+
args = stg.is_a?(String) ? { content: stg } : stg
|
|
243
|
+
args[:content] ||= args.delete(:value)
|
|
244
|
+
Bib::Status::Stage.new(**args)
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def contributors_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength,Metrics/PerceivedComplexity
|
|
248
|
+
ret[:contributor] &&= array(ret[:contributor]).map do |c|
|
|
249
|
+
roles = array(c[:role]).map do |r|
|
|
250
|
+
if r.is_a? Hash
|
|
251
|
+
desc = array(r[:description]).map { |d| localized_marked_up_string d }
|
|
252
|
+
Bib::Contributor::Role.new(type: r[:type], description: desc)
|
|
253
|
+
else
|
|
254
|
+
Bib::Contributor::Role.new(type: r)
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
c[:role] = roles
|
|
258
|
+
(c[:person] &&= create_person(c[:person])) ||
|
|
259
|
+
(c[:organization] &&= create_organization(c[:organization]))
|
|
260
|
+
Bib::Contributor.new(**c)
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def edition_hash_to_bib(ret)
|
|
265
|
+
ret[:edition] &&= if ret[:edition].is_a?(Hash)
|
|
266
|
+
Bib::Edition.new(**ret[:edition])
|
|
267
|
+
else
|
|
268
|
+
Bib::Edition.new(content: ret[:edition])
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def create_organization(org)
|
|
273
|
+
return nil if org.nil?
|
|
274
|
+
|
|
275
|
+
Bib::Organization.new(**org_hash_to_bib(org))
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def org_hash_to_bib(org) # rubocop:disable Metrics/AbcSize
|
|
279
|
+
org[:identifier] = create_org_identifier(org[:identifier])
|
|
280
|
+
org[:subdivision] = create_org_subdivision(org[:subdivision])
|
|
281
|
+
org[:address] = address_hash_to_bib(org[:contact])
|
|
282
|
+
org[:phone] = phone_hash_to_bib(org[:contact])
|
|
283
|
+
org[:email] = email_hash_to_bib(org[:contact])
|
|
284
|
+
org[:uri] = uri_hash_to_bib(org[:contact] || org)
|
|
285
|
+
org[:logo] = array(org[:logo]).map do |l|
|
|
286
|
+
Bib::Logo.new(image: Bib::Image.new(**l[:image]))
|
|
287
|
+
end
|
|
288
|
+
org[:name] = typed_localized_string(org[:name])
|
|
289
|
+
org[:abbreviation] &&= localizedstring(org[:abbreviation])
|
|
290
|
+
org
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
def create_org_identifier(identifier)
|
|
294
|
+
array(identifier).map do |id|
|
|
295
|
+
Bib::Organization::Identifier.new(type: id[:type], content: id[:id])
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
def create_org_subdivision(subdivision)
|
|
300
|
+
array(subdivision).map do |sub|
|
|
301
|
+
if sub.is_a? String
|
|
302
|
+
orgname = Bib::TypedLocalizedString.new(content: sub)
|
|
303
|
+
Bib::Subdivision.new(name: [orgname])
|
|
304
|
+
elsif sub.is_a?(Hash) && sub[:content]
|
|
305
|
+
sub[:name] = sub.delete(:content)
|
|
306
|
+
Bib::Subdivision.new(**org_hash_to_bib(sub))
|
|
307
|
+
end
|
|
308
|
+
end.compact
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
def typed_localized_string(typed_strs)
|
|
312
|
+
array(typed_strs).map do |args|
|
|
313
|
+
if args.is_a? String
|
|
314
|
+
Bib::TypedLocalizedString.new(content: args)
|
|
315
|
+
elsif args.is_a? Hash
|
|
316
|
+
Bib::TypedLocalizedString.new(**args)
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
# def create_org_name(name)
|
|
322
|
+
# array(name).map do |nm|
|
|
323
|
+
# if nm.is_a?(Hash)
|
|
324
|
+
# Bib::Organization::Name.new(**nm)
|
|
325
|
+
# else
|
|
326
|
+
# Bib::Organization::Name.new(content: nm)
|
|
327
|
+
# end
|
|
328
|
+
# end
|
|
329
|
+
# end
|
|
330
|
+
|
|
331
|
+
def create_person(person)
|
|
332
|
+
Bib::Person.new(
|
|
333
|
+
name: fullname_hash_to_bib(person),
|
|
334
|
+
credential: array(person[:credential]),
|
|
335
|
+
affiliation: affiliation_hash_to_bib(person),
|
|
336
|
+
address: address_hash_to_bib(person[:contact]),
|
|
337
|
+
phone: phone_hash_to_bib(person[:contact]),
|
|
338
|
+
email: email_hash_to_bib(person[:contact]),
|
|
339
|
+
uri: uri_hash_to_bib(person[:contact]),
|
|
340
|
+
identifier: person_identifiers_hash_to_bib(person),
|
|
341
|
+
)
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
def fullname_hash_to_bib(person) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
345
|
+
n = person[:name]
|
|
346
|
+
fname = given_hash_to_bib n[:given] || n # `n` is for backward compatibility
|
|
347
|
+
Bib::FullName.new(
|
|
348
|
+
abbreviation: localizedstring(n[:abbreviation]),
|
|
349
|
+
forename: fname,
|
|
350
|
+
formatted_initials: localizedstring(n.dig(:given, :formatted_initials)),
|
|
351
|
+
addition: array(n[:addition])&.map { |f| localizedstring(f) },
|
|
352
|
+
prefix: array(n[:prefix])&.map { |f| localizedstring(f) },
|
|
353
|
+
surname: localizedstring(n[:surname]),
|
|
354
|
+
completename: localizedstring(n[:completename]),
|
|
355
|
+
)
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
def given_hash_to_bib(given)
|
|
359
|
+
return unless given
|
|
360
|
+
|
|
361
|
+
array(given[:forename])&.map { |f| forename_hash_to_bib(f) }
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
def forename_hash_to_bib(fname)
|
|
365
|
+
case fname
|
|
366
|
+
when Hash
|
|
367
|
+
lang_scrip_array_to_string fname
|
|
368
|
+
FullNameType::Forename.new(**fname)
|
|
369
|
+
when String then FullNameType::Forename.new(content: fname)
|
|
370
|
+
end
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
def person_identifiers_hash_to_bib(person)
|
|
374
|
+
array(person[:identifier])&.map do |a|
|
|
375
|
+
Bib::Person::Identifier.new(type: a[:type], content: a[:id])
|
|
376
|
+
end
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
def affiliation_hash_to_bib(person) # rubocop:disable Metrics/AbcSize
|
|
380
|
+
return [] unless person[:affiliation]
|
|
381
|
+
|
|
382
|
+
array(person[:affiliation]).map do |a|
|
|
383
|
+
a[:description] = array(a[:description]).map do |d|
|
|
384
|
+
localized_marked_up_string d
|
|
385
|
+
end
|
|
386
|
+
Bib::Affiliation.new(
|
|
387
|
+
organization: create_organization(a[:organization]),
|
|
388
|
+
description: a[:description], name: localizedstring(a[:name])
|
|
389
|
+
)
|
|
390
|
+
end
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
def address_hash_to_bib(contact)
|
|
394
|
+
array(contact).reduce([]) do |a, c|
|
|
395
|
+
next a unless c[:address]
|
|
396
|
+
|
|
397
|
+
a << create_address(c[:address])
|
|
398
|
+
end
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
def phone_hash_to_bib(contact)
|
|
402
|
+
array(contact).reduce([]) do |a, c|
|
|
403
|
+
next a unless c[:phone]
|
|
404
|
+
|
|
405
|
+
c[:type] ||= "work"
|
|
406
|
+
a << Bib::Phone.new(type: c[:type], content: c[:phone])
|
|
407
|
+
end
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
def email_hash_to_bib(contact)
|
|
411
|
+
array(contact).reduce([]) do |a, c|
|
|
412
|
+
next a unless c[:email]
|
|
413
|
+
|
|
414
|
+
a << c[:email]
|
|
415
|
+
end
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
def uri_hash_to_bib(contact)
|
|
419
|
+
array(contact).reduce([]) do |a, c|
|
|
420
|
+
next a unless c[:uri] || c[:url]
|
|
421
|
+
|
|
422
|
+
a << Bib::Uri.new(content: c[:uri] || c[:url])
|
|
423
|
+
end
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
# def contacts_hash_to_bib(entity) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity
|
|
427
|
+
# return [] unless entity[:contact]
|
|
428
|
+
|
|
429
|
+
# Relaton.array(entity[:contact]).map do |a|
|
|
430
|
+
# type, value = a.reject { |k, _| k == :type }.flatten
|
|
431
|
+
# case type
|
|
432
|
+
# when :street, :city, :state, :country, :postcode # it's for old version compatibility, should be removed in the future
|
|
433
|
+
# a[:street] = Relaton.array(a[:street])
|
|
434
|
+
# Bib::Address.new(**a)
|
|
435
|
+
# when :address then create_address(a[:address])
|
|
436
|
+
# when :phone, :email, :uri
|
|
437
|
+
# Bib::Contact.new(type: type.to_s, value: value, subtype: a[:type])
|
|
438
|
+
# else # it's for old version compatibility, should be removed in the future
|
|
439
|
+
# Bib::Contact.new(**a)
|
|
440
|
+
# end
|
|
441
|
+
# end
|
|
442
|
+
# end
|
|
443
|
+
|
|
444
|
+
def create_address(adr)
|
|
445
|
+
if adr.is_a?(Hash)
|
|
446
|
+
adr[:street] = array(adr[:street])
|
|
447
|
+
Bib::Address.new(**adr)
|
|
448
|
+
else
|
|
449
|
+
Bib::Address.new(formatted_address: adr)
|
|
450
|
+
end
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
# @param ret [Hash]
|
|
454
|
+
def copyright_hash_to_bib(ret)
|
|
455
|
+
ret[:copyright] &&= array(ret[:copyright]).map do |c|
|
|
456
|
+
c[:owner] = array(c[:owner]).map do |o|
|
|
457
|
+
create_contribution_info(o)
|
|
458
|
+
end
|
|
459
|
+
Bib::Copyright.new(**c)
|
|
460
|
+
end
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
def create_contribution_info(contrib)
|
|
464
|
+
if contrib[:name].is_a?(Hash) && (contrib[:name].keys & %i[prefix forename addition surname completename]).any?
|
|
465
|
+
Bib::ContributionInfo.new person: create_person(contrib)
|
|
466
|
+
else
|
|
467
|
+
Bib::ContributionInfo.new organization: create_organization(contrib)
|
|
468
|
+
end
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
# @param ret [Hash]
|
|
472
|
+
def relations_hash_to_bib(ret) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
|
473
|
+
return unless ret[:relation]
|
|
474
|
+
|
|
475
|
+
ret[:relation] &&= array(ret[:relation]).map do |rel|
|
|
476
|
+
rel[:description] = LocalizedMarkedUpString.new(**rel[:description]) if rel[:description]
|
|
477
|
+
relation_bibitem_hash_to_bib(rel)
|
|
478
|
+
relation_locality_hash_to_bib(rel)
|
|
479
|
+
relation_locality_stack_hash_to_bib(rel)
|
|
480
|
+
relaton_source_locality_stack_hash_to_bib(rel)
|
|
481
|
+
relation_source_locality_hash_to_bib(rel)
|
|
482
|
+
create_relation rel
|
|
483
|
+
end
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
def create_relation(rel)
|
|
487
|
+
Bib::Relation.new(**rel)
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
# @param rel [Hash] relation
|
|
491
|
+
def relation_bibitem_hash_to_bib(rel)
|
|
492
|
+
if rel[:bibitem]
|
|
493
|
+
rel[:bibitem] = bib_item hash_to_bib(rel[:bibitem])
|
|
494
|
+
else
|
|
495
|
+
Util.warn "Bibitem missing: `#(rel)`"
|
|
496
|
+
rel[:bibitem] = nil
|
|
497
|
+
end
|
|
498
|
+
end
|
|
499
|
+
|
|
500
|
+
# @param item_hash [Hash]
|
|
501
|
+
# @return [Relaton::Bib::Item]
|
|
502
|
+
def bib_item(item_hash)
|
|
503
|
+
ItemData.new(**item_hash)
|
|
504
|
+
end
|
|
505
|
+
|
|
506
|
+
# @param rel [Hash] relation
|
|
507
|
+
# @return [Relaton::Bib::LocalityStack]
|
|
508
|
+
def relation_locality_hash_to_bib(rel)
|
|
509
|
+
return unless rel[:locality]&.any?
|
|
510
|
+
|
|
511
|
+
rel[:locality] = array(rel[:locality]).map do |bl|
|
|
512
|
+
Bib::Locality.new(**bl)
|
|
513
|
+
end
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
def relation_locality_stack_hash_to_bib(rel)
|
|
517
|
+
return unless rel[:locality_stack]&.any?
|
|
518
|
+
|
|
519
|
+
rel[:locality_stack] = array(rel[:locality_stack]).map do |ls|
|
|
520
|
+
Bib::LocalityStack.new locality: relation_locality_hash_to_bib(ls)
|
|
521
|
+
end
|
|
522
|
+
end
|
|
523
|
+
|
|
524
|
+
# def locality_locality_stack(lls)
|
|
525
|
+
# if lls[:locality_stack]
|
|
526
|
+
# RelatonBib.array(lls[:locality_stack]).map do |lc|
|
|
527
|
+
# l = lc[:locality] || lc
|
|
528
|
+
# Locality.new(l[:type], l[:reference_from], l[:reference_to])
|
|
529
|
+
# end
|
|
530
|
+
# else
|
|
531
|
+
# [Locality.new(lls[:type], lls[:reference_from], lls[:reference_to])]
|
|
532
|
+
# end
|
|
533
|
+
# end
|
|
534
|
+
|
|
535
|
+
# @param rel [Hash] relation
|
|
536
|
+
def relation_source_locality_hash_to_bib(rel)
|
|
537
|
+
rel[:source_locality] = array(rel[:source_locality]).map do |loc|
|
|
538
|
+
Bib::Locality.new(**loc)
|
|
539
|
+
end
|
|
540
|
+
end
|
|
541
|
+
|
|
542
|
+
def relaton_source_locality_stack_hash_to_bib(rel) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
|
|
543
|
+
sls = array(rel[:source_locality_stack])
|
|
544
|
+
array(rel[:source_locality]).each do |loc|
|
|
545
|
+
sls << array(loc[:source_locality_stack]) if loc[:source_locality_stack]
|
|
546
|
+
end
|
|
547
|
+
|
|
548
|
+
case rel[:source_locality]
|
|
549
|
+
when Hash then rel[:source_locality].delete(:source_locality_stack)
|
|
550
|
+
when Array then rel[:source_locality].delete_if { |loc| loc[:source_locality_stack] }
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
rel[:source_locality_stack] = sls.map do |loc|
|
|
554
|
+
SourceLocalityStack.new source_locality: relation_source_locality_hash_to_bib(source_locality: loc)
|
|
555
|
+
end
|
|
556
|
+
end
|
|
557
|
+
|
|
558
|
+
# @param ret [Hash]
|
|
559
|
+
def series_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
560
|
+
ret[:series] &&= array(ret[:series]).map do |s|
|
|
561
|
+
s[:formattedref] && s[:formattedref] = formattedref(s[:formattedref])
|
|
562
|
+
s[:title] &&= title_collection(s[:title])
|
|
563
|
+
s[:place] &&= create_place(s[:place])
|
|
564
|
+
s[:abbreviation] &&= localizedstring(s[:abbreviation])
|
|
565
|
+
s[:from] &&= s[:from].to_s
|
|
566
|
+
s[:to] &&= s[:to].to_s
|
|
567
|
+
Bib::Series.new(**s)
|
|
568
|
+
end
|
|
569
|
+
end
|
|
570
|
+
|
|
571
|
+
#
|
|
572
|
+
# @param title [Hash, Strinbg, Array<Hash, String>]
|
|
573
|
+
#
|
|
574
|
+
# @return [Relaton::Bib::TitleCollection]
|
|
575
|
+
#
|
|
576
|
+
def title_collection(title)
|
|
577
|
+
array(title).map do |t|
|
|
578
|
+
if t.is_a?(Hash)
|
|
579
|
+
lang_scrip_array_to_string t
|
|
580
|
+
Bib::Title.new(**t)
|
|
581
|
+
elsif t.is_a?(String)
|
|
582
|
+
Bib::Title.new(content: t)
|
|
583
|
+
end
|
|
584
|
+
end
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
# @param ret [Hash]
|
|
588
|
+
def medium_hash_to_bib(ret)
|
|
589
|
+
ret[:medium] = Bib::Medium.new(**ret[:medium]) if ret[:medium]
|
|
590
|
+
end
|
|
591
|
+
|
|
592
|
+
# @param ret [Hash]
|
|
593
|
+
def classification_hash_to_bib(ret)
|
|
594
|
+
if ret[:classification]
|
|
595
|
+
ret[:classification] = array(ret[:classification]).map do |cls|
|
|
596
|
+
cls[:content] ||= cls.delete(:value)
|
|
597
|
+
Docidentifier.new(**cls)
|
|
598
|
+
end
|
|
599
|
+
end
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
# @param ret [Hash]
|
|
603
|
+
def validity_hash_to_bib(ret)
|
|
604
|
+
return unless ret[:validity]
|
|
605
|
+
|
|
606
|
+
b = parse_validity_time(ret[:validity], :begins)
|
|
607
|
+
e = parse_validity_time(ret[:validity], :ends)
|
|
608
|
+
r = parse_validity_time(ret[:validity], :revision)
|
|
609
|
+
ret[:validity] = Bib::Validity.new(begins: b, ends: e, revision: r)
|
|
610
|
+
end
|
|
611
|
+
|
|
612
|
+
def parse_validity_time(val, period)
|
|
613
|
+
t = val[period]&.to_s
|
|
614
|
+
return unless t
|
|
615
|
+
|
|
616
|
+
p = period == :ends ? -1 : 1
|
|
617
|
+
case t
|
|
618
|
+
when /^\d{4}$/
|
|
619
|
+
::Date.new(t.to_i, p, p).to_datetime.to_time.utc
|
|
620
|
+
when /^(?<year>\d{4})-(?<month>\d{1,2})$/
|
|
621
|
+
::Date.new($~[:year].to_i, $~[:month].to_i, p).to_datetime.to_time.utc
|
|
622
|
+
else
|
|
623
|
+
# Default to UTC when no timezone is specified
|
|
624
|
+
t += " UTC" unless t.match?(/[+-]\d{2}:?\d{2}\s*$|Z\s*$/i)
|
|
625
|
+
::Time.parse t
|
|
626
|
+
end
|
|
627
|
+
end
|
|
628
|
+
|
|
629
|
+
# @param ret [Hash]
|
|
630
|
+
def editorialgroup_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
|
631
|
+
eg = ret.dig(:ext, :editorialgroup) || ret[:editorialgroup]
|
|
632
|
+
return unless eg
|
|
633
|
+
|
|
634
|
+
ret[:ext]&.delete(:editorialgroup)
|
|
635
|
+
ret.delete(:editorialgroup)
|
|
636
|
+
ret[:contributor] ||= []
|
|
637
|
+
array(eg).each do |wg|
|
|
638
|
+
wg[:content] ||= wg.delete(:name)
|
|
639
|
+
ret[:contributor] << Bib::Contributor.new(
|
|
640
|
+
role: [Bib::Contributor::Role.new(
|
|
641
|
+
type: "author",
|
|
642
|
+
description: [Bib::LocalizedMarkedUpString.new(content: "committee")],
|
|
643
|
+
)],
|
|
644
|
+
organization: Bib::Organization.new(
|
|
645
|
+
name: wg[:prefix] ? [Bib::TypedLocalizedString.new(content: wg[:prefix])] : [],
|
|
646
|
+
subdivision: [Bib::Subdivision.new(
|
|
647
|
+
type: "technical-committee",
|
|
648
|
+
subtype: wg[:type],
|
|
649
|
+
name: [Bib::TypedLocalizedString.new(content: wg[:content])],
|
|
650
|
+
identifier: eg_identifiers(wg),
|
|
651
|
+
)],
|
|
652
|
+
abbreviation: wg[:prefix] ? Bib::LocalizedString.new(content: wg[:prefix]) : nil,
|
|
653
|
+
),
|
|
654
|
+
)
|
|
655
|
+
end
|
|
656
|
+
end
|
|
657
|
+
|
|
658
|
+
def eg_identifiers(workgroup) # rubocop:disable Metrics/MethodLength
|
|
659
|
+
ids = []
|
|
660
|
+
if workgroup[:number]
|
|
661
|
+
ids << Bib::OrganizationType::Identifier.new(
|
|
662
|
+
content: workgroup[:number].to_s,
|
|
663
|
+
)
|
|
664
|
+
end
|
|
665
|
+
if workgroup[:identifier]
|
|
666
|
+
ids << Bib::OrganizationType::Identifier.new(
|
|
667
|
+
content: workgroup[:identifier],
|
|
668
|
+
)
|
|
669
|
+
end
|
|
670
|
+
ids
|
|
671
|
+
end
|
|
672
|
+
|
|
673
|
+
# @param ret [Hash]
|
|
674
|
+
def ics_hash_to_bib(ret)
|
|
675
|
+
ics = ret.dig(:ext, :ics) || ret[:ics] # @todo remove ret[:ics] in the future
|
|
676
|
+
return unless ics
|
|
677
|
+
|
|
678
|
+
ret[:ext][:ics] = array(ics).map { |item| Bib::ICS.new(**item) }
|
|
679
|
+
end
|
|
680
|
+
|
|
681
|
+
# @param ret [Hash]
|
|
682
|
+
def structuredidentifier_hash_to_bib(ret)
|
|
683
|
+
struct_id = ret.dig(:ext, :structuredidentifier) || ret[:structuredidentifier] # @todo remove ret[:structuredidentifier] in the future
|
|
684
|
+
return unless struct_id
|
|
685
|
+
|
|
686
|
+
sids = array(struct_id).map do |si|
|
|
687
|
+
si[:agency] = array si[:agency]
|
|
688
|
+
si[:klass] = si.delete(:class)
|
|
689
|
+
Bib::StructuredIdentifier.new(**si)
|
|
690
|
+
end
|
|
691
|
+
ret[:ext][:structuredidentifier] = sids
|
|
692
|
+
end
|
|
693
|
+
|
|
694
|
+
# @param ogj [Hash, Array, String]
|
|
695
|
+
# @return [Hash, Array, String]
|
|
696
|
+
def symbolize(obj)
|
|
697
|
+
case obj
|
|
698
|
+
when Hash
|
|
699
|
+
obj.reduce({}) do |memo, (k, v)|
|
|
700
|
+
memo[k.to_sym] = symbolize(v)
|
|
701
|
+
memo
|
|
702
|
+
end
|
|
703
|
+
when Array then obj.reduce([]) { |memo, v| memo << symbolize(v) }
|
|
704
|
+
else obj
|
|
705
|
+
end
|
|
706
|
+
end
|
|
707
|
+
|
|
708
|
+
# @param lst [Hash, Array<Relaton::Bib::LocalizedString>, String]
|
|
709
|
+
# @return [Relaton::Bib::LocalizedString]
|
|
710
|
+
def localizedstring(lst)
|
|
711
|
+
return unless lst
|
|
712
|
+
|
|
713
|
+
if lst.is_a?(Hash)
|
|
714
|
+
lang_scrip_array_to_string lst
|
|
715
|
+
Bib::LocalizedString.new(**lst)
|
|
716
|
+
else Bib::LocalizedString.new(content: lst)
|
|
717
|
+
end
|
|
718
|
+
end
|
|
719
|
+
|
|
720
|
+
def lang_scrip_array_to_string(lst)
|
|
721
|
+
lst[:language] = lst[:language][0] if lst[:language].is_a?(Array)
|
|
722
|
+
lst[:script] = lst[:script][0] if lst[:script].is_a?(Array)
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
def localized_marked_up_string(lst)
|
|
726
|
+
return unless lst
|
|
727
|
+
|
|
728
|
+
if lst.is_a?(Hash)
|
|
729
|
+
lang_scrip_array_to_string lst
|
|
730
|
+
LocalizedMarkedUpString.new(**lst)
|
|
731
|
+
else LocalizedMarkedUpString.new(content: lst)
|
|
732
|
+
end
|
|
733
|
+
end
|
|
734
|
+
|
|
735
|
+
# @param frf [Hash, String]
|
|
736
|
+
# @return [Relaton::Bib::Formattedref]
|
|
737
|
+
def formattedref(frf)
|
|
738
|
+
if frf.is_a?(Hash)
|
|
739
|
+
lang_scrip_array_to_string(frf)
|
|
740
|
+
Relaton::Bib::Formattedref.new(**frf)
|
|
741
|
+
else
|
|
742
|
+
Relaton::Bib::Formattedref.new(content: frf)
|
|
743
|
+
end
|
|
744
|
+
end
|
|
745
|
+
|
|
746
|
+
def doctype_hash_to_bib(ret)
|
|
747
|
+
doctype = ret.dig(:ext, :doctype) || ret[:doctype] # @todo remove ret[:doctype] in the future
|
|
748
|
+
return unless doctype
|
|
749
|
+
|
|
750
|
+
ret[:ext][:doctype] = create_doctype(doctype_args(doctype))
|
|
751
|
+
end
|
|
752
|
+
|
|
753
|
+
def doctype_args(args)
|
|
754
|
+
if args.is_a?(String)
|
|
755
|
+
{ content: args }
|
|
756
|
+
else
|
|
757
|
+
args[:content] = args.delete(:type)
|
|
758
|
+
args
|
|
759
|
+
end
|
|
760
|
+
end
|
|
761
|
+
|
|
762
|
+
def create_doctype(args)
|
|
763
|
+
Bib::Doctype.new(**args)
|
|
764
|
+
end
|
|
765
|
+
end
|
|
766
|
+
end
|
|
767
|
+
end
|