bolognese 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (322) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +16 -16
  3. data/README.md +9 -0
  4. data/lib/bolognese.rb +0 -8
  5. data/lib/bolognese/array.rb +2 -2
  6. data/lib/bolognese/author_utils.rb +18 -6
  7. data/lib/bolognese/cli.rb +2 -17
  8. data/lib/bolognese/datacite_utils.rb +8 -7
  9. data/lib/bolognese/metadata.rb +291 -178
  10. data/lib/bolognese/readers/bibtex_reader.rb +66 -0
  11. data/lib/bolognese/readers/citeproc_reader.rb +74 -0
  12. data/lib/bolognese/readers/codemeta_reader.rb +71 -0
  13. data/lib/bolognese/readers/crosscite_reader.rb +12 -0
  14. data/lib/bolognese/readers/crossref_reader.rb +209 -0
  15. data/lib/bolognese/readers/datacite_json_reader.rb +75 -0
  16. data/lib/bolognese/readers/datacite_reader.rb +181 -0
  17. data/lib/bolognese/readers/ris_reader.rb +84 -0
  18. data/lib/bolognese/readers/schema_org_reader.rb +119 -0
  19. data/lib/bolognese/utils.rb +42 -67
  20. data/lib/bolognese/version.rb +1 -1
  21. data/lib/bolognese/writers/bibtex_writer.rb +25 -0
  22. data/lib/bolognese/writers/citeproc_writer.rb +29 -0
  23. data/lib/bolognese/writers/codemeta_writer.rb +25 -0
  24. data/lib/bolognese/writers/crosscite_writer.rb +49 -0
  25. data/lib/bolognese/writers/crossref_writer.rb +9 -0
  26. data/lib/bolognese/writers/datacite_json_writer.rb +45 -0
  27. data/lib/bolognese/writers/datacite_writer.rb +10 -0
  28. data/lib/bolognese/writers/rdf_xml_writer.rb +9 -0
  29. data/lib/bolognese/writers/ris_writer.rb +26 -0
  30. data/lib/bolognese/writers/schema_org_writer.rb +45 -0
  31. data/lib/bolognese/writers/turtle_writer.rb +9 -0
  32. data/spec/author_utils_spec.rb +74 -34
  33. data/spec/cli_spec.rb +6 -6
  34. data/spec/datacite_utils_spec.rb +10 -11
  35. data/spec/doi_utils_spec.rb +2 -1
  36. data/spec/fixtures/crossref.ris +2 -1
  37. data/spec/fixtures/datacite.json +6 -9
  38. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/default.yml +9 -7
  39. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_bibtex.yml +9 -7
  40. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_crossref.yml +6 -6
  41. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_datacite.yml +6 -6
  42. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_schema_org.yml +8 -6
  43. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/default.yml +10 -6
  44. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_bibtex.yml +8 -6
  45. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_datacite.yml +11 -7
  46. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_datacite_json.yml +10 -6
  47. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_schema_org.yml +10 -6
  48. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/default.yml +201 -200
  49. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/to_bibtex.yml +201 -200
  50. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/to_datacite.yml +201 -200
  51. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/to_schema_org.yml +201 -200
  52. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/is_personal_name_/has_type_organization.yml → Bolognese_Metadata/authors_as_string/author.yml} +61 -2
  53. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/authors_as_string/single_author.yml → Bolognese_Metadata/authors_as_string/no_author.yml} +60 -3
  54. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/authors_as_string/single_author.yml +203 -0
  55. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/authors_as_string/with_organization.yml +203 -0
  56. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_from_url/doi.yml +203 -0
  57. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_from_url/not_a_doi.yml +203 -0
  58. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_from_url/url.yml +203 -0
  59. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/crossref.yml +204 -6
  60. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/datacite.yml +204 -4
  61. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/medra.yml +204 -4
  62. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/not_a_valid_prefix.yml +203 -0
  63. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/not_found.yml +204 -4
  64. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/crossref.yml +102 -4
  65. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/crossref_doi_not_url.yml +100 -4
  66. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/datacite.yml +102 -4
  67. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/datacite_doi_http.yml +100 -4
  68. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/github.yml +97 -0
  69. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/orcid.yml +99 -0
  70. 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
  71. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/bibtex.yml +99 -0
  72. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/citeproc.yml +99 -0
  73. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_one_author/has_familyName.yml → Bolognese_Metadata/find_from_format_from_file/codemeta.yml} +61 -2
  74. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/crossref.yml +99 -0
  75. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/datacite.yml +99 -0
  76. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/datacite_json.yml +99 -0
  77. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/ris.yml +99 -0
  78. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/schema_org.yml +97 -0
  79. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/is_personal_name_/has_no_info.yml → Bolognese_Metadata/from_schema_org/with_id.yml} +59 -2
  80. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata → Bolognese_Metadata/get_codemeta_metadata}/maremma.yml +9 -9
  81. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata → Bolognese_Metadata/get_codemeta_metadata}/no_codemeta_json.yml +8 -8
  82. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata → Bolognese_Metadata/get_codemeta_metadata}/not_found_error.yml +8 -8
  83. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/DOI_with_ORCID_ID.yml +61 -2
  84. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/DOI_with_SICI_DOI.yml +62 -3
  85. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/DOI_with_data_citation.yml +61 -2
  86. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/date_in_future.yml +61 -2
  87. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/journal_article.yml +62 -3
  88. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/not_found_error.yml +97 -0
  89. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/posted_content.yml +203 -0
  90. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/BlogPosting.yml +99 -0
  91. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Dataset.yml +99 -0
  92. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Funding_schema_version_4.yml +97 -0
  93. data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata → Bolognese_Metadata/get_datacite_metadata}/author_only_full_name.yml +61 -2
  94. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/author_with_scheme.yml +97 -0
  95. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_name_identifier/has_no_ORCID.yml → Bolognese_Metadata/get_datacite_metadata/date.yml} +63 -2
  96. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/funding_schema_version_3.yml +99 -0
  97. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/is_identical_to.yml +99 -0
  98. data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata → Bolognese_Metadata/get_datacite_metadata}/keywords_with_attributes.yml +64 -3
  99. data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata → Bolognese_Metadata/get_datacite_metadata}/multiple_author_names_in_one_creatorName.yml +63 -2
  100. 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
  101. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata/posted_content.yml → Bolognese_Metadata/get_date_from_date_parts/date.yml} +59 -2
  102. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_from_date_parts/year-month.yml +203 -0
  103. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_from_date_parts/year.yml +203 -0
  104. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_parts/date.yml +203 -0
  105. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_parts/year-month.yml +203 -0
  106. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_parts/year.yml +201 -0
  107. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_name_identifier/has_ORCID.yml +136 -0
  108. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_name_identifier/has_jacow_org_scheme.yml +136 -0
  109. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_name_identifier/has_no_ORCID.yml +136 -0
  110. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_familyName.yml +136 -0
  111. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_multiple_names_in_display-order.yml +136 -0
  112. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_name_in_Thai.yml +134 -0
  113. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_name_in_display-order.yml +136 -0
  114. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_name_in_display-order_with_ORCID.yml +136 -0
  115. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_name_in_sort-order.yml +136 -0
  116. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/hyper-authorship.yml +132 -0
  117. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/is_organization.yml +203 -0
  118. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/multiple_author_names_in_one_field.yml +136 -0
  119. data/spec/fixtures/vcr_cassettes/{Bolognese_SchemaOrg/get_metadata → Bolognese_Metadata/get_schema_org_metadata}/BlogPosting.yml +201 -200
  120. data/spec/fixtures/vcr_cassettes/{Bolognese_SchemaOrg/get_metadata → Bolognese_Metadata/get_schema_org_metadata}/not_found_error.yml +2 -2
  121. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_alternate_identifiers/insert.yml +97 -0
  122. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_contributors/none.yml +99 -0
  123. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_creators/insert.yml +99 -0
  124. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_dates/insert.yml +99 -0
  125. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_descriptions/insert.yml +99 -0
  126. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_identifier/doi.yml +99 -0
  127. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_person/creator_only_name.yml +99 -0
  128. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_publication_year/insert.yml +99 -0
  129. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_publisher/insert.yml +99 -0
  130. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers/insert.yml +99 -0
  131. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers/related_identifier.yml +99 -0
  132. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_resource_type/insert.yml +99 -0
  133. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_rights_list/insert.yml +97 -0
  134. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_subjects/insert.yml +99 -0
  135. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_titles/insert.yml +99 -0
  136. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_version/insert.yml +97 -0
  137. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/is_personal_name_/has_comma.yml +203 -0
  138. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref → Bolognese_Metadata}/is_personal_name_/has_family_name.yml +61 -2
  139. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/is_personal_name_/has_id.yml +201 -0
  140. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref → Bolognese_Metadata}/is_personal_name_/has_known_given_name.yml +61 -2
  141. 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
  142. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/is_personal_name_/has_type_organization.yml +203 -0
  143. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/missing_comma.yml +99 -0
  144. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/nil.yml +99 -0
  145. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/overlapping_keys.yml +97 -0
  146. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/valid.yml +99 -0
  147. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/authors_as_string/author.yml → Bolognese_Metadata/normalize_doi/SICI_doi.yml} +59 -2
  148. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/doi.yml +203 -0
  149. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/doi_from_url_without_doi_proxy.yml +203 -0
  150. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/doi_prefix_too_long.yml +203 -0
  151. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/doi_prefix_with_string.yml +203 -0
  152. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/authors_as_string/no_author.yml → Bolognese_Metadata/normalize_doi/doi_with_protocol.yml} +59 -2
  153. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/dx_doi_org_url.yml +203 -0
  154. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/https_url.yml +203 -0
  155. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/not_valid_doi_prefix.yml +203 -0
  156. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/url_with_one_slash.yml +203 -0
  157. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/doi.yml +203 -0
  158. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/doi_as_url.yml +203 -0
  159. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/ftp.yml +203 -0
  160. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/invalid_url.yml +203 -0
  161. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/string.yml +203 -0
  162. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_one_author/is_organization.yml → Bolognese_Metadata/normalize_id/url.yml} +59 -2
  163. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/url_with_utf-8.yml +203 -0
  164. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_ids/doi.yml +203 -0
  165. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_ids/url.yml +203 -0
  166. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/is_personal_name_/has_comma.yml → Bolognese_Metadata/normalize_url/uri.yml} +2 -2
  167. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/authors_as_string/with_organization.yml → Bolognese_Metadata/normalize_url/with_trailing_slash.yml} +2 -2
  168. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/parse_attributes/array.yml +203 -0
  169. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/is_personal_name_/has_id.yml → Bolognese_Metadata/parse_attributes/hash.yml} +59 -2
  170. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/parse_attributes/nil.yml +203 -0
  171. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/parse_attributes/string.yml +203 -0
  172. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/sanitize/should_only_keep_specific_tags.yml +203 -0
  173. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/sanitize/should_remove_a_tags.yml +203 -0
  174. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/to_schema_org/with_id.yml +203 -0
  175. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/validate_url/DOI.yml +203 -0
  176. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/validate_url/ISSN.yml +203 -0
  177. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/validate_url/URL.yml +203 -0
  178. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/validate_url/string.yml +203 -0
  179. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_bibtex/BlogPosting.yml +99 -0
  180. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_bibtex/Dataset.yml +99 -0
  181. 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
  182. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_datacite_xml → Bolognese_Metadata/write_metadata_as_bibtex}/maremma.yml +9 -9
  183. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_bibtex/with_data_citation.yml +731 -0
  184. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_citeproc → Bolognese_Metadata/write_metadata_as_bibtex}/with_pages.yml +61 -2
  185. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/BlogPosting.yml +99 -0
  186. 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
  187. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/Dataset.yml +99 -0
  188. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_citeproc → Bolognese_Metadata/write_metadata_as_citeproc}/journal_article.yml +62 -3
  189. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_ris → Bolognese_Metadata/write_metadata_as_citeproc}/maremma.yml +8 -8
  190. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_ris → Bolognese_Metadata/write_metadata_as_citeproc}/with_pages.yml +61 -2
  191. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_codemeta/SoftwareSourceCode_DataCite.yml +99 -0
  192. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_bibtex → Bolognese_Metadata/write_metadata_as_crosscite}/maremma.yml +9 -9
  193. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_datacite_xml → Bolognese_Metadata/write_metadata_as_crosscite}/with_ORCID_ID.yml +61 -2
  194. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_crosscite/with_data_citation.yml +731 -0
  195. 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
  196. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_datacite_xml → Bolognese_Metadata/write_metadata_as_crosscite}/with_editor.yml +62 -3
  197. 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
  198. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_json/maremma.yml +100 -0
  199. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_json/with_ORCID_ID.yml +377 -0
  200. 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
  201. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_json/with_data_citation_schema_org.yml +654 -0
  202. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_xml/Dataset_in_schema_4_0.yml +97 -0
  203. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_citeproc → Bolognese_Metadata/write_metadata_as_datacite_xml}/maremma.yml +9 -9
  204. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_xml/with_ORCID_ID.yml +377 -0
  205. 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
  206. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_xml/with_data_citation_schema_org.yml +654 -0
  207. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_xml/with_editor.yml +944 -0
  208. data/spec/fixtures/vcr_cassettes/{Bolognese_DataciteJson/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_rdf_xml}/BlogPosting.yml +88 -23
  209. 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
  210. data/spec/fixtures/vcr_cassettes/{Bolognese_Bibtex/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_rdf_xml}/Crossref_DOI.yml +26 -20
  211. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_rdf_xml}/journal_article.yml +87 -22
  212. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_rdf_xml}/maremma.yml +35 -29
  213. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_turtle → Bolognese_Metadata/write_metadata_as_rdf_xml}/with_pages.yml +88 -23
  214. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_ris/BlogPosting.yml +99 -0
  215. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_ris/BlogPosting_schema_org.yml +654 -0
  216. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_ris/Dataset.yml +99 -0
  217. 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
  218. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_ris/maremma.yml +100 -0
  219. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_bibtex → Bolognese_Metadata/write_metadata_as_ris}/with_pages.yml +62 -3
  220. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_schema_org/Schema_org_JSON_IsSupplementTo.yml +99 -0
  221. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_schema_org/Schema_org_JSON_isReferencedBy.yml +99 -0
  222. 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
  223. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata → Bolognese_Metadata/write_metadata_as_schema_org}/maremma_schema_org_JSON.yml +9 -9
  224. data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_turtle}/BlogPosting.yml +88 -23
  225. 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
  226. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_turtle/BlogPosting_DataCite_JSON.yml +4589 -0
  227. data/spec/fixtures/vcr_cassettes/{Bolognese_Bibtex/get_metadata_as_turtle → Bolognese_Metadata/write_metadata_as_turtle}/Crossref_DOI.yml +26 -20
  228. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_turtle/DataONE.yml +4589 -0
  229. data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata_as_turtle → Bolognese_Metadata/write_metadata_as_turtle}/Dataset.yml +88 -23
  230. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_turtle → Bolognese_Metadata/write_metadata_as_turtle}/journal_article.yml +87 -22
  231. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_turtle}/with_pages.yml +87 -22
  232. data/spec/metadata_spec.rb +8 -2
  233. data/spec/readers/bibtex_reader_spec.rb +30 -0
  234. data/spec/readers/citeproc_reader_spec.rb +28 -0
  235. data/spec/readers/codemeta_reader_spec.rb +90 -0
  236. data/spec/readers/crossref_reader_spec.rb +142 -0
  237. data/spec/readers/datacite_json_reader_spec.rb +48 -0
  238. data/spec/readers/datacite_reader_spec.rb +215 -0
  239. data/spec/readers/ris_reader_spec.rb +32 -0
  240. data/spec/readers/schema_org_reader_spec.rb +63 -0
  241. data/spec/utils_spec.rb +24 -25
  242. data/spec/writers/bibtex_writer_spec.rb +102 -0
  243. data/spec/writers/citeproc_writer_spec.rb +138 -0
  244. data/spec/writers/codemeta_writer_spec.rb +36 -0
  245. data/spec/writers/crosscite_writer_spec.rb +81 -0
  246. data/spec/writers/crossref_writer_spec.rb +19 -0
  247. data/spec/writers/datacite_json_writer_spec.rb +74 -0
  248. data/spec/writers/datacite_writer_spec.rb +124 -0
  249. data/spec/writers/rdf_xml_writer_spec.rb +97 -0
  250. data/spec/writers/ris_writer_spec.rb +153 -0
  251. data/spec/writers/schema_org_writer_spec.rb +59 -0
  252. data/spec/writers/turtle_writer_spec.rb +82 -0
  253. metadata +213 -132
  254. data/codemeta.json +0 -39
  255. data/lib/bolognese/bibtex.rb +0 -163
  256. data/lib/bolognese/citeproc.rb +0 -120
  257. data/lib/bolognese/codemeta.rb +0 -153
  258. data/lib/bolognese/crossref.rb +0 -281
  259. data/lib/bolognese/datacite.rb +0 -288
  260. data/lib/bolognese/datacite_json.rb +0 -220
  261. data/lib/bolognese/ris.rb +0 -117
  262. data/lib/bolognese/schema_org.rb +0 -196
  263. data/spec/bibtex_spec.rb +0 -90
  264. data/spec/citeproc_spec.rb +0 -66
  265. data/spec/codemeta_spec.rb +0 -221
  266. data/spec/crossref_spec.rb +0 -348
  267. data/spec/datacite_json_spec.rb +0 -125
  268. data/spec/datacite_spec.rb +0 -406
  269. data/spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_schema_org_JSON/maremma.yml +0 -100
  270. data/spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_turtle/maremma.yml +0 -4680
  271. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/not_found_error.yml +0 -38
  272. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_string/DOI_with_data_citation.yml +0 -672
  273. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/author.yml +0 -38
  274. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/has_multiple_names_in_display-order.yml +0 -38
  275. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/has_name_in_Thai.yml +0 -38
  276. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/has_name_in_display-order_with_ORCID.yml +0 -38
  277. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/hyper-authorship.yml +0 -38
  278. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/multiple_author_names.yml +0 -38
  279. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/multiple_author_names_in_one_field.yml +0 -38
  280. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/BlogPosting.yml +0 -40
  281. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Dataset.yml +0 -40
  282. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Date.yml +0 -40
  283. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Funding_schema_version_3.yml +0 -40
  284. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Funding_schema_version_4.yml +0 -38
  285. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Schema_org_JSON_IsSupplementTo.yml +0 -40
  286. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Schema_org_JSON_isReferencedBy.yml +0 -40
  287. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/author.yml +0 -38
  288. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/author_with_scheme.yml +0 -38
  289. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/is_identical_to.yml +0 -40
  290. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/jsonlint.yml +0 -38
  291. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/multiple_licenses.yml +0 -40
  292. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_bibtex/BlogPosting.yml +0 -40
  293. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_bibtex/Dataset.yml +0 -40
  294. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_citeproc/BlogPosting.yml +0 -38
  295. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_citeproc/Dataset.yml +0 -40
  296. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_codemeta/SoftwareSourceCode.yml +0 -40
  297. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_datacite_xml_4_0/Dataset.yml +0 -40
  298. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_ris/BlogPosting.yml +0 -40
  299. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_ris/Dataset.yml +0 -40
  300. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_turtle/BlogPosting.yml +0 -4620
  301. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_alternate_identifiers/insert.yml +0 -38
  302. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_contributors/none.yml +0 -40
  303. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_creators/insert.yml +0 -40
  304. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_dates/insert.yml +0 -40
  305. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_descriptions/insert.yml +0 -38
  306. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_identifier/doi.yml +0 -40
  307. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_person/creator_only_name.yml +0 -38
  308. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_publication_year/insert.yml +0 -38
  309. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_publisher/insert.yml +0 -38
  310. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_related_identifiers/insert.yml +0 -38
  311. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_related_identifiers/related_identifier.yml +0 -40
  312. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_resource_type/insert.yml +0 -40
  313. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_rights_list/insert.yml +0 -40
  314. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_subjects/insert.yml +0 -40
  315. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_titles/insert.yml +0 -40
  316. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_version/insert.yml +0 -40
  317. data/spec/fixtures/vcr_cassettes/Bolognese_DataciteJson/get_metadata_as_turtle/BlogPosting.yml +0 -4583
  318. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/generate/datacite.yml +0 -40
  319. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/read/datacite.yml +0 -40
  320. data/spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_datacite_xml/with_data_citation.yml +0 -653
  321. data/spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_ris/BlogPosting.yml +0 -653
  322. data/spec/schema_org_spec.rb +0 -151
