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
data/lib/bolognese/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Bolognese
|
2
|
+
module Writers
|
3
|
+
module BibtexWriter
|
4
|
+
def bibtex
|
5
|
+
bib = {
|
6
|
+
bibtex_type: bibtex_type.presence || "misc",
|
7
|
+
bibtex_key: id,
|
8
|
+
doi: doi,
|
9
|
+
url: url,
|
10
|
+
author: authors_as_string(author),
|
11
|
+
keywords: keywords,
|
12
|
+
language: language,
|
13
|
+
title: title,
|
14
|
+
journal: container_title,
|
15
|
+
volume: volume,
|
16
|
+
issue: issue,
|
17
|
+
pages: pagination,
|
18
|
+
publisher: publisher,
|
19
|
+
year: publication_year
|
20
|
+
}.compact
|
21
|
+
BibTeX::Entry.new(bib).to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Bolognese
|
2
|
+
module Writers
|
3
|
+
module CiteprocWriter
|
4
|
+
def citeproc
|
5
|
+
hsh = {
|
6
|
+
"type" => citeproc_type,
|
7
|
+
"id" => id,
|
8
|
+
"categories" => keywords.present? ? keywords.split(", ") : nil,
|
9
|
+
"language" => language,
|
10
|
+
"author" => to_citeproc(author),
|
11
|
+
"editor" => to_citeproc(editor),
|
12
|
+
"issued" => get_date_parts(date_published),
|
13
|
+
"submitted" => get_date_parts(date_submitted),
|
14
|
+
"abstract" => description.is_a?(Hash) ? description.fetch("text", nil) : description,
|
15
|
+
"container-title" => container_title,
|
16
|
+
"DOI" => doi,
|
17
|
+
"issue" => issue,
|
18
|
+
"page" => pagination,
|
19
|
+
"publisher" => publisher,
|
20
|
+
"title" => title,
|
21
|
+
"URL" => url,
|
22
|
+
"version" => version,
|
23
|
+
"volume" => volume
|
24
|
+
}.compact
|
25
|
+
JSON.pretty_generate hsh.presence
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Bolognese
|
2
|
+
module Writers
|
3
|
+
module CodemetaWriter
|
4
|
+
def codemeta
|
5
|
+
hsh = {
|
6
|
+
"@context" => id.present? ? "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld" : nil,
|
7
|
+
"@type" => type,
|
8
|
+
"@id" => id,
|
9
|
+
"identifier" => id,
|
10
|
+
"codeRepository" => url,
|
11
|
+
"title" => title,
|
12
|
+
"agents" => author,
|
13
|
+
"description" => description.present? ? description["text"] : nil,
|
14
|
+
"version" => version,
|
15
|
+
"tags" => keywords.to_s.split(", ").presence,
|
16
|
+
"dateCreated" => date_created,
|
17
|
+
"datePublished" => date_published,
|
18
|
+
"dateModified" => date_modified,
|
19
|
+
"publisher" => publisher
|
20
|
+
}.compact
|
21
|
+
JSON.pretty_generate hsh.presence
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Bolognese
|
2
|
+
module Writers
|
3
|
+
module CrossciteWriter
|
4
|
+
def crosscite
|
5
|
+
hsh = {
|
6
|
+
"id" => id,
|
7
|
+
"doi" => doi,
|
8
|
+
"type" => type,
|
9
|
+
"additional_type" => additional_type,
|
10
|
+
"citeproc_type" => citeproc_type,
|
11
|
+
"bibtex_type" => bibtex_type,
|
12
|
+
"ris_type" => ris_type,
|
13
|
+
"resource_type_general" => resource_type_general,
|
14
|
+
"resource_type" => additional_type,
|
15
|
+
"author" => author,
|
16
|
+
"title" => title,
|
17
|
+
"publisher" => publisher,
|
18
|
+
"keywords" => keywords,
|
19
|
+
"contributor" => contributor,
|
20
|
+
"date_accepted" => date_accepted,
|
21
|
+
"date_available" => date_available,
|
22
|
+
"date_copyrighted" => date_copyrighted,
|
23
|
+
"date_collected" => date_collected,
|
24
|
+
"date_created" => date_created,
|
25
|
+
"date_published" => date_published,
|
26
|
+
"date_modified" => date_modified,
|
27
|
+
"date_submitted" => date_submitted,
|
28
|
+
"date_valid" => date_valid,
|
29
|
+
"language" => language,
|
30
|
+
"alternate_name" => alternate_name,
|
31
|
+
"references" => references,
|
32
|
+
"content_size" => content_size,
|
33
|
+
"format" => format,
|
34
|
+
"version" => version,
|
35
|
+
"license" => license,
|
36
|
+
"description" => description,
|
37
|
+
"volume" => volume,
|
38
|
+
"issue" => issue,
|
39
|
+
"pagination" => pagination,
|
40
|
+
"spatial_coverage" => spatial_coverage,
|
41
|
+
"funding_reference" => funder,
|
42
|
+
"schema_version" => schema_version,
|
43
|
+
"provider" => provider
|
44
|
+
}.compact
|
45
|
+
JSON.pretty_generate hsh.presence
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Bolognese
|
2
|
+
module Writers
|
3
|
+
module DataciteJsonWriter
|
4
|
+
def datacite_json
|
5
|
+
hsh = {
|
6
|
+
"id" => id,
|
7
|
+
"doi" => doi,
|
8
|
+
"creator" => author,
|
9
|
+
"title" => title,
|
10
|
+
"publisher" => publisher,
|
11
|
+
"resource_type_general" => resource_type_general,
|
12
|
+
"resource_type" => additional_type,
|
13
|
+
"subject" => keywords.present? ? keywords.split(", ") : nil,
|
14
|
+
"contributor" => contributor,
|
15
|
+
"date_accepted" => date_accepted,
|
16
|
+
"date_available" => date_available,
|
17
|
+
"date_copyrighted" => date_copyrighted,
|
18
|
+
"date_collected" => date_collected,
|
19
|
+
"date_created" => date_created,
|
20
|
+
"date_published" => date_published,
|
21
|
+
"date_modified" => date_modified,
|
22
|
+
"date_submitted" => date_submitted,
|
23
|
+
"date_valid" => date_valid,
|
24
|
+
"publication_year" => publication_year,
|
25
|
+
"language" => language,
|
26
|
+
"alternate_identifier" => alternate_name,
|
27
|
+
"references" => references,
|
28
|
+
"is_referenced_by" => is_referenced_by,
|
29
|
+
"is_part_of" => is_part_of,
|
30
|
+
"has_part" => has_part,
|
31
|
+
"size" => content_size,
|
32
|
+
"format" => format,
|
33
|
+
"version" => version,
|
34
|
+
"rights" => license,
|
35
|
+
"description" => description,
|
36
|
+
"geo-location" => spatial_coverage,
|
37
|
+
"funding-reference" => funder,
|
38
|
+
"schemaVersion" => schema_version,
|
39
|
+
"provider" => provider
|
40
|
+
}.compact
|
41
|
+
JSON.pretty_generate hsh.presence
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Bolognese
|
2
|
+
module Writers
|
3
|
+
module RisWriter
|
4
|
+
def ris
|
5
|
+
{
|
6
|
+
"TY" => ris_type,
|
7
|
+
"T1" => title,
|
8
|
+
"T2" => container_title,
|
9
|
+
"AU" => to_ris(author),
|
10
|
+
"DO" => doi,
|
11
|
+
"UR" => url,
|
12
|
+
"AB" => description.present? ? description["text"] : nil,
|
13
|
+
"KW" => keywords.to_s.split(", ").presence,
|
14
|
+
"PY" => publication_year,
|
15
|
+
"PB" => publisher,
|
16
|
+
"AN" => alternate_name.present? ? alternate_name["name"] : nil,
|
17
|
+
"LA" => language,
|
18
|
+
"VL" => volume,
|
19
|
+
"IS" => issue,
|
20
|
+
"SP" => pagination,
|
21
|
+
"ER" => ""
|
22
|
+
}.compact.map { |k, v| v.is_a?(Array) ? v.map { |vi| "#{k} - #{vi}" }.join("\r\n") : "#{k} - #{v}" }.join("\r\n")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Bolognese
|
2
|
+
module Writers
|
3
|
+
module SchemaOrgWriter
|
4
|
+
def schema_hsh
|
5
|
+
{
|
6
|
+
"@context" => id.present? ? "http://schema.org" : nil,
|
7
|
+
"@type" => type,
|
8
|
+
"@id" => id,
|
9
|
+
"url" => url,
|
10
|
+
"additionalType" => additional_type,
|
11
|
+
"name" => name,
|
12
|
+
"alternateName" => alternate_name,
|
13
|
+
"author" => to_schema_org(author),
|
14
|
+
"editor" => editor,
|
15
|
+
"description" => Array.wrap(description).map { |d| d["text"] }.unwrap,
|
16
|
+
"license" => license.present? ? license["id"] : nil,
|
17
|
+
"version" => version,
|
18
|
+
"keywords" => keywords,
|
19
|
+
"inLanguage" => language,
|
20
|
+
"contentSize" => content_size,
|
21
|
+
"dateCreated" => date_created,
|
22
|
+
"datePublished" => date_published,
|
23
|
+
"dateModified" => date_modified,
|
24
|
+
"pagination" => pagination,
|
25
|
+
"spatialCoverage" => spatial_coverage,
|
26
|
+
"sameAs" => same_as,
|
27
|
+
"isPartOf" => is_part_of,
|
28
|
+
"hasPart" => has_part,
|
29
|
+
"predecessor_of" => is_previous_version_of,
|
30
|
+
"successor_of" => is_new_version_of,
|
31
|
+
"citation" => Array.wrap(references).map { |r| r.except("relationType").merge("@type" => "CreativeWork") }.unwrap,
|
32
|
+
"@reverse" => reverse.presence,
|
33
|
+
"schemaVersion" => schema_version,
|
34
|
+
"publisher" => publisher.present? ? { "@type" => "Organization", "name" => publisher } : nil,
|
35
|
+
"funder" => funder,
|
36
|
+
"provider" => provider.present? ? { "@type" => "Organization", "name" => provider } : nil
|
37
|
+
}.compact.presence
|
38
|
+
end
|
39
|
+
|
40
|
+
def schema_org
|
41
|
+
JSON.pretty_generate schema_hsh
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/spec/author_utils_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Bolognese::
|
4
|
-
let(:
|
3
|
+
describe Bolognese::Metadata, vcr: true do
|
4
|
+
let(:input) { "https://doi.org/10.1101/097196" }
|
5
5
|
|
6
|
-
subject { Bolognese::
|
6
|
+
subject { Bolognese::Metadata.new(input: input, from: "crossref") }
|
7
7
|
|
8
8
|
context "is_personal_name?" do
|
9
9
|
it "has type organization" do
|
@@ -39,59 +39,86 @@ describe Bolognese::Crossref, vcr: true do
|
|
39
39
|
|
40
40
|
context "get_one_author" do
|
41
41
|
it "has familyName" do
|
42
|
-
|
43
|
-
subject = Bolognese::
|
44
|
-
|
42
|
+
input = "https://doi.org/10.5438/4K3M-NYVG"
|
43
|
+
subject = Bolognese::Metadata.new(input: input, from: "datacite")
|
44
|
+
string = subject.get_datacite(id: input)
|
45
|
+
meta = Maremma.from_xml(string).fetch("resource", {})
|
46
|
+
response = subject.get_one_author(meta.dig("creators", "creator"))
|
45
47
|
expect(response).to eq("type"=>"Person", "id"=>"http://orcid.org/0000-0003-1419-2405", "name"=>"Fenner, Martin", "givenName"=>"Martin", "familyName"=>"Fenner")
|
46
48
|
end
|
47
49
|
|
48
50
|
it "has name in sort-order" do
|
49
|
-
|
50
|
-
subject = Bolognese::
|
51
|
-
|
51
|
+
input = "https://doi.org/10.5061/dryad.8515"
|
52
|
+
subject = Bolognese::Metadata.new(input: input, from: "datacite")
|
53
|
+
string = subject.get_datacite(id: input)
|
54
|
+
meta = Maremma.from_xml(string).fetch("resource", {})
|
55
|
+
response = subject.get_one_author(meta.dig("creators", "creator").first)
|
52
56
|
expect(response).to eq("type"=>"Person", "name"=>"Benjamin Ollomo", "givenName"=>"Benjamin", "familyName"=>"Ollomo")
|
53
57
|
end
|
54
58
|
|
55
59
|
it "has name in display-order" do
|
56
|
-
|
57
|
-
subject = Bolognese::
|
58
|
-
|
60
|
+
input = "https://doi.org/10.5281/ZENODO.48440"
|
61
|
+
subject = Bolognese::Metadata.new(input: input, from: "datacite")
|
62
|
+
string = subject.get_datacite(id: input)
|
63
|
+
meta = Maremma.from_xml(string).fetch("resource", {})
|
64
|
+
response = subject.get_one_author(meta.dig("creators", "creator"))
|
59
65
|
expect(response).to eq("type"=>"Person", "name"=>"Kristian Garza", "givenName"=>"Kristian", "familyName"=>"Garza")
|
60
66
|
end
|
61
67
|
|
62
68
|
it "has multiple names in display-order" do
|
63
|
-
|
64
|
-
subject = Bolognese::
|
65
|
-
|
69
|
+
input = "https://doi.org/10.6084/M9.FIGSHARE.3479141 "
|
70
|
+
subject = Bolognese::Metadata.new(input: input, from: "datacite")
|
71
|
+
string = subject.get_datacite(id: input)
|
72
|
+
meta = Maremma.from_xml(string).fetch("resource", {})
|
73
|
+
response = subject.get_authors(meta.dig("creators", "creator"))
|
66
74
|
expect(response.count).to eq(9)
|
67
75
|
expect(response.last).to eq("type"=>"Person", "name"=>"Ed Pentz", "givenName"=>"Ed", "familyName"=>"Pentz")
|
68
76
|
end
|
69
77
|
|
70
78
|
it "has name in display-order with ORCID" do
|
71
|
-
|
72
|
-
subject = Bolognese::
|
73
|
-
|
79
|
+
input = "https://doi.org/10.6084/M9.FIGSHARE.4700788"
|
80
|
+
subject = Bolognese::Metadata.new(input: input, from: "datacite")
|
81
|
+
string = subject.get_datacite(id: input)
|
82
|
+
meta = Maremma.from_xml(string).fetch("resource", {})
|
83
|
+
response = subject.get_one_author(meta.dig("creators", "creator"))
|
74
84
|
expect(response).to eq("type"=>"Person", "id"=>"http://orcid.org/0000-0003-4881-1606", "name"=>"Andrea Bedini", "givenName"=>"Andrea", "familyName"=>"Bedini")
|
75
85
|
end
|
76
86
|
|
77
87
|
it "has name in Thai" do
|
78
|
-
|
79
|
-
subject = Bolognese::
|
80
|
-
|
88
|
+
input = "https://doi.org/10.14457/KMITL.res.2006.17"
|
89
|
+
subject = Bolognese::Metadata.new(input: input, from: "datacite")
|
90
|
+
string = subject.get_datacite(id: input)
|
91
|
+
meta = Maremma.from_xml(string).fetch("resource", {})
|
92
|
+
response = subject.get_one_author(meta.dig("creators", "creator"))
|
81
93
|
expect(response).to eq("name"=>"กัญจนา แซ่เตียว")
|
82
94
|
end
|
83
95
|
|
84
96
|
it "multiple author names in one field" do
|
85
|
-
|
86
|
-
subject = Bolognese::
|
87
|
-
|
88
|
-
|
97
|
+
input = "https://doi.org/10.7910/dvn/eqtqyo"
|
98
|
+
subject = Bolognese::Metadata.new(input: input, from: "datacite")
|
99
|
+
string = subject.get_datacite(id: input)
|
100
|
+
meta = Maremma.from_xml(string).fetch("resource", {})
|
101
|
+
response = subject.get_authors(meta.dig("creators", "creator"))
|
102
|
+
expect(response).to eq([{"type"=>"Person",
|
103
|
+
"name"=>"Ryan Enos",
|
104
|
+
"givenName"=>"Ryan",
|
105
|
+
"familyName"=>"Enos"},
|
106
|
+
{"type"=>"Person",
|
107
|
+
"name"=>"Anthony Fowler",
|
108
|
+
"givenName"=>"Anthony",
|
109
|
+
"familyName"=>"Fowler"},
|
110
|
+
{"type"=>"Person",
|
111
|
+
"name"=>"Lynn Vavreck",
|
112
|
+
"givenName"=>"Lynn",
|
113
|
+
"familyName"=>"Vavreck"}])
|
89
114
|
end
|
90
115
|
|
91
116
|
it "hyper-authorship" do
|
92
|
-
|
93
|
-
subject = Bolognese::
|
94
|
-
|
117
|
+
input = "https://doi.org/10.17182/HEPDATA.77274.V1"
|
118
|
+
subject = Bolognese::Metadata.new(input: input, from: "datacite")
|
119
|
+
string = subject.get_datacite(id: input)
|
120
|
+
meta = Maremma.from_xml(string).fetch("resource", {})
|
121
|
+
response = subject.get_authors(meta.dig("creators", "creator"))
|
95
122
|
expect(response.length).to eq(1000)
|
96
123
|
expect(response.first).to eq("type"=>"Person", "name"=>"Jaroslav Adam", "givenName"=>"Jaroslav", "familyName"=>"Adam")
|
97
124
|
end
|
@@ -105,18 +132,31 @@ describe Bolognese::Crossref, vcr: true do
|
|
105
132
|
|
106
133
|
context "get_name_identifier" do
|
107
134
|
it "has ORCID" do
|
108
|
-
|
109
|
-
subject = Bolognese::
|
110
|
-
|
135
|
+
input = "https://doi.org/10.5438/4K3M-NYVG"
|
136
|
+
subject = Bolognese::Metadata.new(input: input, from: "datacite")
|
137
|
+
string = subject.get_datacite(id: input)
|
138
|
+
meta = Maremma.from_xml(string).fetch("resource", {})
|
139
|
+
response = subject.get_name_identifier(meta.dig("creators", "creator"))
|
111
140
|
expect(response).to eq("http://orcid.org/0000-0003-1419-2405")
|
112
141
|
end
|
113
142
|
|
114
143
|
it "has no ORCID" do
|
115
|
-
|
116
|
-
subject = Bolognese::
|
117
|
-
|
144
|
+
input = "https://doi.org/10.4230/lipics.tqc.2013.93"
|
145
|
+
subject = Bolognese::Metadata.new(input: input, from: "datacite")
|
146
|
+
string = subject.get_datacite(id: input)
|
147
|
+
meta = Maremma.from_xml(string).fetch("resource", {})
|
148
|
+
response = subject.get_name_identifier(meta.dig("creators", "creator"))
|
118
149
|
expect(response).to be_nil
|
119
150
|
end
|
151
|
+
|
152
|
+
it "has jacow.org scheme" do
|
153
|
+
input = "https://doi.org/10.18429/JACOW-IPAC2016-TUPMY003"
|
154
|
+
subject = Bolognese::Metadata.new(input: input, from: "datacite")
|
155
|
+
string = subject.get_datacite(id: input)
|
156
|
+
meta = Maremma.from_xml(string).fetch("resource", {})
|
157
|
+
response = subject.get_name_identifier(meta.dig("creators", "creator").first)
|
158
|
+
expect(response).to eq("http://jacow.org/JACoW-00077389")
|
159
|
+
end
|
120
160
|
end
|
121
161
|
|
122
162
|
context "authors_as_string" do
|