bolognese 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +16 -16
- data/README.md +9 -0
- data/lib/bolognese.rb +0 -8
- data/lib/bolognese/array.rb +2 -2
- data/lib/bolognese/author_utils.rb +18 -6
- data/lib/bolognese/cli.rb +2 -17
- data/lib/bolognese/datacite_utils.rb +8 -7
- data/lib/bolognese/metadata.rb +291 -178
- data/lib/bolognese/readers/bibtex_reader.rb +66 -0
- data/lib/bolognese/readers/citeproc_reader.rb +74 -0
- data/lib/bolognese/readers/codemeta_reader.rb +71 -0
- data/lib/bolognese/readers/crosscite_reader.rb +12 -0
- data/lib/bolognese/readers/crossref_reader.rb +209 -0
- data/lib/bolognese/readers/datacite_json_reader.rb +75 -0
- data/lib/bolognese/readers/datacite_reader.rb +181 -0
- data/lib/bolognese/readers/ris_reader.rb +84 -0
- data/lib/bolognese/readers/schema_org_reader.rb +119 -0
- data/lib/bolognese/utils.rb +42 -67
- data/lib/bolognese/version.rb +1 -1
- data/lib/bolognese/writers/bibtex_writer.rb +25 -0
- data/lib/bolognese/writers/citeproc_writer.rb +29 -0
- data/lib/bolognese/writers/codemeta_writer.rb +25 -0
- data/lib/bolognese/writers/crosscite_writer.rb +49 -0
- data/lib/bolognese/writers/crossref_writer.rb +9 -0
- data/lib/bolognese/writers/datacite_json_writer.rb +45 -0
- data/lib/bolognese/writers/datacite_writer.rb +10 -0
- data/lib/bolognese/writers/rdf_xml_writer.rb +9 -0
- data/lib/bolognese/writers/ris_writer.rb +26 -0
- data/lib/bolognese/writers/schema_org_writer.rb +45 -0
- data/lib/bolognese/writers/turtle_writer.rb +9 -0
- data/spec/author_utils_spec.rb +74 -34
- data/spec/cli_spec.rb +6 -6
- data/spec/datacite_utils_spec.rb +10 -11
- data/spec/doi_utils_spec.rb +2 -1
- data/spec/fixtures/crossref.ris +2 -1
- data/spec/fixtures/datacite.json +6 -9
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/default.yml +9 -7
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_bibtex.yml +9 -7
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_crossref.yml +6 -6
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_datacite.yml +6 -6
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_schema_org.yml +8 -6
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/default.yml +10 -6
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_bibtex.yml +8 -6
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_datacite.yml +11 -7
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_datacite_json.yml +10 -6
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_schema_org.yml +10 -6
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/default.yml +201 -200
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/to_bibtex.yml +201 -200
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/to_datacite.yml +201 -200
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/to_schema_org.yml +201 -200
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/is_personal_name_/has_type_organization.yml → Bolognese_Metadata/authors_as_string/author.yml} +61 -2
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/authors_as_string/single_author.yml → Bolognese_Metadata/authors_as_string/no_author.yml} +60 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/authors_as_string/single_author.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/authors_as_string/with_organization.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_from_url/doi.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_from_url/not_a_doi.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_from_url/url.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/crossref.yml +204 -6
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/datacite.yml +204 -4
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/medra.yml +204 -4
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/not_a_valid_prefix.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/not_found.yml +204 -4
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/crossref.yml +102 -4
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/crossref_doi_not_url.yml +100 -4
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/datacite.yml +102 -4
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/datacite_doi_http.yml +100 -4
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/github.yml +97 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/orcid.yml +99 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_name_identifier/has_ORCID.yml → Bolognese_Metadata/find_from_format_by_ID/schema_org.yml} +61 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/bibtex.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/citeproc.yml +99 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_one_author/has_familyName.yml → Bolognese_Metadata/find_from_format_from_file/codemeta.yml} +61 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/crossref.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/datacite.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/datacite_json.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/ris.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/schema_org.yml +97 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/is_personal_name_/has_no_info.yml → Bolognese_Metadata/from_schema_org/with_id.yml} +59 -2
- data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata → Bolognese_Metadata/get_codemeta_metadata}/maremma.yml +9 -9
- data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata → Bolognese_Metadata/get_codemeta_metadata}/no_codemeta_json.yml +8 -8
- data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata → Bolognese_Metadata/get_codemeta_metadata}/not_found_error.yml +8 -8
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/DOI_with_ORCID_ID.yml +61 -2
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/DOI_with_SICI_DOI.yml +62 -3
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/DOI_with_data_citation.yml +61 -2
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/date_in_future.yml +61 -2
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/journal_article.yml +62 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/not_found_error.yml +97 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/posted_content.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/BlogPosting.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Dataset.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Funding_schema_version_4.yml +97 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata → Bolognese_Metadata/get_datacite_metadata}/author_only_full_name.yml +61 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/author_with_scheme.yml +97 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_name_identifier/has_no_ORCID.yml → Bolognese_Metadata/get_datacite_metadata/date.yml} +63 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/funding_schema_version_3.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/is_identical_to.yml +99 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata → Bolognese_Metadata/get_datacite_metadata}/keywords_with_attributes.yml +64 -3
- data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata → Bolognese_Metadata/get_datacite_metadata}/multiple_author_names_in_one_creatorName.yml +63 -2
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_one_author/has_name_in_display-order.yml → Bolognese_Metadata/get_datacite_metadata/multiple_licenses.yml} +63 -2
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata/posted_content.yml → Bolognese_Metadata/get_date_from_date_parts/date.yml} +59 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_from_date_parts/year-month.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_from_date_parts/year.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_parts/date.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_parts/year-month.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_parts/year.yml +201 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_name_identifier/has_ORCID.yml +136 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_name_identifier/has_jacow_org_scheme.yml +136 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_name_identifier/has_no_ORCID.yml +136 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_familyName.yml +136 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_multiple_names_in_display-order.yml +136 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_name_in_Thai.yml +134 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_name_in_display-order.yml +136 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_name_in_display-order_with_ORCID.yml +136 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_name_in_sort-order.yml +136 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/hyper-authorship.yml +132 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/is_organization.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/multiple_author_names_in_one_field.yml +136 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_SchemaOrg/get_metadata → Bolognese_Metadata/get_schema_org_metadata}/BlogPosting.yml +201 -200
- data/spec/fixtures/vcr_cassettes/{Bolognese_SchemaOrg/get_metadata → Bolognese_Metadata/get_schema_org_metadata}/not_found_error.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_alternate_identifiers/insert.yml +97 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_contributors/none.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_creators/insert.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_dates/insert.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_descriptions/insert.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_identifier/doi.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_person/creator_only_name.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_publication_year/insert.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_publisher/insert.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers/insert.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers/related_identifier.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_resource_type/insert.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_rights_list/insert.yml +97 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_subjects/insert.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_titles/insert.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_version/insert.yml +97 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/is_personal_name_/has_comma.yml +203 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref → Bolognese_Metadata}/is_personal_name_/has_family_name.yml +61 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/is_personal_name_/has_id.yml +201 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref → Bolognese_Metadata}/is_personal_name_/has_known_given_name.yml +61 -2
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/is_personal_name_/has_type_person.yml → Bolognese_Metadata/is_personal_name_/has_no_info.yml} +61 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/is_personal_name_/has_type_organization.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/missing_comma.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/nil.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/overlapping_keys.yml +97 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/valid.yml +99 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/authors_as_string/author.yml → Bolognese_Metadata/normalize_doi/SICI_doi.yml} +59 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/doi.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/doi_from_url_without_doi_proxy.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/doi_prefix_too_long.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/doi_prefix_with_string.yml +203 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/authors_as_string/no_author.yml → Bolognese_Metadata/normalize_doi/doi_with_protocol.yml} +59 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/dx_doi_org_url.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/https_url.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/not_valid_doi_prefix.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/url_with_one_slash.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/doi.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/doi_as_url.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/ftp.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/invalid_url.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/string.yml +203 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_one_author/is_organization.yml → Bolognese_Metadata/normalize_id/url.yml} +59 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/url_with_utf-8.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_ids/doi.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_ids/url.yml +203 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/is_personal_name_/has_comma.yml → Bolognese_Metadata/normalize_url/uri.yml} +2 -2
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/authors_as_string/with_organization.yml → Bolognese_Metadata/normalize_url/with_trailing_slash.yml} +2 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/parse_attributes/array.yml +203 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/is_personal_name_/has_id.yml → Bolognese_Metadata/parse_attributes/hash.yml} +59 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/parse_attributes/nil.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/parse_attributes/string.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/sanitize/should_only_keep_specific_tags.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/sanitize/should_remove_a_tags.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/to_schema_org/with_id.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/validate_url/DOI.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/validate_url/ISSN.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/validate_url/URL.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/validate_url/string.yml +203 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_bibtex/BlogPosting.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_bibtex/Dataset.yml +99 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_SchemaOrg/get_metadata/BlogPosting_schema_org_JSON.yml → Bolognese_Metadata/write_metadata_as_bibtex/from_schema_org.yml} +201 -200
- data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_datacite_xml → Bolognese_Metadata/write_metadata_as_bibtex}/maremma.yml +9 -9
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_bibtex/with_data_citation.yml +731 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_citeproc → Bolognese_Metadata/write_metadata_as_bibtex}/with_pages.yml +61 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/BlogPosting.yml +99 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_SchemaOrg/get_metadata_as_bibtex/with_data_citation.yml → Bolognese_Metadata/write_metadata_as_citeproc/BlogPosting_schema_org.yml} +201 -200
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/Dataset.yml +99 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_citeproc → Bolognese_Metadata/write_metadata_as_citeproc}/journal_article.yml +62 -3
- data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_ris → Bolognese_Metadata/write_metadata_as_citeproc}/maremma.yml +8 -8
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_ris → Bolognese_Metadata/write_metadata_as_citeproc}/with_pages.yml +61 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_codemeta/SoftwareSourceCode_DataCite.yml +99 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_bibtex → Bolognese_Metadata/write_metadata_as_crosscite}/maremma.yml +9 -9
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_datacite_xml → Bolognese_Metadata/write_metadata_as_crosscite}/with_ORCID_ID.yml +61 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_crosscite/with_data_citation.yml +731 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_SchemaOrg/get_metadata_as_citeproc/BlogPosting.yml → Bolognese_Metadata/write_metadata_as_crosscite/with_data_citation_schema_org.yml} +201 -200
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_datacite_xml → Bolognese_Metadata/write_metadata_as_crosscite}/with_editor.yml +62 -3
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_one_author/has_name_in_sort-order.yml → Bolognese_Metadata/write_metadata_as_crossref/from_DataCite.yml} +61 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_json/maremma.yml +100 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_json/with_ORCID_ID.yml +377 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_datacite_xml → Bolognese_Metadata/write_metadata_as_datacite_json}/with_data_citation.yml +61 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_json/with_data_citation_schema_org.yml +654 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_xml/Dataset_in_schema_4_0.yml +97 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_citeproc → Bolognese_Metadata/write_metadata_as_datacite_xml}/maremma.yml +9 -9
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_xml/with_ORCID_ID.yml +377 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_ris/journal_article.yml → Bolognese_Metadata/write_metadata_as_datacite_xml/with_data_citation.yml} +61 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_xml/with_data_citation_schema_org.yml +654 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_xml/with_editor.yml +944 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_DataciteJson/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_rdf_xml}/BlogPosting.yml +88 -23
- data/spec/fixtures/vcr_cassettes/{Bolognese_Citeproc/get_metadata_as_rdf_xml/BlogPosting.yml → Bolognese_Metadata/write_metadata_as_rdf_xml/BlogPosting_Citeproc_JSON.yml} +26 -20
- data/spec/fixtures/vcr_cassettes/{Bolognese_Bibtex/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_rdf_xml}/Crossref_DOI.yml +26 -20
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_rdf_xml}/journal_article.yml +87 -22
- data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_rdf_xml}/maremma.yml +35 -29
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_turtle → Bolognese_Metadata/write_metadata_as_rdf_xml}/with_pages.yml +88 -23
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_ris/BlogPosting.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_ris/BlogPosting_schema_org.yml +654 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_ris/Dataset.yml +99 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_bibtex/with_data_citation.yml → Bolognese_Metadata/write_metadata_as_ris/journal_article.yml} +59 -2
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_ris/maremma.yml +100 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_bibtex → Bolognese_Metadata/write_metadata_as_ris}/with_pages.yml +62 -3
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_schema_org/Schema_org_JSON_IsSupplementTo.yml +99 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_schema_org/Schema_org_JSON_isReferencedBy.yml +99 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata/Schema_org_JSON.yml → Bolognese_Metadata/write_metadata_as_schema_org/journal_article.yml} +61 -2
- data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata → Bolognese_Metadata/write_metadata_as_schema_org}/maremma_schema_org_JSON.yml +9 -9
- data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_turtle}/BlogPosting.yml +88 -23
- data/spec/fixtures/vcr_cassettes/{Bolognese_Citeproc/get_metadata_as_turtle/BlogPosting.yml → Bolognese_Metadata/write_metadata_as_turtle/BlogPosting_Citeproc_JSON.yml} +26 -20
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_turtle/BlogPosting_DataCite_JSON.yml +4589 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Bibtex/get_metadata_as_turtle → Bolognese_Metadata/write_metadata_as_turtle}/Crossref_DOI.yml +26 -20
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_turtle/DataONE.yml +4589 -0
- data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata_as_turtle → Bolognese_Metadata/write_metadata_as_turtle}/Dataset.yml +88 -23
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_turtle → Bolognese_Metadata/write_metadata_as_turtle}/journal_article.yml +87 -22
- data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_turtle}/with_pages.yml +87 -22
- data/spec/metadata_spec.rb +8 -2
- data/spec/readers/bibtex_reader_spec.rb +30 -0
- data/spec/readers/citeproc_reader_spec.rb +28 -0
- data/spec/readers/codemeta_reader_spec.rb +90 -0
- data/spec/readers/crossref_reader_spec.rb +142 -0
- data/spec/readers/datacite_json_reader_spec.rb +48 -0
- data/spec/readers/datacite_reader_spec.rb +215 -0
- data/spec/readers/ris_reader_spec.rb +32 -0
- data/spec/readers/schema_org_reader_spec.rb +63 -0
- data/spec/utils_spec.rb +24 -25
- data/spec/writers/bibtex_writer_spec.rb +102 -0
- data/spec/writers/citeproc_writer_spec.rb +138 -0
- data/spec/writers/codemeta_writer_spec.rb +36 -0
- data/spec/writers/crosscite_writer_spec.rb +81 -0
- data/spec/writers/crossref_writer_spec.rb +19 -0
- data/spec/writers/datacite_json_writer_spec.rb +74 -0
- data/spec/writers/datacite_writer_spec.rb +124 -0
- data/spec/writers/rdf_xml_writer_spec.rb +97 -0
- data/spec/writers/ris_writer_spec.rb +153 -0
- data/spec/writers/schema_org_writer_spec.rb +59 -0
- data/spec/writers/turtle_writer_spec.rb +82 -0
- metadata +213 -132
- data/codemeta.json +0 -39
- data/lib/bolognese/bibtex.rb +0 -163
- data/lib/bolognese/citeproc.rb +0 -120
- data/lib/bolognese/codemeta.rb +0 -153
- data/lib/bolognese/crossref.rb +0 -281
- data/lib/bolognese/datacite.rb +0 -288
- data/lib/bolognese/datacite_json.rb +0 -220
- data/lib/bolognese/ris.rb +0 -117
- data/lib/bolognese/schema_org.rb +0 -196
- data/spec/bibtex_spec.rb +0 -90
- data/spec/citeproc_spec.rb +0 -66
- data/spec/codemeta_spec.rb +0 -221
- data/spec/crossref_spec.rb +0 -348
- data/spec/datacite_json_spec.rb +0 -125
- data/spec/datacite_spec.rb +0 -406
- data/spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_schema_org_JSON/maremma.yml +0 -100
- data/spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_turtle/maremma.yml +0 -4680
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/not_found_error.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_string/DOI_with_data_citation.yml +0 -672
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/author.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/has_multiple_names_in_display-order.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/has_name_in_Thai.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/has_name_in_display-order_with_ORCID.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/hyper-authorship.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/multiple_author_names.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/multiple_author_names_in_one_field.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/BlogPosting.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Dataset.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Date.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Funding_schema_version_3.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Funding_schema_version_4.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Schema_org_JSON_IsSupplementTo.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Schema_org_JSON_isReferencedBy.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/author.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/author_with_scheme.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/is_identical_to.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/jsonlint.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/multiple_licenses.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_bibtex/BlogPosting.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_bibtex/Dataset.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_citeproc/BlogPosting.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_citeproc/Dataset.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_codemeta/SoftwareSourceCode.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_datacite_xml_4_0/Dataset.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_ris/BlogPosting.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_ris/Dataset.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_turtle/BlogPosting.yml +0 -4620
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_alternate_identifiers/insert.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_contributors/none.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_creators/insert.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_dates/insert.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_descriptions/insert.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_identifier/doi.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_person/creator_only_name.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_publication_year/insert.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_publisher/insert.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_related_identifiers/insert.yml +0 -38
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_related_identifiers/related_identifier.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_resource_type/insert.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_rights_list/insert.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_subjects/insert.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_titles/insert.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_version/insert.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_DataciteJson/get_metadata_as_turtle/BlogPosting.yml +0 -4583
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/generate/datacite.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/read/datacite.yml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_datacite_xml/with_data_citation.yml +0 -653
- data/spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_ris/BlogPosting.yml +0 -653
- data/spec/schema_org_spec.rb +0 -151
@@ -1,220 +0,0 @@
|
|
1
|
-
module Bolognese
|
2
|
-
class DataciteJson < Metadata
|
3
|
-
|
4
|
-
def initialize(string: nil, regenerate: false)
|
5
|
-
if string.present?
|
6
|
-
@raw = string
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def metadata
|
11
|
-
@metadata ||= raw.present? && valid? ? Maremma.from_json(raw) : {}
|
12
|
-
end
|
13
|
-
|
14
|
-
def errors
|
15
|
-
jsonlint(raw)
|
16
|
-
end
|
17
|
-
|
18
|
-
def valid?
|
19
|
-
errors.empty?
|
20
|
-
end
|
21
|
-
|
22
|
-
def datacite
|
23
|
-
datacite_xml
|
24
|
-
end
|
25
|
-
|
26
|
-
def doi
|
27
|
-
metadata.fetch("doi", nil)
|
28
|
-
end
|
29
|
-
|
30
|
-
def id
|
31
|
-
metadata.fetch("id", nil)
|
32
|
-
end
|
33
|
-
|
34
|
-
def resource_type_general
|
35
|
-
metadata.fetch("resource-type-general", nil)
|
36
|
-
end
|
37
|
-
|
38
|
-
def type
|
39
|
-
DC_TO_SO_TRANSLATIONS[resource_type_general.to_s.dasherize] || valid?.presence && "CreativeWork"
|
40
|
-
end
|
41
|
-
|
42
|
-
def citeproc_type
|
43
|
-
DC_TO_CP_TRANSLATIONS[resource_type_general.to_s.dasherize] || valid?.presence && "other"
|
44
|
-
end
|
45
|
-
|
46
|
-
def ris_type
|
47
|
-
SO_TO_RIS_TRANSLATIONS[resource_type_general.to_s.dasherize] || "GEN"
|
48
|
-
end
|
49
|
-
|
50
|
-
def additional_type
|
51
|
-
metadata.fetch("resource-type", nil)
|
52
|
-
end
|
53
|
-
|
54
|
-
def bibtex_type
|
55
|
-
Bolognese::Bibtex::SO_TO_BIB_TRANSLATIONS[type] || "misc"
|
56
|
-
end
|
57
|
-
|
58
|
-
def title
|
59
|
-
metadata.fetch("title", nil)
|
60
|
-
end
|
61
|
-
|
62
|
-
def alternate_name
|
63
|
-
metadata.fetch("alternate-identifier", nil)
|
64
|
-
end
|
65
|
-
|
66
|
-
def description
|
67
|
-
metadata.fetch("description", nil)
|
68
|
-
end
|
69
|
-
|
70
|
-
def license
|
71
|
-
metadata.fetch("license", nil)
|
72
|
-
end
|
73
|
-
|
74
|
-
def keywords
|
75
|
-
Array.wrap(metadata.fetch("subject", nil)).join(", ").presence
|
76
|
-
end
|
77
|
-
|
78
|
-
def author
|
79
|
-
metadata.fetch("creator", nil)
|
80
|
-
end
|
81
|
-
|
82
|
-
def editor
|
83
|
-
metadata.fetch("contributor", nil)
|
84
|
-
end
|
85
|
-
|
86
|
-
# def funder
|
87
|
-
# f = funder_contributor + funding_reference
|
88
|
-
# f.length > 1 ? f : f.first
|
89
|
-
# end
|
90
|
-
#
|
91
|
-
# def funder_contributor
|
92
|
-
# Array.wrap(metadata.dig("contributors", "contributor")).reduce([]) do |sum, f|
|
93
|
-
# if f["contributorType"] == "Funder"
|
94
|
-
# sum << { "name" => f["contributorName"] }
|
95
|
-
# else
|
96
|
-
# sum
|
97
|
-
# end
|
98
|
-
# end
|
99
|
-
# end
|
100
|
-
#
|
101
|
-
# def funding_reference
|
102
|
-
# Array.wrap(metadata.dig("fundingReferences", "fundingReference")).map do |f|
|
103
|
-
# funder_id = parse_attributes(f["funderIdentifier"])
|
104
|
-
# { "identifier" => normalize_id(funder_id),
|
105
|
-
# "name" => f["funderName"] }.compact
|
106
|
-
# end.uniq
|
107
|
-
# end
|
108
|
-
|
109
|
-
def version
|
110
|
-
metadata.fetch("version", nil)
|
111
|
-
end
|
112
|
-
|
113
|
-
# def dates
|
114
|
-
# Array.wrap(metadata.dig("dates", "date"))
|
115
|
-
# end
|
116
|
-
#
|
117
|
-
# #Accepted Available Copyrighted Collected Created Issued Submitted Updated Valid
|
118
|
-
#
|
119
|
-
# def date(date_type)
|
120
|
-
# dd = dates.find { |d| d["dateType"] == date_type } || {}
|
121
|
-
# dd.fetch("__content__", nil)
|
122
|
-
# end
|
123
|
-
|
124
|
-
def date_accepted
|
125
|
-
metadata.fetch("date-accepted", nil)
|
126
|
-
end
|
127
|
-
|
128
|
-
def date_available
|
129
|
-
metadata.fetch("date-available", nil)
|
130
|
-
end
|
131
|
-
|
132
|
-
def date_copyrighted
|
133
|
-
metadata.fetch("date-copyrighted", nil)
|
134
|
-
end
|
135
|
-
|
136
|
-
def date_collected
|
137
|
-
metadata.fetch("date-collected", nil)
|
138
|
-
end
|
139
|
-
|
140
|
-
def date_created
|
141
|
-
metadata.fetch("date-created", nil)
|
142
|
-
end
|
143
|
-
|
144
|
-
# use datePublished for date issued
|
145
|
-
def date_published
|
146
|
-
metadata.fetch("date-published", nil)
|
147
|
-
end
|
148
|
-
|
149
|
-
def date_submitted
|
150
|
-
metadata.fetch("date-submitted", nil)
|
151
|
-
end
|
152
|
-
|
153
|
-
# use dateModified for date updated
|
154
|
-
def date_modified
|
155
|
-
metadata.fetch("date-modified", nil)
|
156
|
-
end
|
157
|
-
|
158
|
-
def date_valid
|
159
|
-
metadata.fetch("date-valid", nil)
|
160
|
-
end
|
161
|
-
|
162
|
-
def publication_year
|
163
|
-
metadata.fetch("publication-year")
|
164
|
-
end
|
165
|
-
|
166
|
-
def language
|
167
|
-
metadata.fetch("language", nil)
|
168
|
-
end
|
169
|
-
|
170
|
-
def spatial_coverage
|
171
|
-
|
172
|
-
end
|
173
|
-
|
174
|
-
def content_size
|
175
|
-
metadata.fetch("size", nil)
|
176
|
-
end
|
177
|
-
|
178
|
-
def related_identifier
|
179
|
-
metadata.fetch("related_identifier", nil)
|
180
|
-
end
|
181
|
-
|
182
|
-
def get_related_identifier(relation_type: nil)
|
183
|
-
Array.wrap(related_identifier).select { |r| relation_type.split(" ").include?(r["relationType"]) }.unwrap
|
184
|
-
end
|
185
|
-
|
186
|
-
def is_identical_to
|
187
|
-
get_related_identifier(relation_type: "IsIdenticalTo")
|
188
|
-
end
|
189
|
-
|
190
|
-
def is_part_of
|
191
|
-
get_related_identifier(relation_type: "IsPartOf")
|
192
|
-
end
|
193
|
-
|
194
|
-
def has_part
|
195
|
-
get_related_identifier(relation_type: "HasPart")
|
196
|
-
end
|
197
|
-
|
198
|
-
def is_previous_version_of
|
199
|
-
get_related_identifier(relation_type: "IsPreviousVersionOf")
|
200
|
-
end
|
201
|
-
|
202
|
-
def is_new_version_of
|
203
|
-
get_related_identifier(relation_type: "IsNewVersionOf")
|
204
|
-
end
|
205
|
-
|
206
|
-
def references
|
207
|
-
get_related_identifier(relation_type: "Cites IsCitedBy Supplements IsSupplementTo References IsReferencedBy").presence
|
208
|
-
end
|
209
|
-
|
210
|
-
def publisher
|
211
|
-
metadata.fetch("publisher", nil)
|
212
|
-
end
|
213
|
-
|
214
|
-
alias_method :container_title, :publisher
|
215
|
-
|
216
|
-
def provider
|
217
|
-
"DataCite"
|
218
|
-
end
|
219
|
-
end
|
220
|
-
end
|
data/lib/bolognese/ris.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
module Bolognese
|
2
|
-
class Ris < Metadata
|
3
|
-
|
4
|
-
BIB_TO_SO_TRANSLATIONS = {
|
5
|
-
"article" => "ScholarlyArticle"
|
6
|
-
}
|
7
|
-
|
8
|
-
SO_TO_BIB_TRANSLATIONS = {
|
9
|
-
"Article" => "article",
|
10
|
-
"AudioObject" => "misc",
|
11
|
-
"Blog" => "misc",
|
12
|
-
"BlogPosting" => "article",
|
13
|
-
"Collection" => "misc",
|
14
|
-
"CreativeWork" => "misc",
|
15
|
-
"DataCatalog" => "misc",
|
16
|
-
"Dataset" => "misc",
|
17
|
-
"Event" => "misc",
|
18
|
-
"ImageObject" => "misc",
|
19
|
-
"Movie" => "misc",
|
20
|
-
"PublicationIssue" => "misc",
|
21
|
-
"ScholarlyArticle" => "article",
|
22
|
-
"Service" => "misc",
|
23
|
-
"SoftwareSourceCode" => "misc",
|
24
|
-
"VideoObject" => "misc",
|
25
|
-
"WebPage" => "misc",
|
26
|
-
"WebSite" => "misc"
|
27
|
-
}
|
28
|
-
|
29
|
-
BIB_TO_CP_TRANSLATIONS = {
|
30
|
-
"article" => "article-journal"
|
31
|
-
}
|
32
|
-
|
33
|
-
def initialize(string: nil)
|
34
|
-
@raw = string
|
35
|
-
end
|
36
|
-
|
37
|
-
def metadata
|
38
|
-
@metadata ||= raw.present? ? BibTeX.parse(raw).first : {}
|
39
|
-
end
|
40
|
-
|
41
|
-
def exists?
|
42
|
-
metadata.present?
|
43
|
-
end
|
44
|
-
|
45
|
-
def valid?
|
46
|
-
bibtex.present?
|
47
|
-
end
|
48
|
-
|
49
|
-
def type
|
50
|
-
BIB_TO_SO_TRANSLATIONS[metadata.type.to_s] || "ScholarlyArticle"
|
51
|
-
end
|
52
|
-
|
53
|
-
def citeproc_type
|
54
|
-
BIB_TO_CP_TRANSLATIONS[metadata.type.to_s] || "misc"
|
55
|
-
end
|
56
|
-
|
57
|
-
def resource_type_general
|
58
|
-
SO_TO_DC_TRANSLATIONS[type]
|
59
|
-
end
|
60
|
-
|
61
|
-
def doi
|
62
|
-
metadata.doi
|
63
|
-
end
|
64
|
-
|
65
|
-
def url
|
66
|
-
metadata.url
|
67
|
-
end
|
68
|
-
|
69
|
-
def id
|
70
|
-
normalize_doi(doi)
|
71
|
-
end
|
72
|
-
|
73
|
-
def author
|
74
|
-
Array(metadata.author).map do |a|
|
75
|
-
{ "@type" => "Person",
|
76
|
-
"givenName" => a.first,
|
77
|
-
"familyName" => a.last }.compact
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def title
|
82
|
-
metadata.title
|
83
|
-
end
|
84
|
-
|
85
|
-
def container_title
|
86
|
-
metadata.journal.to_s.presence || metadata.publisher.to_s
|
87
|
-
end
|
88
|
-
|
89
|
-
alias_method :journal, :container_title
|
90
|
-
|
91
|
-
def date_published
|
92
|
-
metadata.date.to_s.presence
|
93
|
-
end
|
94
|
-
|
95
|
-
def publication_year
|
96
|
-
metadata.year.to_s.presence
|
97
|
-
end
|
98
|
-
|
99
|
-
def is_part_of
|
100
|
-
if metadata.journal.present?
|
101
|
-
{ "type" => "Periodical",
|
102
|
-
"name" => metadata.journal.to_s,
|
103
|
-
"issn" => metadata.issn.to_s.presence }.compact
|
104
|
-
else
|
105
|
-
nil
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def description
|
110
|
-
{ "text" => metadata.field?(:abstract) && metadata.abstract.to_s.presence }
|
111
|
-
end
|
112
|
-
|
113
|
-
def license
|
114
|
-
{ "id" => metadata.field?(:copyright) && metadata.copyright.to_s.presence }
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
data/lib/bolognese/schema_org.rb
DELETED
@@ -1,196 +0,0 @@
|
|
1
|
-
module Bolognese
|
2
|
-
class SchemaOrg < Metadata
|
3
|
-
|
4
|
-
SO_TO_DC_RELATION_TYPES = {
|
5
|
-
"citation" => "References",
|
6
|
-
"sameAs" => "IsIdenticalTo",
|
7
|
-
"isPartOf" => "IsPartOf",
|
8
|
-
"hasPart" => "HasPart",
|
9
|
-
"isPredecessor" => "IsPreviousVersionOf",
|
10
|
-
"isSuccessor" => "IsNewVersionOf"
|
11
|
-
}
|
12
|
-
|
13
|
-
def initialize(id: nil, string: nil)
|
14
|
-
id = normalize_id(id) if id.present?
|
15
|
-
|
16
|
-
if string.present?
|
17
|
-
@raw = string
|
18
|
-
elsif id.present?
|
19
|
-
response = Maremma.get(id)
|
20
|
-
doc = Nokogiri::XML(response.body.fetch("data", nil), nil, 'UTF-8')
|
21
|
-
@raw = doc.at_xpath('//script[@type="application/ld+json"]')
|
22
|
-
@raw = @raw.text if @raw.present?
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def metadata
|
27
|
-
@metadata ||= raw.present? && valid? ? Maremma.from_json(raw) : {}
|
28
|
-
end
|
29
|
-
|
30
|
-
def exists?
|
31
|
-
metadata.present?
|
32
|
-
end
|
33
|
-
|
34
|
-
def errors
|
35
|
-
jsonlint(raw)
|
36
|
-
end
|
37
|
-
|
38
|
-
def valid?
|
39
|
-
errors.empty?
|
40
|
-
end
|
41
|
-
|
42
|
-
def doi
|
43
|
-
validate_doi(id)
|
44
|
-
end
|
45
|
-
|
46
|
-
def id
|
47
|
-
normalize_id(metadata.fetch("@id", nil))
|
48
|
-
end
|
49
|
-
|
50
|
-
def url
|
51
|
-
normalize_id(metadata.fetch("url", nil))
|
52
|
-
end
|
53
|
-
|
54
|
-
def resource_type_general
|
55
|
-
SO_TO_DC_TRANSLATIONS[type]
|
56
|
-
end
|
57
|
-
|
58
|
-
def type
|
59
|
-
metadata.fetch("@type", nil)
|
60
|
-
end
|
61
|
-
|
62
|
-
def citeproc_type
|
63
|
-
SO_TO_CP_TRANSLATIONS[type] || "article-journal"
|
64
|
-
end
|
65
|
-
|
66
|
-
def ris_type
|
67
|
-
SO_TO_RIS_TRANSLATIONS[resource_type_general.to_s.dasherize] || "GEN"
|
68
|
-
end
|
69
|
-
|
70
|
-
def additional_type
|
71
|
-
metadata.fetch("additionalType", nil)
|
72
|
-
end
|
73
|
-
|
74
|
-
def bibtex_type
|
75
|
-
Bolognese::Bibtex::SO_TO_BIB_TRANSLATIONS[type] || "misc"
|
76
|
-
end
|
77
|
-
|
78
|
-
def title
|
79
|
-
metadata.fetch("name", nil)
|
80
|
-
end
|
81
|
-
|
82
|
-
def alternate_name
|
83
|
-
metadata.fetch("alternateName", nil)
|
84
|
-
end
|
85
|
-
|
86
|
-
def author
|
87
|
-
authors = from_schema_org(Array.wrap(metadata.fetch("author", nil)))
|
88
|
-
get_authors(authors)
|
89
|
-
end
|
90
|
-
|
91
|
-
def editor
|
92
|
-
editors = from_schema_org(Array.wrap(metadata.fetch("editor", nil)))
|
93
|
-
get_authors(editors)
|
94
|
-
end
|
95
|
-
|
96
|
-
def description
|
97
|
-
{ "text" => metadata.fetch("description", nil) }
|
98
|
-
end
|
99
|
-
|
100
|
-
def license
|
101
|
-
{ "id" => metadata.fetch("license", nil) }
|
102
|
-
end
|
103
|
-
|
104
|
-
def version
|
105
|
-
metadata.fetch("version", nil)
|
106
|
-
end
|
107
|
-
|
108
|
-
def keywords
|
109
|
-
metadata.fetch("keywords", nil)
|
110
|
-
end
|
111
|
-
|
112
|
-
def date_created
|
113
|
-
metadata.fetch("dateCreated", nil)
|
114
|
-
end
|
115
|
-
|
116
|
-
def date_published
|
117
|
-
metadata.fetch("datePublished", nil)
|
118
|
-
end
|
119
|
-
|
120
|
-
def date_modified
|
121
|
-
metadata.fetch("dateModified", nil)
|
122
|
-
end
|
123
|
-
|
124
|
-
def related_identifier
|
125
|
-
Array.wrap(is_identical_to) +
|
126
|
-
Array.wrap(is_part_of) +
|
127
|
-
Array.wrap(has_part) +
|
128
|
-
Array.wrap(is_previous_version_of) +
|
129
|
-
Array.wrap(is_new_version_of) +
|
130
|
-
Array.wrap(references) +
|
131
|
-
Array.wrap(is_supplemented_by)
|
132
|
-
end
|
133
|
-
|
134
|
-
def get_related_identifier(relation_type: nil)
|
135
|
-
normalize_ids(ids: metadata.fetch(relation_type, nil),
|
136
|
-
relation_type: SO_TO_DC_RELATION_TYPES[relation_type])
|
137
|
-
end
|
138
|
-
|
139
|
-
def get_reverse_related_identifier(relation_type: nil)
|
140
|
-
normalize_ids(ids: metadata.dig("@reverse", relation_type),
|
141
|
-
relation_type: SO_TO_DC_RELATION_TYPES[relation_type])
|
142
|
-
end
|
143
|
-
|
144
|
-
def is_identical_to
|
145
|
-
get_related_identifier(relation_type: "sameAs")
|
146
|
-
end
|
147
|
-
|
148
|
-
def is_part_of
|
149
|
-
get_related_identifier(relation_type: "isPartOf")
|
150
|
-
end
|
151
|
-
|
152
|
-
def has_part
|
153
|
-
get_related_identifier(relation_type: "hasPart")
|
154
|
-
end
|
155
|
-
|
156
|
-
def is_previous_version_of
|
157
|
-
get_related_identifier(relation_type: "isPredecessor")
|
158
|
-
end
|
159
|
-
|
160
|
-
def is_new_version_of
|
161
|
-
get_related_identifier(relation_type: "isSuccessor")
|
162
|
-
end
|
163
|
-
|
164
|
-
def references
|
165
|
-
get_related_identifier(relation_type: "citation")
|
166
|
-
end
|
167
|
-
|
168
|
-
def is_referenced_by
|
169
|
-
get_reverse_related_identifier(relation_type: "citation")
|
170
|
-
end
|
171
|
-
|
172
|
-
def is_supplement_to
|
173
|
-
get_reverse_related_identifier(relation_type: "isBasedOn")
|
174
|
-
end
|
175
|
-
|
176
|
-
def is_supplemented_by
|
177
|
-
get_related_identifier(relation_type: "isBasedOn")
|
178
|
-
end
|
179
|
-
|
180
|
-
def publisher
|
181
|
-
metadata.dig("publisher", "name")
|
182
|
-
end
|
183
|
-
|
184
|
-
def container_title
|
185
|
-
if publisher.is_a?(Hash)
|
186
|
-
publisher.fetch("name", nil)
|
187
|
-
elsif publisher.is_a?(String)
|
188
|
-
publisher
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
def provider
|
193
|
-
metadata.fetch("provider", nil)
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|