@@ -1,281 +0,0 @@
1
- module Bolognese
2
- class Crossref < Metadata
3
- # CrossRef types from https://api.crossref.org/types
4
- CR_TO_SO_TRANSLATIONS = {
5
- "Proceedings" => nil,
6
- "ReferenceBook" => "Book",
7
- "JournalIssue" => "PublicationIssue",
8
- "ProceedingsArticle" => nil,
9
- "Other" => "CreativeWork",
10
- "Dissertation" => "Thesis",
11
- "Dataset" => "Dataset",
12
- "EditedBook" => "Book",
13
- "JournalArticle" => "ScholarlyArticle",
14
- "Journal" => nil,
15
- "Report" => nil,
16
- "BookSeries" => nil,
17
- "ReportSeries" => nil,
18
- "BookTrack" => nil,
19
- "Standard" => nil,
20
- "BookSection" => nil,
21
- "BookPart" => nil,
22
- "Book" => "Book",
23
- "BookChapter" => "Chapter",
24
- "StandardSeries" => nil,
25
- "Monograph" => "Book",
26
- "Component" => "CreativeWork",
27
- "ReferenceEntry" => nil,
28
- "JournalVolume" => "PublicationVolume",
29
- "BookSet" => nil,
30
- "PostedContent" => "ScholarlyArticle"
31
- }
32
-
33
- CR_TO_BIB_TRANSLATIONS = {
34
- "Proceedings" => "proceedings",
35
- "ReferenceBook" => "book",
36
- "JournalIssue" => nil,
37
- "ProceedingsArticle" => nil,
38
- "Other" => nil,
39
- "Dissertation" => "phdthesis",
40
- "Dataset" => nil,
41
- "EditedBook" => "book",
42
- "JournalArticle" => "article",
43
- "Journal" => nil,
44
- "Report" => nil,
45
- "BookSeries" => nil,
46
- "ReportSeries" => nil,
47
- "BookTrack" => nil,
48
- "Standard" => nil,
49
- "BookSection" => "inbook",
50
- "BookPart" => nil,
51
- "Book" => "book",
52
- "BookChapter" => "inbook",
53
- "StandardSeries" => nil,
54
- "Monograph" => "book",
55
- "Component" => nil,
56
- "ReferenceEntry" => nil,
57
- "JournalVolume" => nil,
58
- "BookSet" => nil,
59
- "PostedContent" => "article"
60
- }
61
-
62
- CONTACT_EMAIL = "tech@datacite.org"
63
-
64
- def initialize(id: nil, string: nil)
65
- id = normalize_doi(id) if id.present?
66
-
67
- if string.present?
68
- @raw = string
69
- elsif id.present?
70
- doi = doi_from_url(id)
71
- url = "http://www.crossref.org/openurl/?id=doi:#{doi}&noredirect=true&pid=#{CONTACT_EMAIL}&format=unixref"
72
- response = Maremma.get(url, accept: "text/xml", raw: true)
73
- @raw = response.body.fetch("data", nil)
74
- @raw = Nokogiri::XML(@raw, nil, 'UTF-8', &:noblanks).to_s if @raw.present?
75
- end
76
- end
77
-
78
- alias_method :crossref, :raw
79
-
80
- def metadata
81
- @metadata ||= if raw.present?
82
- m = Maremma.from_xml(raw).fetch("doi_records", {}).fetch("doi_record", {})
83
- m.dig("crossref", "error").nil? ? m : {}
84
- else
85
- {}
86
- end
87
- end
88
-
89
- def exists?
90
- metadata.present?
91
- end
92
-
93
- def valid?
94
- crossref.present?
95
- end
96
-
97
- def doi
98
- bibliographic_metadata.dig("doi_data", "doi")
99
- end
100
-
101
- def url
102
- bibliographic_metadata.dig("doi_data", "resource")
103
- end
104
-
105
- def id
106
- normalize_doi(doi)
107
- end
108
-
109
- def journal_metadata
110
- @journal_metadata ||=
111
- metadata.dig("crossref", "journal", "journal_metadata").presence || {}
112
- end
113
-
114
- def journal_issue
115
- metadata.dig("crossref", "journal", "journal_issue").presence || {}
116
- end
117
-
118
- def bibliographic_metadata
119
- @bibliographic_metadata ||=
120
- metadata.dig("crossref", "journal", "journal_article").presence ||
121
- metadata.dig("crossref", "conference", "conference_paper").presence ||
122
- metadata.dig("crossref", metadata.fetch("crossref", {}).keys.last).presence || {}
123
- end
124
-
125
- def program_metadata
126
- @program_metadata ||=
127
- bibliographic_metadata.dig("program") ||
128
- bibliographic_metadata.dig("crossmark", "custom_metadata", "program") || {}
129
- end
130
-
131
- def resource_type_general
132
- SO_TO_DC_TRANSLATIONS[type]
133
- end
134
-
135
- def type
136
- CR_TO_SO_TRANSLATIONS[additional_type] || "ScholarlyArticle"
137
- end
138
-
139
- def citeproc_type
140
- CR_TO_CP_TRANSLATIONS[additional_type] || "article-journal"
141
- end
142
-
143
- def ris_type
144
- CR_TO_RIS_TRANSLATIONS[additional_type] || "JOUR"
145
- end
146
-
147
- def additional_type
148
- if metadata.dig("crossref", "journal").present?
149
- metadata.dig("crossref", "journal").keys.last.camelize
150
- else
151
- metadata.dig("crossref").keys.last.camelize
152
- end
153
- end
154
-
155
- def bibtex_type
156
- CR_TO_BIB_TRANSLATIONS[additional_type] || "misc"
157
- end
158
-
159
- def title
160
- parse_attributes(bibliographic_metadata.dig("titles", "title"))
161
- end
162
-
163
- def alternate_name
164
- if bibliographic_metadata.fetch("publisher_item", nil).present?
165
- parse_attributes(bibliographic_metadata.dig("publisher_item", "item_number"))
166
- else
167
- parse_attributes(bibliographic_metadata.fetch("item_number", nil))
168
- end
169
- end
170
-
171
- def description
172
- des = bibliographic_metadata.fetch("abstract", {}).values.first
173
- if des.is_a?(Hash)
174
- des.to_xml
175
- elsif des.is_a?(String)
176
- des
177
- end
178
- end
179
-
180
- def license
181
- access_indicator = Array.wrap(program_metadata).find { |m| m["name"] == "AccessIndicators" }
182
- if access_indicator.present?
183
- { "url" => parse_attributes(access_indicator["license_ref"]) }
184
- else
185
- nil
186
- end
187
- end
188
-
189
- def author
190
- people("author")
191
- end
192
-
193
- def editor
194
- people("editor")
195
- end
196
-
197
- def people(contributor_role)
198
- person = bibliographic_metadata.dig("contributors", "person_name")
199
- Array.wrap(person).select { |a| a["contributor_role"] == contributor_role }.map do |a|
200
- { "type" => "Person",
201
- "id" => parse_attributes(a["ORCID"]),
202
- "name" => [a["given_name"], a["surname"]].join(" "),
203
- "givenName" => a["given_name"],
204
- "familyName" => a["surname"] }.compact
205
- end.unwrap
206
- end
207
-
208
- def funder
209
- fundref = Array.wrap(program_metadata).find { |a| a["name"] == "fundref" } || {}
210
- Array.wrap(fundref.fetch("assertion", [])).select { |a| a["name"] == "fundgroup" }.map do |f|
211
- { "id" => normalize_id(f.dig("assertion", "assertion", "__content__")),
212
- "name" => f.dig("assertion", "__content__").strip }.compact
213
- end.unwrap
214
- end
215
-
216
- def date_published
217
- pub_date = Array.wrap(bibliographic_metadata.fetch("publication_date", nil)).presence ||
218
- Array.wrap(bibliographic_metadata.fetch("acceptance_date", nil))
219
- if pub_date.present?
220
- get_date_from_parts(pub_date.first["year"], pub_date.first["month"], pub_date.first["day"])
221
- else
222
- nil
223
- end
224
- end
225
-
226
- def date_modified
227
- Time.parse(metadata.fetch("timestamp", "")).utc.iso8601
228
- end
229
-
230
- def volume
231
- journal_issue.dig("journal_volume", "volume")
232
- end
233
-
234
- def issue
235
- journal_issue.dig("issue")
236
- end
237
-
238
- def page_start
239
- bibliographic_metadata.dig("pages", "first_page")
240
- end
241
-
242
- def page_end
243
- bibliographic_metadata.dig("pages", "last_page")
244
- end
245
-
246
- def is_part_of
247
- if journal_metadata.present?
248
- { "type" => "Periodical",
249
- "name" => journal_metadata["full_title"],
250
- "issn" => parse_attributes(journal_metadata.fetch("issn", nil)) }.compact
251
- else
252
- nil
253
- end
254
- end
255
-
256
- def container_title
257
- is_part_of.to_h.fetch("name", nil)
258
- end
259
-
260
- alias_method :journal, :container_title
261
-
262
- def related_identifier(relation_type: nil)
263
- references
264
- end
265
-
266
- def references
267
- refs = bibliographic_metadata.dig("citation_list", "citation")
268
- Array.wrap(refs).map do |c|
269
- { "id" => normalize_id(c["doi"]),
270
- "relationType" => "Cites",
271
- "position" => c["key"],
272
- "name" => c["article_title"],
273
- "datePublished" => c["cYear"] }.compact
274
- end.unwrap
275
- end
276
-
277
- def provider
278
- "Crossref"
279
- end
280
- end
281
- end
@@ -1,288 +0,0 @@
1
- module Bolognese
2
- class Datacite < Metadata
3
- def initialize(id: nil, string: nil, regenerate: false)
4
- id = normalize_doi(id) if id.present?
5
-
6
- if string.present?
7
- @raw = string
8
- elsif id.present?
9
- doi = doi_from_url(id)
10
- url = "https://search.datacite.org/api?q=doi:#{doi}&fl=doi,xml,media,minted,updated&wt=json"
11
- response = Maremma.get url
12
- attributes = response.body.dig("data", "response", "docs").first
13
- @raw = attributes.fetch('xml', "PGhzaD48L2hzaD4=\n")
14
- @raw = Base64.decode64(@raw)
15
- @doc = Nokogiri::XML(@raw, nil, 'UTF-8', &:noblanks) if @raw.present?
16
- @raw = @doc.to_s if @raw.present?
17
- end
18
-
19
- @should_passthru = !regenerate
20
- end
21
-
22
- # generate new DataCite XML version 4.0 if regenerate (!should_passthru) option is provided
23
- def datacite
24
- should_passthru ? raw : datacite_xml
25
- end
26
-
27
- def metadata
28
- @metadata ||= raw.present? ? Maremma.from_xml(raw).fetch("resource", {}) : {}
29
- end
30
-
31
- def exists?
32
- metadata.present?
33
- end
34
-
35
- def valid?
36
- datacite.present? && errors.blank?
37
- end
38
-
39
- def errors
40
- doc && doc.errors.map { |error| error.to_s }.unwrap
41
- end
42
-
43
- def schema_version
44
- metadata.fetch("xmlns", nil)
45
- end
46
-
47
- def doi
48
- metadata.fetch("identifier", {}).fetch("__content__", nil)
49
- end
50
-
51
- def id
52
- normalize_doi(doi)
53
- end
54
-
55
- def resource_type_general
56
- metadata.dig("resourceType", "resourceTypeGeneral")
57
- end
58
-
59
- def type
60
- DC_TO_SO_TRANSLATIONS[resource_type_general.to_s.dasherize] || "CreativeWork"
61
- end
62
-
63
- def citeproc_type
64
- DC_TO_CP_TRANSLATIONS[resource_type_general.to_s.dasherize] || "other"
65
- end
66
-
67
- def ris_type
68
- DC_TO_RIS_TRANSLATIONS[resource_type_general.to_s.dasherize] || "GEN"
69
- end
70
-
71
- def additional_type
72
- metadata.fetch("resourceType", {}).fetch("__content__", nil) ||
73
- metadata.fetch("resourceType", {}).fetch("resourceTypeGeneral", nil)
74
- end
75
-
76
- def bibtex_type
77
- Bolognese::Bibtex::SO_TO_BIB_TRANSLATIONS[type] || "misc"
78
- end
79
-
80
- def title
81
- Array.wrap(metadata.dig("titles", "title")).map do |r|
82
- if r.is_a?(String)
83
- sanitize(r)
84
- else
85
- { "title_type" => r["titleType"], "lang" => r["xml:lang"], "text" => sanitize(r["__content__"]) }.compact
86
- end
87
- end.unwrap
88
- end
89
-
90
- def alternate_name
91
- Array.wrap(metadata.dig("alternateIdentifiers", "alternateIdentifier")).map do |r|
92
- { "type" => r["alternateIdentifierType"], "name" => r["__content__"] }.compact
93
- end.unwrap
94
- end
95
-
96
- def description
97
- Array.wrap(metadata.dig("descriptions", "description")).map do |r|
98
- { "type" => r["descriptionType"], "text" => sanitize(r["__content__"]) }.compact
99
- end.unwrap
100
- end
101
-
102
- def license
103
- Array.wrap(metadata.dig("rightsList", "rights")).map do |r|
104
- { "url" => r["rightsURI"], "name" => r["__content__"] }.compact
105
- end.unwrap
106
- end
107
-
108
- def keywords
109
- Array.wrap(metadata.dig("subjects", "subject")).map do |k|
110
- if k.is_a?(String)
111
- sanitize(k)
112
- else
113
- k.fetch("__content__", nil)
114
- end
115
- end.compact.join(", ").presence
116
- end
117
-
118
- def author
119
- get_authors(metadata.dig("creators", "creator"))
120
- end
121
-
122
- def editor
123
- get_authors(Array.wrap(metadata.dig("contributors", "contributor"))
124
- .select { |r| r["contributorType"] == "Editor" })
125
- end
126
-
127
- def funder
128
- f = funder_contributor + funding_reference
129
- f.length > 1 ? f : f.first
130
- end
131
-
132
- def funder_contributor
133
- Array.wrap(metadata.dig("contributors", "contributor")).reduce([]) do |sum, f|
134
- if f["contributorType"] == "Funder"
135
- sum << { "name" => f["contributorName"] }
136
- else
137
- sum
138
- end
139
- end
140
- end
141
-
142
- def funding_reference
143
- Array.wrap(metadata.dig("fundingReferences", "fundingReference")).map do |f|
144
- funder_id = parse_attributes(f["funderIdentifier"])
145
- { "identifier" => normalize_id(funder_id),
146
- "name" => f["funderName"] }.compact
147
- end.uniq
148
- end
149
-
150
- def version
151
- metadata.fetch("version", nil)
152
- end
153
-
154
- def dates
155
- Array.wrap(metadata.dig("dates", "date"))
156
- end
157
-
158
- #Accepted Available Copyrighted Collected Created Issued Submitted Updated Valid
159
-
160
- def date(date_type)
161
- dd = dates.find { |d| d["dateType"] == date_type } || {}
162
- dd.fetch("__content__", nil)
163
- end
164
-
165
- def date_accepted
166
- date("Accepted")
167
- end
168
-
169
- def date_available
170
- date("Available")
171
- end
172
-
173
- def date_copyrighted
174
- date("Copyrighted")
175
- end
176
-
177
- def date_collected
178
- date("Collected")
179
- end
180
-
181
- def date_created
182
- date("Created")
183
- end
184
-
185
- # use datePublished for date issued
186
- def date_published
187
- date("Issued") || publication_year
188
- end
189
-
190
- def date_submitted
191
- date("Submitted")
192
- end
193
-
194
- # use dateModified for date updated
195
- def date_modified
196
- date("Updated")
197
- end
198
-
199
- def date_valid
200
- date("Valid")
201
- end
202
-
203
- def publication_year
204
- metadata.fetch("publicationYear", nil)
205
- end
206
-
207
- def language
208
- metadata.fetch("language", nil)
209
- end
210
-
211
- def spatial_coverage
212
-
213
- end
214
-
215
- def content_size
216
- metadata.fetch("size", nil)
217
- end
218
-
219
- def related_identifier(relation_type: nil)
220
- arr = Array.wrap(metadata.dig("relatedIdentifiers", "relatedIdentifier")).select { |r| %w(DOI URL).include?(r["relatedIdentifierType"]) }
221
- arr = arr.select { |r| relation_type.split(" ").include?(r["relationType"]) } if relation_type.present?
222
-
223
- arr.map { |work| { "id" => normalize_id(work["__content__"]), "relationType" => work["relationType"] } }.unwrap
224
- end
225
-
226
- def is_identical_to
227
- related_identifier(relation_type: "IsIdenticalTo")
228
- end
229
-
230
- def is_part_of
231
- related_identifier(relation_type: "IsPartOf")
232
- end
233
-
234
- def has_part
235
- related_identifier(relation_type: "HasPart")
236
- end
237
-
238
- def is_previous_version_of
239
- related_identifier(relation_type: "IsPreviousVersionOf")
240
- end
241
-
242
- def is_new_version_of
243
- related_identifier(relation_type: "IsNewVersionOf")
244
- end
245
-
246
- def is_variant_form_of
247
- related_identifier(relation_type: "IsVariantFormOf")
248
- end
249
-
250
- def is_original_form_of
251
- related_identifier(relation_type: "IsOriginalFormOf")
252
- end
253
-
254
- def references
255
- related_identifier(relation_type: "References Cites").presence
256
- end
257
-
258
- def is_referenced_by
259
- related_identifier(relation_type: "IsCitedBy IsReferencedBy").presence
260
- end
261
-
262
- def is_supplement_to
263
- related_identifier(relation_type: "IsSupplementTo")
264
- end
265
-
266
- def is_supplemented_by
267
- get_related_identifier(relation_type: "isSupplementedBy")
268
- end
269
-
270
- def reviews
271
- related_identifier(relation_type: "Reviews").presence
272
- end
273
-
274
- def is_reviewed_by
275
- related_identifier(relation_type: "IsReviewedBy").presence
276
- end
277
-
278
- def publisher
279
- metadata.fetch("publisher")
280
- end
281
-
282
- alias_method :container_title, :publisher
283
-
284
- def provider
285
- "DataCite"
286
- end
287
- end
288
- end