briard 2.7.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (534) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rubocop.yml +6 -6
  3. data/.rubocop.yml +1 -1
  4. data/Gemfile.lock +6 -6
  5. data/README.md +8 -1
  6. data/briard.gemspec +3 -3
  7. data/lib/briard/author_utils.rb +50 -33
  8. data/lib/briard/doi_utils.rb +14 -8
  9. data/lib/briard/metadata.rb +1 -1
  10. data/lib/briard/metadata_utils.rb +2 -0
  11. data/lib/briard/readers/crossref_json_reader.rb +167 -0
  12. data/lib/briard/readers/crossref_reader.rb +6 -7
  13. data/lib/briard/readers/datacite_reader.rb +1 -1
  14. data/lib/briard/readers/schema_org_reader.rb +1 -1
  15. data/lib/briard/utils.rb +892 -807
  16. data/lib/briard/version.rb +1 -1
  17. data/lib/briard/writers/datacite_json_writer.rb +5 -5
  18. data/lib/briard/writers/jats_writer.rb +12 -12
  19. data/spec/author_utils_spec.rb +36 -32
  20. data/spec/cli_spec.rb +1 -1
  21. data/spec/doi_utils_spec.rb +8 -8
  22. data/spec/fixtures/crossref.json +572 -0
  23. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/crossref/default.yml +11 -13
  24. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/crossref/to_bibtex.yml +11 -13
  25. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/crossref/to_citation.yml +11 -13
  26. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/crossref/to_crossref.yml +11 -13
  27. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/crossref/to_datacite.yml +11 -13
  28. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/crossref/to_jats.yml +11 -13
  29. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/crossref/to_schema_org.yml +11 -13
  30. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/datacite/default.yml +14 -16
  31. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/datacite/to_bibtex.yml +14 -16
  32. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/datacite/to_citation.yml +14 -16
  33. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/datacite/to_datacite.yml +14 -16
  34. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/datacite/to_datacite_json.yml +14 -16
  35. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/datacite/to_jats.yml +14 -16
  36. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/datacite/to_schema_org.yml +14 -16
  37. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/schema_org/default.yml +9 -9
  38. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/schema_org/to_datacite.yml +9 -9
  39. data/spec/fixtures/vcr_cassettes/Briard_CLI/convert_from_id/schema_org/to_schema_org.yml +13 -11
  40. data/spec/fixtures/vcr_cassettes/Briard_CLI/find_from_format_by_id/crossref.yml +5 -7
  41. data/spec/fixtures/vcr_cassettes/Briard_CLI/find_from_format_by_id/datacite.yml +5 -7
  42. data/spec/fixtures/vcr_cassettes/Briard_CLI/find_from_format_by_id/jalc.yml +5 -7
  43. data/spec/fixtures/vcr_cassettes/Briard_CLI/find_from_format_by_id/kisti.yml +5 -7
  44. data/spec/fixtures/vcr_cassettes/Briard_CLI/find_from_format_by_id/medra.yml +5 -7
  45. data/spec/fixtures/vcr_cassettes/Briard_CLI/find_from_format_by_id/op.yml +5 -7
  46. data/spec/fixtures/vcr_cassettes/Briard_Metadata/authors_as_string/author.yml +7 -7
  47. data/spec/fixtures/vcr_cassettes/Briard_Metadata/authors_as_string/no_author.yml +6 -6
  48. data/spec/fixtures/vcr_cassettes/Briard_Metadata/authors_as_string/single_author.yml +6 -6
  49. data/spec/fixtures/vcr_cassettes/Briard_Metadata/authors_as_string/with_organization.yml +7 -7
  50. data/spec/fixtures/vcr_cassettes/Briard_Metadata/change_datacite_metadata/change_state.yml +14 -16
  51. data/spec/fixtures/vcr_cassettes/Briard_Metadata/change_datacite_metadata/change_title.yml +14 -16
  52. data/spec/fixtures/vcr_cassettes/Briard_Metadata/change_metadata_as_datacite_xml/change_description.yml +6 -6
  53. data/spec/fixtures/vcr_cassettes/Briard_Metadata/change_metadata_as_datacite_xml/change_identifiers.yml +6 -6
  54. data/spec/fixtures/vcr_cassettes/Briard_Metadata/change_metadata_as_datacite_xml/change_license.yml +6 -6
  55. data/spec/fixtures/vcr_cassettes/Briard_Metadata/change_metadata_as_datacite_xml/change_license_name.yml +6 -6
  56. data/spec/fixtures/vcr_cassettes/Briard_Metadata/change_metadata_as_datacite_xml/change_license_url.yml +6 -6
  57. data/spec/fixtures/vcr_cassettes/Briard_Metadata/change_metadata_as_datacite_xml/change_state.yml +6 -6
  58. data/spec/fixtures/vcr_cassettes/Briard_Metadata/change_metadata_as_datacite_xml/validates_against_schema.yml +6 -6
  59. data/spec/fixtures/vcr_cassettes/Briard_Metadata/change_metadata_as_datacite_xml/with_data_citation.yml +6 -6
  60. data/spec/fixtures/vcr_cassettes/Briard_Metadata/{doi_api_url/https_url.yml → datacite_api_url/doi.yml} +6 -6
  61. data/spec/fixtures/vcr_cassettes/Briard_Metadata/{doi_api_url/doi.yml → datacite_api_url/doi_with_protocol.yml} +6 -6
  62. data/spec/fixtures/vcr_cassettes/Briard_Metadata/{sanitize/should_only_keep_specific_tags.yml → datacite_api_url/dx_doi_org_url.yml} +6 -6
  63. data/spec/fixtures/vcr_cassettes/Briard_Metadata/datacite_api_url/force_test_resolver.yml +65 -0
  64. data/spec/fixtures/vcr_cassettes/Briard_Metadata/datacite_api_url/https_url.yml +65 -0
  65. data/spec/fixtures/vcr_cassettes/Briard_Metadata/{doi_api_url → datacite_api_url}/test_resolver.yml +6 -6
  66. data/spec/fixtures/vcr_cassettes/Briard_Metadata/{doi_api_url → datacite_api_url}/test_resolver_http.yml +6 -6
  67. data/spec/fixtures/vcr_cassettes/Briard_Metadata/{doi_api_url/doi_with_protocol.yml → doi_from_url/crossref_api_url.yml} +6 -6
  68. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_from_url/doi.yml +7 -7
  69. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_from_url/doi_with_special_characters.yml +6 -6
  70. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_from_url/not_a_doi.yml +7 -7
  71. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_from_url/sandbox_url.yml +6 -6
  72. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_from_url/url.yml +7 -7
  73. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_registration_agency/crossref.yml +12 -14
  74. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_registration_agency/datacite.yml +11 -13
  75. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_registration_agency/jalc.yml +11 -13
  76. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_registration_agency/kisti.yml +12 -14
  77. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_registration_agency/medra.yml +12 -14
  78. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_registration_agency/not_a_valid_prefix.yml +6 -6
  79. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_registration_agency/not_found.yml +11 -13
  80. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_registration_agency/op.yml +11 -13
  81. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_resolver/doi.yml +6 -6
  82. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_resolver/doi_with_protocol.yml +7 -7
  83. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_resolver/dx_doi_org_url.yml +6 -6
  84. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_resolver/force_stage_resolver.yml +7 -7
  85. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_resolver/https_url.yml +7 -7
  86. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_resolver/stage_resolver.yml +6 -6
  87. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_resolver/stage_resolver_http.yml +7 -7
  88. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_by_ID/crossref.yml +19 -23
  89. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_by_ID/crossref_doi_not_url.yml +19 -23
  90. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_by_ID/datacite.yml +19 -23
  91. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_by_ID/datacite_doi_http.yml +19 -23
  92. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_by_ID/github.yml +14 -16
  93. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_by_ID/orcid.yml +14 -16
  94. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_by_ID/schema_org.yml +14 -16
  95. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_by_ID/unknown_DOI_registration_agency.yml +19 -23
  96. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_from_file/bibtex.yml +14 -16
  97. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_from_file/citeproc.yml +14 -16
  98. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_from_file/codemeta.yml +14 -16
  99. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_from_file/crosscite.yml +14 -16
  100. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_from_file/crossref.yml +14 -16
  101. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_from_file/datacite.yml +14 -16
  102. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_from_file/datacite_json.yml +14 -16
  103. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_from_file/ris.yml +14 -16
  104. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_from_file/schema_org.yml +14 -16
  105. data/spec/fixtures/vcr_cassettes/Briard_Metadata/find_from_format_from_string/crosscite.yml +14 -16
  106. data/spec/fixtures/vcr_cassettes/Briard_Metadata/fos/hsh_to_fos_for_match.yml +6 -6
  107. data/spec/fixtures/vcr_cassettes/Briard_Metadata/fos/hsh_to_fos_for_with_schemeUri_in_hash.yml +7 -7
  108. data/spec/fixtures/vcr_cassettes/Briard_Metadata/fos/hsh_to_fos_match.yml +6 -6
  109. data/spec/fixtures/vcr_cassettes/Briard_Metadata/fos/hsh_to_fos_no_match.yml +6 -6
  110. data/spec/fixtures/vcr_cassettes/Briard_Metadata/fos/name_to_fos_for_match.yml +7 -7
  111. data/spec/fixtures/vcr_cassettes/Briard_Metadata/fos/name_to_fos_match.yml +6 -6
  112. data/spec/fixtures/vcr_cassettes/Briard_Metadata/fos/name_to_fos_no_match.yml +7 -7
  113. data/spec/fixtures/vcr_cassettes/Briard_Metadata/from_schema_org/with_id.yml +7 -7
  114. data/spec/fixtures/vcr_cassettes/Briard_Metadata/from_schema_org_creators/with_affiliation.yml +6 -6
  115. data/spec/fixtures/vcr_cassettes/Briard_Metadata/from_schema_org_creators/without_affiliation.yml +7 -7
  116. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_cff_metadata/cff-converter-python.yml +8 -8
  117. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_cff_metadata/ruby-cff.yml +13 -13
  118. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_cff_metadata/ruby-cff_repository_url.yml +14 -14
  119. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_codemeta_metadata/maremma.yml +9 -9
  120. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_codemeta_metadata/metadata_reports.yml +8 -8
  121. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/DOI_with_ORCID_ID.yml +112 -0
  122. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/DOI_with_SICI_DOI.yml +112 -0
  123. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/DOI_with_data_citation.yml +112 -0
  124. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/JaLC.yml +112 -0
  125. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/KISTI.yml +112 -0
  126. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/OP.yml +112 -0
  127. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/affiliation_is_space.yml +112 -0
  128. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/another_book.yml +112 -0
  129. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/another_book_chapter.yml +112 -0
  130. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/article_id_as_page_number.yml +112 -0
  131. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/author_literal.yml +112 -0
  132. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/book.yml +112 -0
  133. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/book_chapter.yml +112 -0
  134. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/book_chapter_with_RDF_for_container.yml +112 -0
  135. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/book_oup.yml +112 -0
  136. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/component.yml +112 -0
  137. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/dataset.yml +112 -0
  138. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/dataset_usda.yml +112 -0
  139. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/date_in_future.yml +112 -0
  140. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/dissertation.yml +112 -0
  141. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/empty_given_name.yml +112 -0
  142. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/invalid_date.yml +112 -0
  143. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/journal_article.yml +112 -0
  144. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/journal_article_original_language_title.yml +112 -0
  145. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/journal_article_with.yml +112 -0
  146. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/journal_article_with_RDF_for_container.yml +112 -0
  147. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/journal_article_with_funding.yml +112 -0
  148. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/journal_issue.yml +112 -0
  149. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/mEDRA.yml +112 -0
  150. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/markup.yml +112 -0
  151. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/missing_creator.yml +112 -0
  152. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/multiple_issn.yml +112 -0
  153. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/multiple_titles.yml +112 -0
  154. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/multiple_titles_with_missing.yml +112 -0
  155. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/not_found_error.yml +105 -0
  156. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/peer_review.yml +112 -0
  157. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/posted_content.yml +112 -0
  158. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/posted_content_copernicus.yml +112 -0
  159. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/report_osti.yml +112 -0
  160. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/vor_with_url.yml +112 -0
  161. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/yet_another_book.yml +112 -0
  162. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_json_metadata/yet_another_book_chapter.yml +112 -0
  163. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/DOI_with_ORCID_ID.yml +11 -13
  164. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/DOI_with_SICI_DOI.yml +13 -15
  165. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/DOI_with_data_citation.yml +11 -13
  166. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/JaLC.yml +11 -13
  167. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/KISTI.yml +13 -15
  168. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/OP.yml +13 -15
  169. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/affiliation_is_space.yml +13 -15
  170. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/another_book.yml +12 -14
  171. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/another_book_chapter.yml +11 -13
  172. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/article_id_as_page_number.yml +12 -14
  173. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/author_literal.yml +13 -15
  174. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/book.yml +13 -15
  175. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/book_chapter.yml +12 -14
  176. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/book_chapter_with_RDF_for_container.yml +11 -13
  177. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/book_oup.yml +11 -13
  178. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/component.yml +11 -13
  179. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/dataset.yml +11 -13
  180. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/dataset_usda.yml +11 -13
  181. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/date_in_future.yml +11 -13
  182. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/dissertation.yml +11 -13
  183. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/empty_given_name.yml +11 -13
  184. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/invalid_date.yml +11 -13
  185. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/journal_article.yml +58 -62
  186. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/journal_article_original_language_title.yml +58 -61
  187. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/journal_article_with.yml +13 -15
  188. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/journal_article_with_RDF_for_container.yml +12 -14
  189. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/journal_article_with_funding.yml +58 -62
  190. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/journal_issue.yml +11 -13
  191. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/mEDRA.yml +12 -14
  192. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/markup.yml +13 -15
  193. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/missing_creator.yml +11 -13
  194. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/multiple_issn.yml +11 -13
  195. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/multiple_titles.yml +11 -13
  196. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/multiple_titles_with_missing.yml +12 -14
  197. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/not_found_error.yml +11 -13
  198. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/peer_review.yml +11 -13
  199. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/posted_content.yml +12 -14
  200. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/posted_content_copernicus.yml +11 -13
  201. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/report_osti.yml +12 -14
  202. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/vor_with_url.yml +13 -15
  203. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/yet_another_book.yml +11 -13
  204. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_crossref_metadata/yet_another_book_chapter.yml +11 -13
  205. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_json_metadata/metadata_from_api.yml +14 -16
  206. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/BlogPosting.yml +14 -16
  207. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/DOI_in_staging_system.yml +14 -16
  208. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/DOI_in_staging_system_schema_3.yml +14 -16
  209. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/DOI_in_with_related_id_system.yml +14 -16
  210. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/DOI_not_found.yml +13 -15
  211. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/Dataset.yml +14 -16
  212. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/Funding.yml +14 -16
  213. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/Funding_empty_awardTitle.yml +14 -16
  214. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/Funding_schema_version_4.yml +14 -16
  215. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/Referee_report_in_staging_system.yml +14 -16
  216. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/Schema_org_type.yml +14 -16
  217. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/author_only_full_name.yml +14 -16
  218. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/author_with_scheme.yml +14 -16
  219. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/author_with_wrong_orcid_scheme.yml +14 -16
  220. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/cc-by_3_0_us.yml +14 -16
  221. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/content_url.yml +14 -16
  222. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/date.yml +14 -16
  223. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/dissertation.yml +14 -16
  224. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/doi_with_sign.yml +14 -16
  225. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/empty_subject.yml +14 -16
  226. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/even_more_subject_scheme_FOR.yml +14 -16
  227. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/funding_references.yml +14 -16
  228. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/funding_schema_version_3.yml +14 -16
  229. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/is_identical_to.yml +14 -16
  230. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/keywords_with_attributes.yml +14 -16
  231. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/leading_and_trailing_whitespace.yml +14 -16
  232. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/more_subject_scheme_FOR.yml +14 -16
  233. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/multiple_author_names_in_one_creatorsName.yml +14 -16
  234. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/multiple_licenses.yml +14 -16
  235. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/series-information.yml +14 -16
  236. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/subject_scheme.yml +14 -16
  237. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datacite_metadata/subject_scheme_FOR.yml +14 -16
  238. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_date/publication_date.yml +7 -7
  239. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_date_from_date_parts/date.yml +6 -6
  240. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_date_from_date_parts/year-month.yml +6 -6
  241. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_date_from_date_parts/year.yml +6 -6
  242. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_date_from_parts/date.yml +6 -6
  243. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_date_from_parts/year-month.yml +7 -7
  244. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_date_from_parts/year.yml +6 -6
  245. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_date_parts/date.yml +6 -6
  246. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_date_parts/year-month.yml +7 -7
  247. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_date_parts/year.yml +6 -6
  248. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datetime_from_time/future.yml +7 -7
  249. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datetime_from_time/invalid.yml +7 -7
  250. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datetime_from_time/nil.yml +6 -6
  251. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datetime_from_time/past.yml +6 -6
  252. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_datetime_from_time/present.yml +6 -6
  253. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_one_author/has_familyName.yml +9 -9
  254. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_one_author/has_name_in_Thai.yml +9 -9
  255. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_one_author/has_name_in_display-order.yml +9 -9
  256. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_one_author/has_name_in_display-order_with_ORCID.yml +9 -9
  257. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_one_author/has_name_in_sort-order.yml +9 -9
  258. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_one_author/hyper-authorship.yml +9 -9
  259. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_one_author/is_organization.yml +6 -6
  260. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_one_author/multiple_author_names_in_one_field.yml +9 -9
  261. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_one_author/multiple_name_identifier.yml +9 -9
  262. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_one_author/name_with_affiliation.yml +9 -9
  263. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_one_author/name_with_affiliation_and_country.yml +7 -7
  264. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_one_author/name_with_affiliation_crossref.yml +112 -0
  265. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_one_author/name_with_role.yml +9 -9
  266. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_one_author/only_familyName_and_givenName.yml +10 -10
  267. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_schema_org_metadata/BlogPosting.yml +19 -19
  268. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_schema_org_metadata/BlogPosting_with_new_DOI.yml +19 -19
  269. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_schema_org_metadata/get_schema_org_metadata_front_matter/BlogPosting.yml +21 -21
  270. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_schema_org_metadata/harvard_dataverse.yml +7 -7
  271. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_schema_org_metadata/pangaea.yml +10 -10
  272. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_schema_org_metadata/zenodo.yml +10 -10
  273. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_series_information/only_title.yml +6 -6
  274. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_series_information/title_and_pages.yml +7 -7
  275. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_series_information/title_volume_and_pages.yml +6 -6
  276. data/spec/fixtures/vcr_cassettes/Briard_Metadata/get_series_information/title_volume_issue_and_pages.yml +6 -6
  277. data/spec/fixtures/vcr_cassettes/Briard_Metadata/github/github_as_cff_url.yml +6 -6
  278. data/spec/fixtures/vcr_cassettes/Briard_Metadata/github/github_as_codemeta_url.yml +6 -6
  279. data/spec/fixtures/vcr_cassettes/Briard_Metadata/github/github_from_url.yml +7 -7
  280. data/spec/fixtures/vcr_cassettes/Briard_Metadata/github/github_from_url_cff_file.yml +7 -7
  281. data/spec/fixtures/vcr_cassettes/Briard_Metadata/github/github_from_url_file.yml +7 -7
  282. data/spec/fixtures/vcr_cassettes/Briard_Metadata/handle_input/DOI_RA_not_Crossref_or_DataCite.yml +5 -7
  283. data/spec/fixtures/vcr_cassettes/Briard_Metadata/handle_input/unknown_DOI_prefix.yml +5 -7
  284. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_contributors/none.yml +9 -9
  285. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_creators/insert.yml +9 -9
  286. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_dates/insert.yml +9 -9
  287. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_descriptions/insert.yml +9 -9
  288. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_identifier/doi.yml +9 -9
  289. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_language/insert.yml +9 -9
  290. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_person/creator_only_name.yml +9 -9
  291. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_publication_year/insert.yml +9 -9
  292. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_publisher/insert.yml +9 -9
  293. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_related_identifiers/insert.yml +9 -9
  294. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_related_identifiers/related_identifier.yml +9 -9
  295. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_resource_type/insert.yml +9 -9
  296. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_rights_list/insert.yml +9 -9
  297. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_sizes/insert.yml +9 -9
  298. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_subjects/insert.yml +9 -9
  299. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_titles/insert.yml +9 -9
  300. data/spec/fixtures/vcr_cassettes/Briard_Metadata/insert_version/insert.yml +9 -9
  301. data/spec/fixtures/vcr_cassettes/Briard_Metadata/is_personal_name_/has_comma.yml +7 -7
  302. data/spec/fixtures/vcr_cassettes/Briard_Metadata/is_personal_name_/has_family_name.yml +7 -7
  303. data/spec/fixtures/vcr_cassettes/Briard_Metadata/{doi_api_url/dx_doi_org_url.yml → is_personal_name_/has_family_name_crossref.yml} +6 -6
  304. data/spec/fixtures/vcr_cassettes/Briard_Metadata/is_personal_name_/has_id.yml +6 -6
  305. data/spec/fixtures/vcr_cassettes/Briard_Metadata/is_personal_name_/has_known_given_name.yml +6 -6
  306. data/spec/fixtures/vcr_cassettes/Briard_Metadata/is_personal_name_/has_no_info.yml +7 -7
  307. data/spec/fixtures/vcr_cassettes/Briard_Metadata/is_personal_name_/has_orcid_id.yml +6 -6
  308. data/spec/fixtures/vcr_cassettes/Briard_Metadata/is_personal_name_/has_type_organization.yml +6 -6
  309. data/spec/fixtures/vcr_cassettes/Briard_Metadata/jsonlint/missing_comma.yml +14 -16
  310. data/spec/fixtures/vcr_cassettes/Briard_Metadata/jsonlint/nil.yml +14 -16
  311. data/spec/fixtures/vcr_cassettes/Briard_Metadata/jsonlint/overlapping_keys.yml +14 -16
  312. data/spec/fixtures/vcr_cassettes/Briard_Metadata/jsonlint/valid.yml +14 -16
  313. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_cc_url/not_found.yml +7 -7
  314. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_cc_url/with_trailing_slash.yml +6 -6
  315. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_cc_url/with_trailing_slash_and_to_https.yml +7 -7
  316. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_doi/SICI_doi.yml +6 -6
  317. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_doi/doi.yml +6 -6
  318. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_doi/doi_force_datacite_sandbox.yml +7 -7
  319. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_doi/doi_from_datacite_sandbox.yml +7 -7
  320. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_doi/doi_from_url_without_doi_proxy.yml +6 -6
  321. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_doi/doi_prefix_too_long.yml +6 -6
  322. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_doi/doi_prefix_with_string.yml +7 -7
  323. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_doi/doi_with_protocol.yml +7 -7
  324. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_doi/dx_doi_org_url.yml +7 -7
  325. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_doi/https_url.yml +7 -7
  326. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_doi/not_valid_doi_prefix.yml +6 -6
  327. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_doi/url_with_one_slash.yml +6 -6
  328. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_id/doi.yml +6 -6
  329. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_id/doi_as_url.yml +6 -6
  330. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_id/ftp.yml +6 -6
  331. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_id/invalid_url.yml +6 -6
  332. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_id/sandbox_via_options.yml +6 -6
  333. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_id/sandbox_via_url.yml +7 -7
  334. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_id/string.yml +6 -6
  335. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_id/url.yml +6 -6
  336. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_id/url_with_utf-8.yml +7 -7
  337. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_ids/doi.yml +6 -6
  338. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_ids/url.yml +6 -6
  339. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_issn/from_array.yml +6 -6
  340. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_issn/from_empty_array.yml +7 -7
  341. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_issn/from_hash.yml +7 -7
  342. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_issn/from_string.yml +7 -7
  343. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_url/uri.yml +6 -6
  344. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_url/with_trailing_slash.yml +6 -6
  345. data/spec/fixtures/vcr_cassettes/Briard_Metadata/normalize_url/with_trailing_slash_and_to_https.yml +6 -6
  346. data/spec/fixtures/vcr_cassettes/Briard_Metadata/parse_attributes/array.yml +6 -6
  347. data/spec/fixtures/vcr_cassettes/Briard_Metadata/parse_attributes/array_of_strings.yml +7 -7
  348. data/spec/fixtures/vcr_cassettes/Briard_Metadata/parse_attributes/first.yml +6 -6
  349. data/spec/fixtures/vcr_cassettes/Briard_Metadata/parse_attributes/hash.yml +6 -6
  350. data/spec/fixtures/vcr_cassettes/Briard_Metadata/parse_attributes/nil.yml +6 -6
  351. data/spec/fixtures/vcr_cassettes/Briard_Metadata/parse_attributes/string.yml +6 -6
  352. data/spec/fixtures/vcr_cassettes/Briard_Metadata/random_doi/decode_anothe_doi.yml +6 -6
  353. data/spec/fixtures/vcr_cassettes/Briard_Metadata/random_doi/decode_doi.yml +6 -6
  354. data/spec/fixtures/vcr_cassettes/Briard_Metadata/random_doi/encode_doi.yml +6 -6
  355. data/spec/fixtures/vcr_cassettes/Briard_Metadata/sanitize/onlies_keep_specific_tags.yml +7 -7
  356. data/spec/fixtures/vcr_cassettes/Briard_Metadata/sanitize/removes_a_tags.yml +6 -6
  357. data/spec/fixtures/vcr_cassettes/Briard_Metadata/spdx/hsh_to_spdx_id.yml +7 -7
  358. data/spec/fixtures/vcr_cassettes/Briard_Metadata/spdx/hsh_to_spdx_not_found.yml +7 -7
  359. data/spec/fixtures/vcr_cassettes/Briard_Metadata/spdx/hsh_to_spdx_url.yml +6 -6
  360. data/spec/fixtures/vcr_cassettes/Briard_Metadata/spdx/name_to_spdx_exists.yml +6 -6
  361. data/spec/fixtures/vcr_cassettes/Briard_Metadata/spdx/name_to_spdx_id.yml +6 -6
  362. data/spec/fixtures/vcr_cassettes/Briard_Metadata/to_schema_org/with_id.yml +6 -6
  363. data/spec/fixtures/vcr_cassettes/Briard_Metadata/to_schema_org_identifiers/with_identifiers.yml +6 -6
  364. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_doi/doi.yml +6 -6
  365. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_funder_doi/1_7_10.yml +7 -7
  366. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_funder_doi/1_7_11.yml +6 -6
  367. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_funder_doi/1_7_12.yml +7 -7
  368. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_funder_doi/1_7_13.yml +6 -6
  369. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_funder_doi/1_7_14.yml +7 -7
  370. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_funder_doi/1_7_4.yml +7 -7
  371. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_funder_doi/1_7_5.yml +6 -6
  372. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_funder_doi/1_7_6.yml +7 -7
  373. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_funder_doi/1_7_7.yml +6 -6
  374. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_funder_doi/1_7_8.yml +6 -6
  375. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_funder_doi/1_7_9.yml +6 -6
  376. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_funder_doi/funder_doi.yml +6 -6
  377. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_funder_doi/funder_doi_without_prefix.yml +6 -6
  378. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_funder_doi/non-funder_doi.yml +6 -6
  379. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_orcid/validate_orcid.yml +7 -7
  380. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_orcid/validate_orcid_https.yml +6 -6
  381. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_orcid/validate_orcid_id.yml +7 -7
  382. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_orcid/validate_orcid_sandbox.yml +6 -6
  383. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_orcid/validate_orcid_sandbox_https.yml +7 -7
  384. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_orcid/validate_orcid_with_spaces.yml +6 -6
  385. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_orcid/validate_orcid_wrong_id.yml +7 -7
  386. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_orcid/validate_orcid_www.yml +7 -7
  387. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_orcid_scheme/validate_orcid_scheme.yml +7 -7
  388. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_orcid_scheme/validate_orcid_scheme_https.yml +6 -6
  389. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_orcid_scheme/validate_orcid_scheme_trailing_slash.yml +7 -7
  390. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_orcid_scheme/validate_orcid_scheme_www.yml +6 -6
  391. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_prefix/doi.yml +6 -6
  392. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_prefix/doi_as_url.yml +6 -6
  393. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_prefix/doi_with_protocol.yml +7 -7
  394. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_prefix/only_prefix.yml +7 -7
  395. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_url/DOI.yml +6 -6
  396. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_url/ISSN.yml +6 -6
  397. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_url/URL.yml +6 -6
  398. data/spec/fixtures/vcr_cassettes/Briard_Metadata/validate_url/string.yml +7 -7
  399. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_bibtex/BlogPosting.yml +9 -9
  400. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_bibtex/Dataset.yml +9 -9
  401. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_bibtex/authors_with_affiliations.yml +8 -8
  402. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_bibtex/climate_data.yml +9 -9
  403. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_bibtex/from_schema_org.yml +19 -19
  404. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_bibtex/keywords_subject_scheme.yml +9 -9
  405. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_bibtex/maremma.yml +9 -9
  406. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_bibtex/text.yml +9 -9
  407. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_bibtex/with_data_citation.yml +6 -6
  408. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_bibtex/with_pages.yml +6 -6
  409. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_cff/Collection_of_Jupyter_notebooks.yml +9 -9
  410. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_cff/SoftwareSourceCode_Zenodo.yml +9 -9
  411. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_cff/SoftwareSourceCode_also_Zenodo.yml +9 -9
  412. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_cff/ruby-cff.yml +12 -12
  413. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citation/Dataset.yml +9 -9
  414. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citation/Journal_article.yml +6 -6
  415. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citation/Journal_article_vancouver_style.yml +6 -6
  416. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citation/Missing_author.yml +6 -6
  417. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citation/interactive_resource_without_dates.yml +9 -9
  418. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citation/software_w/version.yml +9 -9
  419. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/Another_dataset.yml +9 -9
  420. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/BlogPosting.yml +9 -9
  421. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/BlogPosting_schema_org.yml +19 -19
  422. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/Dataset.yml +9 -9
  423. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/container_title.yml +9 -9
  424. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/interactive_resource_without_dates.yml +9 -9
  425. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/journal_article.yml +6 -6
  426. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/keywords_subject_scheme.yml +9 -9
  427. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/maremma.yml +9 -9
  428. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/missing_creator.yml +6 -6
  429. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/multiple_abstracts.yml +9 -9
  430. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/organization_author.yml +6 -6
  431. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/software.yml +9 -9
  432. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/software_w/version.yml +9 -9
  433. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/with_only_first_page.yml +6 -6
  434. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citeproc/with_pages.yml +6 -6
  435. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_codemeta/SoftwareSourceCode_DataCite.yml +9 -9
  436. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_codemeta/SoftwareSourceCode_DataCite_check_codemeta_v2.yml +9 -9
  437. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_crosscite/datacite_database_attributes.yml +9 -9
  438. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_crosscite/maremma.yml +11 -11
  439. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_crosscite/with_ORCID_ID.yml +6 -6
  440. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_crosscite/with_data_citation.yml +6 -6
  441. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_crossref/another_schema_org_from_front-matter.yml +21 -21
  442. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_crossref/journal_article_from_datacite.yml +9 -9
  443. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_crossref/posted_content.yml +11 -13
  444. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_crossref/schema_org_from_another_science_blog.yml +10 -14
  445. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_crossref/schema_org_from_front_matter.yml +20 -20
  446. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_csv/climate_data.yml +9 -9
  447. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_csv/maremma.yml +9 -9
  448. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_csv/text.yml +9 -9
  449. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_csv/with_data_citation.yml +6 -6
  450. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_csv/with_pages.yml +6 -6
  451. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_json/from_schema_org.yml +19 -19
  452. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_json/maremma.yml +11 -11
  453. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_json/with_ORCID_ID.yml +8 -8
  454. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_json/with_data_citation.yml +6 -6
  455. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_xml/DOI_not_found.yml +8 -8
  456. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_xml/Dataset_in_schema_4_0.yml +9 -9
  457. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_xml/Text_pass-thru.yml +9 -9
  458. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_xml/Text_pass-thru_with_doi_in_options.yml +9 -9
  459. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_xml/maremma.yml +9 -9
  460. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_xml/with_ORCID_ID.yml +6 -6
  461. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_xml/with_data_citation.yml +6 -6
  462. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_xml/with_editor.yml +8 -8
  463. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_xml/with_version.yml +9 -9
  464. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_jats_xml/Dataset_in_schema_4_0.yml +9 -9
  465. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_jats_xml/Text_pass-thru.yml +9 -9
  466. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_jats_xml/book_chapter.yml +8 -8
  467. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_jats_xml/from_schema_org.yml +19 -19
  468. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_jats_xml/interactive_resource_without_dates.yml +9 -9
  469. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_jats_xml/maremma.yml +9 -9
  470. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_jats_xml/with_ORCID_ID.yml +6 -6
  471. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_jats_xml/with_data_citation.yml +6 -6
  472. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_jats_xml/with_editor.yml +8 -8
  473. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_rdf_xml/BlogPosting.yml +9 -9
  474. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_rdf_xml/BlogPosting_schema_org.yml +19 -19
  475. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_rdf_xml/journal_article.yml +6 -6
  476. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_rdf_xml/maremma.yml +9 -9
  477. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_rdf_xml/with_pages.yml +6 -6
  478. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_ris/BlogPosting.yml +9 -9
  479. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_ris/BlogPosting_schema_org.yml +19 -19
  480. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_ris/Dataset.yml +9 -9
  481. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_ris/alternate_name.yml +9 -9
  482. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_ris/journal_article.yml +6 -6
  483. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_ris/keywords_with_subject_scheme.yml +9 -9
  484. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_ris/maremma.yml +11 -11
  485. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_ris/with_pages.yml +8 -8
  486. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/Another_Schema_org_JSON.yml +9 -9
  487. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/Funding.yml +14 -16
  488. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/Funding_OpenAIRE.yml +14 -16
  489. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/Schema_org_JSON.yml +9 -9
  490. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/Schema_org_JSON_Cyark.yml +14 -16
  491. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/Schema_org_JSON_IsSupplementTo.yml +14 -16
  492. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/alternate_identifiers.yml +9 -9
  493. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/data_catalog.yml +9 -9
  494. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/geo_location_box.yml +9 -9
  495. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/interactive_resource_without_dates.yml +9 -9
  496. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/journal_article.yml +6 -6
  497. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/maremma_schema_org_JSON.yml +9 -9
  498. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/series_information.yml +9 -9
  499. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/subject_scheme.yml +9 -9
  500. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/subject_scheme_multiple_keywords.yml +9 -9
  501. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_turtle/BlogPosting.yml +9 -9
  502. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_turtle/BlogPosting_schema_org.yml +19 -19
  503. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_turtle/Dataset.yml +9 -9
  504. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_turtle/journal_article.yml +6 -6
  505. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_turtle/with_pages.yml +8 -8
  506. data/spec/readers/cff_reader_spec.rb +9 -9
  507. data/spec/readers/citeproc_reader_spec.rb +2 -2
  508. data/spec/readers/codemeta_reader_spec.rb +3 -4
  509. data/spec/readers/crossref_json_reader_spec.rb +1237 -0
  510. data/spec/readers/crossref_reader_spec.rb +59 -66
  511. data/spec/readers/datacite_json_reader_spec.rb +1 -1
  512. data/spec/readers/datacite_reader_spec.rb +53 -82
  513. data/spec/readers/npm_reader_spec.rb +2 -2
  514. data/spec/readers/ris_reader_spec.rb +2 -5
  515. data/spec/readers/schema_org_reader_spec.rb +8 -13
  516. data/spec/writers/bibtex_writer_spec.rb +2 -2
  517. data/spec/writers/cff_writer_spec.rb +1 -1
  518. data/spec/writers/citation_writer_spec.rb +2 -2
  519. data/spec/writers/citeproc_writer_spec.rb +1 -1
  520. data/spec/writers/codemeta_writer_spec.rb +1 -1
  521. data/spec/writers/crosscite_writer_spec.rb +4 -5
  522. data/spec/writers/crossref_writer_spec.rb +16 -18
  523. data/spec/writers/datacite_json_writer_spec.rb +2 -4
  524. data/spec/writers/datacite_writer_spec.rb +7 -9
  525. data/spec/writers/schema_org_writer_spec.rb +8 -9
  526. metadata +65 -37
  527. data/spec/fixtures/vcr_cassettes/Briard_Metadata/doi_api_url/force_test_resolver.yml +0 -65
  528. data/spec/fixtures/vcr_cassettes/Briard_Metadata/sanitize/should_remove_a_tags.yml +0 -65
  529. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_crosscite/with_data_citation_schema_org.yml +0 -106
  530. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_crossref/schema_org_from_zenodo.yml +0 -62
  531. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_json/with_data_citation_schema_org.yml +0 -108
  532. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_datacite_xml/with_data_citation_schema_org.yml +0 -106
  533. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_jats_xml/with_data_citation_schema_org.yml +0 -106
  534. data/spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_schema_org/Schema_org_JSON_isReferencedBy.yml +0 -73
data/lib/briard/utils.rb CHANGED
@@ -3,486 +3,488 @@
3
3
  module Briard
4
4
  module Utils
5
5
  NORMALIZED_LICENSES = {
6
- "https://creativecommons.org/licenses/by/1.0" => "https://creativecommons.org/licenses/by/1.0/legalcode",
7
- "https://creativecommons.org/licenses/by/2.0" => "https://creativecommons.org/licenses/by/2.0/legalcode",
8
- "https://creativecommons.org/licenses/by/2.5" => "https://creativecommons.org/licenses/by/2.5/legalcode",
9
- "https://creativecommons.org/licenses/by/3.0" => "https://creativecommons.org/licenses/by/3.0/legalcode",
10
- "https://creativecommons.org/licenses/by/3.0/us" => "https://creativecommons.org/licenses/by/3.0/legalcode",
11
- "https://creativecommons.org/licenses/by/4.0" => "https://creativecommons.org/licenses/by/4.0/legalcode",
12
- "https://creativecommons.org/licenses/by-nc/1.0" => "https://creativecommons.org/licenses/by-nc/1.0/legalcode",
13
- "https://creativecommons.org/licenses/by-nc/2.0" => "https://creativecommons.org/licenses/by-nc/2.0/legalcode",
14
- "https://creativecommons.org/licenses/by-nc/2.5" => "https://creativecommons.org/licenses/by-nc/2.5/legalcode",
15
- "https://creativecommons.org/licenses/by-nc/3.0" => "https://creativecommons.org/licenses/by-nc/3.0/legalcode",
16
- "https://creativecommons.org/licenses/by-nc/4.0" => "https://creativecommons.org/licenses/by-nc/4.0/legalcode",
17
- "https://creativecommons.org/licenses/by-nd-nc/1.0" => "https://creativecommons.org/licenses/by-nd-nc/1.0/legalcode",
18
- "https://creativecommons.org/licenses/by-nd-nc/2.0" => "https://creativecommons.org/licenses/by-nd-nc/2.0/legalcode",
19
- "https://creativecommons.org/licenses/by-nd-nc/2.5" => "https://creativecommons.org/licenses/by-nd-nc/2.5/legalcode",
20
- "https://creativecommons.org/licenses/by-nd-nc/3.0" => "https://creativecommons.org/licenses/by-nd-nc/3.0/legalcode",
21
- "https://creativecommons.org/licenses/by-nd-nc/4.0" => "https://creativecommons.org/licenses/by-nd-nc/4.0/legalcode",
22
- "https://creativecommons.org/licenses/by-nc-sa/1.0" => "https://creativecommons.org/licenses/by-nc-sa/1.0/legalcode",
23
- "https://creativecommons.org/licenses/by-nc-sa/2.0" => "https://creativecommons.org/licenses/by-nc-sa/2.0/legalcode",
24
- "https://creativecommons.org/licenses/by-nc-sa/2.5" => "https://creativecommons.org/licenses/by-nc-sa/2.5/legalcode",
25
- "https://creativecommons.org/licenses/by-nc-sa/3.0" => "https://creativecommons.org/licenses/by-nc-sa/3.0/legalcode",
26
- "https://creativecommons.org/licenses/by-nc-sa/4.0" => "https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode",
27
- "https://creativecommons.org/licenses/by-nd/1.0" => "https://creativecommons.org/licenses/by-nd/1.0/legalcode",
28
- "https://creativecommons.org/licenses/by-nd/2.0" => "https://creativecommons.org/licenses/by-nd/2.0/legalcode",
29
- "https://creativecommons.org/licenses/by-nd/2.5" => "https://creativecommons.org/licenses/by-nd/2.5/legalcode",
30
- "https://creativecommons.org/licenses/by-nd/3.0" => "https://creativecommons.org/licenses/by-nd/3.0/legalcode",
31
- "https://creativecommons.org/licenses/by-nd/4.0" => "https://creativecommons.org/licenses/by-nd/2.0/legalcode",
32
- "https://creativecommons.org/licenses/by-sa/1.0" => "https://creativecommons.org/licenses/by-sa/1.0/legalcode",
33
- "https://creativecommons.org/licenses/by-sa/2.0" => "https://creativecommons.org/licenses/by-sa/2.0/legalcode",
34
- "https://creativecommons.org/licenses/by-sa/2.5" => "https://creativecommons.org/licenses/by-sa/2.5/legalcode",
35
- "https://creativecommons.org/licenses/by-sa/3.0" => "https://creativecommons.org/licenses/by-sa/3.0/legalcode",
36
- "https://creativecommons.org/licenses/by-sa/4.0" => "https://creativecommons.org/licenses/by-sa/4.0/legalcode",
37
- "https://creativecommons.org/licenses/by-nc-nd/1.0" => "https://creativecommons.org/licenses/by-nc-nd/1.0/legalcode",
38
- "https://creativecommons.org/licenses/by-nc-nd/2.0" => "https://creativecommons.org/licenses/by-nc-nd/2.0/legalcode",
39
- "https://creativecommons.org/licenses/by-nc-nd/2.5" => "https://creativecommons.org/licenses/by-nc-nd/2.5/legalcode",
40
- "https://creativecommons.org/licenses/by-nc-nd/3.0" => "https://creativecommons.org/licenses/by-nc-nd/3.0/legalcode",
41
- "https://creativecommons.org/licenses/by-nc-nd/4.0" => "https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode",
42
- "https://creativecommons.org/licenses/publicdomain" => "https://creativecommons.org/licenses/publicdomain/",
43
- "https://creativecommons.org/publicdomain/zero/1.0" => "https://creativecommons.org/publicdomain/zero/1.0/legalcode",
6
+ 'https://creativecommons.org/licenses/by/1.0' => 'https://creativecommons.org/licenses/by/1.0/legalcode',
7
+ 'https://creativecommons.org/licenses/by/2.0' => 'https://creativecommons.org/licenses/by/2.0/legalcode',
8
+ 'https://creativecommons.org/licenses/by/2.5' => 'https://creativecommons.org/licenses/by/2.5/legalcode',
9
+ 'https://creativecommons.org/licenses/by/3.0' => 'https://creativecommons.org/licenses/by/3.0/legalcode',
10
+ 'https://creativecommons.org/licenses/by/3.0/us' => 'https://creativecommons.org/licenses/by/3.0/legalcode',
11
+ 'https://creativecommons.org/licenses/by/4.0' => 'https://creativecommons.org/licenses/by/4.0/legalcode',
12
+ 'https://creativecommons.org/licenses/by-nc/1.0' => 'https://creativecommons.org/licenses/by-nc/1.0/legalcode',
13
+ 'https://creativecommons.org/licenses/by-nc/2.0' => 'https://creativecommons.org/licenses/by-nc/2.0/legalcode',
14
+ 'https://creativecommons.org/licenses/by-nc/2.5' => 'https://creativecommons.org/licenses/by-nc/2.5/legalcode',
15
+ 'https://creativecommons.org/licenses/by-nc/3.0' => 'https://creativecommons.org/licenses/by-nc/3.0/legalcode',
16
+ 'https://creativecommons.org/licenses/by-nc/4.0' => 'https://creativecommons.org/licenses/by-nc/4.0/legalcode',
17
+ 'https://creativecommons.org/licenses/by-nd-nc/1.0' => 'https://creativecommons.org/licenses/by-nd-nc/1.0/legalcode',
18
+ 'https://creativecommons.org/licenses/by-nd-nc/2.0' => 'https://creativecommons.org/licenses/by-nd-nc/2.0/legalcode',
19
+ 'https://creativecommons.org/licenses/by-nd-nc/2.5' => 'https://creativecommons.org/licenses/by-nd-nc/2.5/legalcode',
20
+ 'https://creativecommons.org/licenses/by-nd-nc/3.0' => 'https://creativecommons.org/licenses/by-nd-nc/3.0/legalcode',
21
+ 'https://creativecommons.org/licenses/by-nd-nc/4.0' => 'https://creativecommons.org/licenses/by-nd-nc/4.0/legalcode',
22
+ 'https://creativecommons.org/licenses/by-nc-sa/1.0' => 'https://creativecommons.org/licenses/by-nc-sa/1.0/legalcode',
23
+ 'https://creativecommons.org/licenses/by-nc-sa/2.0' => 'https://creativecommons.org/licenses/by-nc-sa/2.0/legalcode',
24
+ 'https://creativecommons.org/licenses/by-nc-sa/2.5' => 'https://creativecommons.org/licenses/by-nc-sa/2.5/legalcode',
25
+ 'https://creativecommons.org/licenses/by-nc-sa/3.0' => 'https://creativecommons.org/licenses/by-nc-sa/3.0/legalcode',
26
+ 'https://creativecommons.org/licenses/by-nc-sa/4.0' => 'https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode',
27
+ 'https://creativecommons.org/licenses/by-nd/1.0' => 'https://creativecommons.org/licenses/by-nd/1.0/legalcode',
28
+ 'https://creativecommons.org/licenses/by-nd/2.0' => 'https://creativecommons.org/licenses/by-nd/2.0/legalcode',
29
+ 'https://creativecommons.org/licenses/by-nd/2.5' => 'https://creativecommons.org/licenses/by-nd/2.5/legalcode',
30
+ 'https://creativecommons.org/licenses/by-nd/3.0' => 'https://creativecommons.org/licenses/by-nd/3.0/legalcode',
31
+ 'https://creativecommons.org/licenses/by-nd/4.0' => 'https://creativecommons.org/licenses/by-nd/2.0/legalcode',
32
+ 'https://creativecommons.org/licenses/by-sa/1.0' => 'https://creativecommons.org/licenses/by-sa/1.0/legalcode',
33
+ 'https://creativecommons.org/licenses/by-sa/2.0' => 'https://creativecommons.org/licenses/by-sa/2.0/legalcode',
34
+ 'https://creativecommons.org/licenses/by-sa/2.5' => 'https://creativecommons.org/licenses/by-sa/2.5/legalcode',
35
+ 'https://creativecommons.org/licenses/by-sa/3.0' => 'https://creativecommons.org/licenses/by-sa/3.0/legalcode',
36
+ 'https://creativecommons.org/licenses/by-sa/4.0' => 'https://creativecommons.org/licenses/by-sa/4.0/legalcode',
37
+ 'https://creativecommons.org/licenses/by-nc-nd/1.0' => 'https://creativecommons.org/licenses/by-nc-nd/1.0/legalcode',
38
+ 'https://creativecommons.org/licenses/by-nc-nd/2.0' => 'https://creativecommons.org/licenses/by-nc-nd/2.0/legalcode',
39
+ 'https://creativecommons.org/licenses/by-nc-nd/2.5' => 'https://creativecommons.org/licenses/by-nc-nd/2.5/legalcode',
40
+ 'https://creativecommons.org/licenses/by-nc-nd/3.0' => 'https://creativecommons.org/licenses/by-nc-nd/3.0/legalcode',
41
+ 'https://creativecommons.org/licenses/by-nc-nd/4.0' => 'https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode',
42
+ 'https://creativecommons.org/licenses/publicdomain' => 'https://creativecommons.org/licenses/publicdomain/',
43
+ 'https://creativecommons.org/publicdomain/zero/1.0' => 'https://creativecommons.org/publicdomain/zero/1.0/legalcode'
44
44
  }
45
45
 
46
46
  DC_TO_SO_TRANSLATIONS = {
47
- "Audiovisual" => "MediaObject",
48
- "Book" => "Book",
49
- "BookChapter" => "Chapter",
50
- "Collection" => "Collection",
51
- "ComputationalNotebook" => "SoftwareSourceCode",
52
- "ConferencePaper" => "Article",
53
- "ConferenceProceeding" => "Periodical",
54
- "DataPaper" => "Article",
55
- "Dataset" => "Dataset",
56
- "Dissertation" => "Thesis",
57
- "Event" => "Event",
58
- "Image" => "ImageObject",
59
- "InteractiveResource" => nil,
60
- "Journal" => "Periodical",
61
- "JournalArticle" => "ScholarlyArticle",
62
- "Model" => nil,
63
- "OutputManagementPlan" => nil,
64
- "PeerReview" => "Review",
65
- "PhysicalObject" => nil,
66
- "Preprint" => nil,
67
- "Report" => "Report",
68
- "Service" => "Service",
69
- "Software" => "SoftwareSourceCode",
70
- "Sound" => "AudioObject",
71
- "Standard" => nil,
72
- "Text" => "ScholarlyArticle",
73
- "Workflow" => nil,
74
- "Other" => "CreativeWork",
47
+ 'Audiovisual' => 'MediaObject',
48
+ 'Book' => 'Book',
49
+ 'BookChapter' => 'Chapter',
50
+ 'Collection' => 'Collection',
51
+ 'ComputationalNotebook' => 'SoftwareSourceCode',
52
+ 'ConferencePaper' => 'Article',
53
+ 'ConferenceProceeding' => 'Periodical',
54
+ 'DataPaper' => 'Article',
55
+ 'Dataset' => 'Dataset',
56
+ 'Dissertation' => 'Thesis',
57
+ 'Event' => 'Event',
58
+ 'Image' => 'ImageObject',
59
+ 'InteractiveResource' => nil,
60
+ 'Journal' => 'Periodical',
61
+ 'JournalArticle' => 'ScholarlyArticle',
62
+ 'Model' => nil,
63
+ 'OutputManagementPlan' => nil,
64
+ 'PeerReview' => 'Review',
65
+ 'PhysicalObject' => nil,
66
+ 'Preprint' => nil,
67
+ 'Report' => 'Report',
68
+ 'Service' => 'Service',
69
+ 'Software' => 'SoftwareSourceCode',
70
+ 'Sound' => 'AudioObject',
71
+ 'Standard' => nil,
72
+ 'Text' => 'ScholarlyArticle',
73
+ 'Workflow' => nil,
74
+ 'Other' => 'CreativeWork',
75
75
  # not part of DataCite schema, but used internally
76
- "Periodical" => "Periodical",
77
- "DataCatalog" => "DataCatalog"
76
+ 'Periodical' => 'Periodical',
77
+ 'DataCatalog' => 'DataCatalog'
78
78
  }
79
79
 
80
80
  DC_TO_CP_TRANSLATIONS = {
81
- "Audiovisual" => "motion_picture",
82
- "Book" => "book",
83
- "BookChapter" => "chapter",
84
- "Collection" => nil,
85
- "ComputationalNotebook" => nil,
86
- "ConferencePaper" => "paper_conference",
87
- "ConferenceProceeding" => nil,
88
- "DataPaper" => "report",
89
- "Dataset" => "dataset",
90
- "Dissertation" => nil,
91
- "Event" => nil,
92
- "Image" => "graphic",
93
- "InteractiveResource" => nil,
94
- "Journal" => nil,
95
- "JournalArticle" => "article-journal",
96
- "Model" => nil,
97
- "OutputManagementPlan" => nil,
98
- "PeerReview" => "review",
99
- "PhysicalObject" => nil,
100
- "Preprint" => nil,
101
- "Report" => "report",
102
- "Service" => nil,
103
- "Sound" => "song",
104
- "Standard" => nil,
105
- "Text" => "report",
106
- "Workflow" => nil,
107
- "Other" => nil
81
+ 'Audiovisual' => 'motion_picture',
82
+ 'Book' => 'book',
83
+ 'BookChapter' => 'chapter',
84
+ 'Collection' => nil,
85
+ 'ComputationalNotebook' => nil,
86
+ 'ConferencePaper' => 'paper_conference',
87
+ 'ConferenceProceeding' => nil,
88
+ 'DataPaper' => 'report',
89
+ 'Dataset' => 'dataset',
90
+ 'Dissertation' => nil,
91
+ 'Event' => nil,
92
+ 'Image' => 'graphic',
93
+ 'InteractiveResource' => nil,
94
+ 'Journal' => nil,
95
+ 'JournalArticle' => 'article-journal',
96
+ 'Model' => nil,
97
+ 'OutputManagementPlan' => nil,
98
+ 'PeerReview' => 'review',
99
+ 'PhysicalObject' => nil,
100
+ 'Preprint' => nil,
101
+ 'Report' => 'report',
102
+ 'Service' => nil,
103
+ 'Sound' => 'song',
104
+ 'Standard' => nil,
105
+ 'Text' => 'report',
106
+ 'Workflow' => nil,
107
+ 'Other' => nil
108
108
  }
109
109
 
110
110
  CR_TO_CP_TRANSLATIONS = {
111
- "Proceedings" => nil,
112
- "ReferenceBook" => nil,
113
- "JournalIssue" => nil,
114
- "ProceedingsArticle" => "paper-conference",
115
- "Other" => nil,
116
- "Dissertation" => "thesis",
117
- "Dataset" => "dataset",
118
- "EditedBook" => "book",
119
- "JournalArticle" => "article-journal",
120
- "Journal" => nil,
121
- "Report" => "report",
122
- "BookSeries" => nil,
123
- "ReportSeries" => nil,
124
- "BookTrack" => nil,
125
- "Standard" => nil,
126
- "BookSection" => "chapter",
127
- "BookPart" => nil,
128
- "Book" => "book",
129
- "BookChapter" => "chapter",
130
- "StandardSeries" => nil,
131
- "Monograph" => "book",
132
- "Component" => nil,
133
- "ReferenceEntry" => "entry-dictionary",
134
- "JournalVolume" => nil,
135
- "BookSet" => nil
111
+ 'Proceedings' => nil,
112
+ 'ReferenceBook' => nil,
113
+ 'JournalIssue' => 'article-journal',
114
+ 'ProceedingsArticle' => 'paper-conference',
115
+ 'Other' => nil,
116
+ 'Dissertation' => 'thesis',
117
+ 'Dataset' => 'dataset',
118
+ 'EditedBook' => 'book',
119
+ 'PostedContent' => 'article-journal',
120
+ 'JournalArticle' => 'article-journal',
121
+ 'Journal' => nil,
122
+ 'Report' => 'report',
123
+ 'BookSeries' => nil,
124
+ 'ReportSeries' => nil,
125
+ 'BookTrack' => nil,
126
+ 'Standard' => nil,
127
+ 'BookSection' => 'chapter',
128
+ 'BookPart' => nil,
129
+ 'Book' => 'book',
130
+ 'BookChapter' => 'chapter',
131
+ 'StandardSeries' => nil,
132
+ 'Monograph' => 'book',
133
+ 'Component' => nil,
134
+ 'ReferenceEntry' => 'entry-dictionary',
135
+ 'JournalVolume' => nil,
136
+ 'BookSet' => nil
136
137
  }
137
138
 
138
139
  CR_TO_SO_TRANSLATIONS = {
139
- "Proceedings" => nil,
140
- "ReferenceBook" => "Book",
141
- "JournalIssue" => "PublicationIssue",
142
- "ProceedingsArticle" => nil,
143
- "Other" => "CreativeWork",
144
- "Dissertation" => "Thesis",
145
- "Dataset" => "Dataset",
146
- "EditedBook" => "Book",
147
- "JournalArticle" => "ScholarlyArticle",
148
- "Journal" => nil,
149
- "Report" => "Report",
150
- "BookSeries" => nil,
151
- "ReportSeries" => nil,
152
- "BookTrack" => nil,
153
- "Standard" => nil,
154
- "BookSection" => nil,
155
- "BookPart" => nil,
156
- "Book" => "Book",
157
- "BookChapter" => "Chapter",
158
- "StandardSeries" => nil,
159
- "Monograph" => "Book",
160
- "Component" => "CreativeWork",
161
- "ReferenceEntry" => nil,
162
- "JournalVolume" => "PublicationVolume",
163
- "BookSet" => nil,
164
- "PostedContent" => "ScholarlyArticle",
165
- "PeerReview" => "Review"
140
+ 'Proceedings' => nil,
141
+ 'ReferenceBook' => 'Book',
142
+ 'JournalIssue' => 'PublicationIssue',
143
+ 'ProceedingsArticle' => nil,
144
+ 'Other' => 'CreativeWork',
145
+ 'Dissertation' => 'Thesis',
146
+ 'Dataset' => 'Dataset',
147
+ 'EditedBook' => 'Book',
148
+ 'JournalArticle' => 'ScholarlyArticle',
149
+ 'Journal' => nil,
150
+ 'Report' => 'Report',
151
+ 'BookSeries' => nil,
152
+ 'ReportSeries' => nil,
153
+ 'BookTrack' => nil,
154
+ 'Standard' => nil,
155
+ 'BookSection' => nil,
156
+ 'BookPart' => nil,
157
+ 'Book' => 'Book',
158
+ 'BookChapter' => 'Chapter',
159
+ 'StandardSeries' => nil,
160
+ 'Monograph' => 'Book',
161
+ 'Component' => 'CreativeWork',
162
+ 'ReferenceEntry' => nil,
163
+ 'JournalVolume' => 'PublicationVolume',
164
+ 'BookSet' => nil,
165
+ 'PostedContent' => 'ScholarlyArticle',
166
+ 'PeerReview' => 'Review'
166
167
  }
167
168
 
168
169
  CR_TO_BIB_TRANSLATIONS = {
169
- "Proceedings" => "proceedings",
170
- "ReferenceBook" => "book",
171
- "JournalIssue" => nil,
172
- "ProceedingsArticle" => nil,
173
- "Other" => nil,
174
- "Dissertation" => "phdthesis",
175
- "Dataset" => nil,
176
- "EditedBook" => "book",
177
- "JournalArticle" => "article",
178
- "Journal" => nil,
179
- "Report" => "techreport",
180
- "BookSeries" => nil,
181
- "ReportSeries" => nil,
182
- "BookTrack" => nil,
183
- "Standard" => nil,
184
- "BookSection" => "inbook",
185
- "BookPart" => nil,
186
- "Book" => "book",
187
- "BookChapter" => "inbook",
188
- "StandardSeries" => nil,
189
- "Monograph" => "book",
190
- "Component" => nil,
191
- "ReferenceEntry" => nil,
192
- "JournalVolume" => nil,
193
- "BookSet" => nil,
194
- "PostedContent" => "article"
170
+ 'Proceedings' => 'proceedings',
171
+ 'ReferenceBook' => 'book',
172
+ 'JournalIssue' => nil,
173
+ 'ProceedingsArticle' => nil,
174
+ 'Other' => nil,
175
+ 'Dissertation' => 'phdthesis',
176
+ 'Dataset' => nil,
177
+ 'EditedBook' => 'book',
178
+ 'JournalArticle' => 'article',
179
+ 'Journal' => nil,
180
+ 'Report' => 'techreport',
181
+ 'BookSeries' => nil,
182
+ 'ReportSeries' => nil,
183
+ 'BookTrack' => nil,
184
+ 'Standard' => nil,
185
+ 'BookSection' => 'inbook',
186
+ 'BookPart' => nil,
187
+ 'Book' => 'book',
188
+ 'BookChapter' => 'inbook',
189
+ 'StandardSeries' => nil,
190
+ 'Monograph' => 'book',
191
+ 'Component' => nil,
192
+ 'ReferenceEntry' => nil,
193
+ 'JournalVolume' => nil,
194
+ 'BookSet' => nil,
195
+ 'PostedContent' => 'article'
195
196
  }
196
197
 
197
198
  BIB_TO_CR_TRANSLATIONS = {
198
- "proceedings" => "Proceedings",
199
- "phdthesis" => "Dissertation",
200
- "article" => "JournalArticle",
201
- "book" => "Book",
202
- "inbook" => "BookChapter"
199
+ 'proceedings' => 'Proceedings',
200
+ 'phdthesis' => 'Dissertation',
201
+ 'article' => 'JournalArticle',
202
+ 'book' => 'Book',
203
+ 'inbook' => 'BookChapter'
203
204
  }
204
205
 
205
206
  CR_TO_JATS_TRANSLATIONS = {
206
- "Proceedings" => "working-paper",
207
- "ReferenceBook" => "book",
208
- "JournalIssue" => "journal",
209
- "ProceedingsArticle" => "working-paper",
210
- "Other" => nil,
211
- "Dissertation" => nil,
212
- "Dataset" => "data",
213
- "EditedBook" => "book",
214
- "JournalArticle" => "journal",
215
- "Journal" => "journal",
216
- "Report" => "report",
217
- "BookSeries" => "book",
218
- "ReportSeries" => "report",
219
- "BookTrack" => "book",
220
- "Standard" => "standard",
221
- "BookSection" => "chapter",
222
- "BookPart" => "chapter",
223
- "Book" => "book",
224
- "BookChapter" => "chapter",
225
- "StandardSeries" => "standard",
226
- "Monograph" => "book",
227
- "Component" => nil,
228
- "ReferenceEntry" => nil,
229
- "JournalVolume" => "journal",
230
- "BookSet" => "book"
207
+ 'Proceedings' => 'working-paper',
208
+ 'ReferenceBook' => 'book',
209
+ 'JournalIssue' => 'journal',
210
+ 'ProceedingsArticle' => 'working-paper',
211
+ 'Other' => nil,
212
+ 'Dissertation' => nil,
213
+ 'Dataset' => 'data',
214
+ 'EditedBook' => 'book',
215
+ 'JournalArticle' => 'journal',
216
+ 'Journal' => 'journal',
217
+ 'Report' => 'report',
218
+ 'BookSeries' => 'book',
219
+ 'ReportSeries' => 'report',
220
+ 'BookTrack' => 'book',
221
+ 'Standard' => 'standard',
222
+ 'BookSection' => 'chapter',
223
+ 'BookPart' => 'chapter',
224
+ 'Book' => 'book',
225
+ 'BookChapter' => 'chapter',
226
+ 'StandardSeries' => 'standard',
227
+ 'Monograph' => 'book',
228
+ 'Component' => nil,
229
+ 'ReferenceEntry' => nil,
230
+ 'JournalVolume' => 'journal',
231
+ 'BookSet' => 'book'
231
232
  }
232
233
 
233
234
  CR_TO_DC_TRANSLATIONS = {
234
- "Proceedings" => nil,
235
- "ReferenceBook" => nil,
236
- "JournalIssue" => "Text",
237
- "ProceedingsArticle" => "ConferencePaper",
238
- "Other" => "Other",
239
- "Dissertation" => "Dissertation",
240
- "Dataset" => "Dataset",
241
- "EditedBook" => "Book",
242
- "JournalArticle" => "JournalArticle",
243
- "Journal" => "Journal",
244
- "Report" => "Report",
245
- "BookSeries" => nil,
246
- "ReportSeries" => nil,
247
- "BookTrack" => nil,
248
- "Standard" => "Standard",
249
- "BookSection" => "BookChapter",
250
- "BookPart" => nil,
251
- "Book" => "Book",
252
- "BookChapter" => "BookChapter",
253
- "SaComponent" => "Text",
254
- "StandardSeries" => "Standard",
255
- "Monograph" => "book",
256
- "Component" => nil,
257
- "ReferenceEntry" => nil,
258
- "JournalVolume" => nil,
259
- "BookSet" => nil,
260
- "PostedContent" => "Preprint",
261
- "PeerReview" => "PeerReview"
235
+ 'Proceedings' => nil,
236
+ 'ReferenceBook' => nil,
237
+ 'JournalIssue' => 'Text',
238
+ 'ProceedingsArticle' => 'ConferencePaper',
239
+ 'Other' => 'Other',
240
+ 'Dissertation' => 'Dissertation',
241
+ 'Dataset' => 'Dataset',
242
+ 'EditedBook' => 'Book',
243
+ 'JournalArticle' => 'JournalArticle',
244
+ 'Journal' => 'Journal',
245
+ 'Report' => 'Report',
246
+ 'BookSeries' => nil,
247
+ 'ReportSeries' => nil,
248
+ 'BookTrack' => nil,
249
+ 'Standard' => 'Standard',
250
+ 'BookSection' => 'BookChapter',
251
+ 'BookPart' => nil,
252
+ 'Book' => 'Book',
253
+ 'BookChapter' => 'BookChapter',
254
+ 'SaComponent' => 'Text',
255
+ 'StandardSeries' => 'Standard',
256
+ 'Monograph' => 'Book',
257
+ 'Component' => nil,
258
+ 'ReferenceEntry' => nil,
259
+ 'JournalVolume' => nil,
260
+ 'BookSet' => nil,
261
+ 'PostedContent' => 'Preprint',
262
+ 'PeerReview' => 'PeerReview'
262
263
  }
263
264
 
264
265
  SO_TO_DC_TRANSLATIONS = {
265
- "Article" => "Preprint",
266
- "AudioObject" => "Sound",
267
- "Blog" => "Text",
268
- "BlogPosting" => "Preprint",
269
- "Book" => "Book",
270
- "Chapter" => "BookChapter",
271
- "Collection" => "Collection",
272
- "CreativeWork" => "Text",
273
- "DataCatalog" => "Dataset",
274
- "Dataset" => "Dataset",
275
- "Event" => "Event",
276
- "ImageObject" => "Image",
277
- "Movie" => "Audiovisual",
278
- "PublicationIssue" => "Text",
279
- "Report" => "Report",
280
- "ScholarlyArticle" => "Text",
281
- "Thesis" => "Text",
282
- "Service" => "Service",
283
- "Review" => "PeerReview",
284
- "SoftwareSourceCode" => "Software",
285
- "VideoObject" => "Audiovisual",
286
- "WebPage" => "Text",
287
- "WebSite" => "Text"
266
+ 'Article' => 'Preprint',
267
+ 'AudioObject' => 'Sound',
268
+ 'Blog' => 'Text',
269
+ 'BlogPosting' => 'Preprint',
270
+ 'Book' => 'Book',
271
+ 'Chapter' => 'BookChapter',
272
+ 'Collection' => 'Collection',
273
+ 'CreativeWork' => 'Text',
274
+ 'DataCatalog' => 'Dataset',
275
+ 'Dataset' => 'Dataset',
276
+ 'Event' => 'Event',
277
+ 'ImageObject' => 'Image',
278
+ 'Movie' => 'Audiovisual',
279
+ 'PublicationIssue' => 'Text',
280
+ 'Report' => 'Report',
281
+ 'ScholarlyArticle' => 'Text',
282
+ 'Thesis' => 'Text',
283
+ 'Service' => 'Service',
284
+ 'Review' => 'PeerReview',
285
+ 'SoftwareSourceCode' => 'Software',
286
+ 'VideoObject' => 'Audiovisual',
287
+ 'WebPage' => 'Text',
288
+ 'WebSite' => 'Text'
288
289
  }
289
290
 
290
291
  SO_TO_JATS_TRANSLATIONS = {
291
- "Article" => "journal",
292
- "AudioObject" => nil,
293
- "Blog" => nil,
294
- "BlogPosting" => nil,
295
- "Book" => "book",
296
- "Collection" => nil,
297
- "CreativeWork" => nil,
298
- "DataCatalog" => "data",
299
- "Dataset" => "data",
300
- "Event" => nil,
301
- "ImageObject" => nil,
302
- "Movie" => nil,
303
- "PublicationIssue" => "journal",
304
- "ScholarlyArticle" => "journal",
305
- "Service" => nil,
306
- "SoftwareSourceCode" => "software",
307
- "VideoObject" => nil,
308
- "WebPage" => nil,
309
- "WebSite" => "website"
292
+ 'Article' => 'journal',
293
+ 'AudioObject' => nil,
294
+ 'Blog' => nil,
295
+ 'BlogPosting' => nil,
296
+ 'Book' => 'book',
297
+ 'Collection' => nil,
298
+ 'CreativeWork' => nil,
299
+ 'DataCatalog' => 'data',
300
+ 'Dataset' => 'data',
301
+ 'Event' => nil,
302
+ 'ImageObject' => nil,
303
+ 'Movie' => nil,
304
+ 'PublicationIssue' => 'journal',
305
+ 'ScholarlyArticle' => 'journal',
306
+ 'Service' => nil,
307
+ 'SoftwareSourceCode' => 'software',
308
+ 'VideoObject' => nil,
309
+ 'WebPage' => nil,
310
+ 'WebSite' => 'website'
310
311
  }
311
312
 
312
313
  SO_TO_CP_TRANSLATIONS = {
313
- "Article" => "article-newspaper",
314
- "AudioObject" => "song",
315
- "Blog" => "report",
316
- "BlogPosting" => "post-weblog",
317
- "Collection" => nil,
318
- "CreativeWork" => nil,
319
- "DataCatalog" => "dataset",
320
- "Dataset" => "dataset",
321
- "Event" => nil,
322
- "ImageObject" => "graphic",
323
- "Movie" => "motion_picture",
324
- "PublicationIssue" => nil,
325
- "Report" => "report",
326
- "ScholarlyArticle" => "article-journal",
327
- "Service" => nil,
328
- "Thesis" => "thesis",
329
- "VideoObject" => "broadcast",
330
- "WebPage" => "webpage",
331
- "WebSite" => "webpage"
314
+ 'Article' => 'article-newspaper',
315
+ 'AudioObject' => 'song',
316
+ 'Blog' => 'report',
317
+ 'BlogPosting' => 'post-weblog',
318
+ 'Collection' => nil,
319
+ 'CreativeWork' => nil,
320
+ 'DataCatalog' => 'dataset',
321
+ 'Dataset' => 'dataset',
322
+ 'Event' => nil,
323
+ 'ImageObject' => 'graphic',
324
+ 'Movie' => 'motion_picture',
325
+ 'PublicationIssue' => nil,
326
+ 'Report' => 'report',
327
+ 'ScholarlyArticle' => 'article-journal',
328
+ 'Service' => nil,
329
+ 'Thesis' => 'thesis',
330
+ 'VideoObject' => 'broadcast',
331
+ 'WebPage' => 'webpage',
332
+ 'WebSite' => 'webpage'
332
333
  }
333
334
 
334
335
  SO_TO_RIS_TRANSLATIONS = {
335
- "Article" => "GEN",
336
- "AudioObject" => nil,
337
- "Blog" => nil,
338
- "BlogPosting" => "BLOG",
339
- "Collection" => nil,
340
- "CreativeWork" => "GEN",
341
- "DataCatalog" => "CTLG",
342
- "Dataset" => "DATA",
343
- "Event" => nil,
344
- "ImageObject" => "FIGURE",
345
- "Movie" => "MPCT",
346
- "Report" => "RPRT",
347
- "PublicationIssue" => nil,
348
- "ScholarlyArticle" => "JOUR",
349
- "Service" => nil,
350
- "SoftwareSourceCode" => "COMP",
351
- "VideoObject" => "VIDEO",
352
- "WebPage" => "ELEC",
353
- "WebSite" => nil
336
+ 'Article' => 'GEN',
337
+ 'AudioObject' => nil,
338
+ 'Blog' => nil,
339
+ 'BlogPosting' => 'BLOG',
340
+ 'Collection' => nil,
341
+ 'CreativeWork' => 'GEN',
342
+ 'DataCatalog' => 'CTLG',
343
+ 'Dataset' => 'DATA',
344
+ 'Event' => nil,
345
+ 'ImageObject' => 'FIGURE',
346
+ 'Movie' => 'MPCT',
347
+ 'Report' => 'RPRT',
348
+ 'PublicationIssue' => nil,
349
+ 'ScholarlyArticle' => 'JOUR',
350
+ 'Service' => nil,
351
+ 'SoftwareSourceCode' => 'COMP',
352
+ 'VideoObject' => 'VIDEO',
353
+ 'WebPage' => 'ELEC',
354
+ 'WebSite' => nil
354
355
  }
355
356
 
356
357
  CR_TO_RIS_TRANSLATIONS = {
357
- "Proceedings" => "CONF",
358
- "ReferenceBook" => "BOOK",
359
- "JournalIssue" => nil,
360
- "ProceedingsArticle" => "CPAPER",
361
- "Other" => "GEN",
362
- "Dissertation" => "THES",
363
- "Dataset" => "DATA",
364
- "EditedBook" => "BOOK",
365
- "JournalArticle" => "JOUR",
366
- "Journal" => nil,
367
- "Report" => "RPRT",
368
- "BookSeries" => nil,
369
- "ReportSeries" => nil,
370
- "BookTrack" => nil,
371
- "Standard" => "STAND",
372
- "BookSection" => "CHAP",
373
- "BookPart" => "CHAP",
374
- "Book" => "BOOK",
375
- "BookChapter" => "CHAP",
376
- "StandardSeries" => nil,
377
- "Monograph" => "BOOK",
378
- "Component" => nil,
379
- "ReferenceEntry" => "DICT",
380
- "JournalVolume" => nil,
381
- "BookSet" => nil
358
+ 'Proceedings' => 'CONF',
359
+ 'PostedContent' => 'JOUR',
360
+ 'ReferenceBook' => 'BOOK',
361
+ 'JournalIssue' => 'JOUR',
362
+ 'ProceedingsArticle' => 'CPAPER',
363
+ 'Other' => 'GEN',
364
+ 'Dissertation' => 'THES',
365
+ 'Dataset' => 'DATA',
366
+ 'EditedBook' => 'BOOK',
367
+ 'JournalArticle' => 'JOUR',
368
+ 'Journal' => nil,
369
+ 'Report' => 'RPRT',
370
+ 'BookSeries' => nil,
371
+ 'ReportSeries' => nil,
372
+ 'BookTrack' => nil,
373
+ 'Standard' => 'STAND',
374
+ 'BookSection' => 'CHAP',
375
+ 'BookPart' => 'CHAP',
376
+ 'Book' => 'BOOK',
377
+ 'BookChapter' => 'CHAP',
378
+ 'StandardSeries' => nil,
379
+ 'Monograph' => 'BOOK',
380
+ 'Component' => nil,
381
+ 'ReferenceEntry' => 'DICT',
382
+ 'JournalVolume' => nil,
383
+ 'BookSet' => nil
382
384
  }
383
385
 
384
386
  DC_TO_RIS_TRANSLATIONS = {
385
- "Audiovisual" => "MPCT",
386
- "Book" => "BOOK",
387
- "BookChapter" => "CHAP",
388
- "Collection" => nil,
389
- "ComputationalNotebook" => "COMP",
390
- "ConferencePaper" => "CPAPER",
391
- "ConferenceProceeding" => "CONF",
392
- "DataPaper" => nil,
393
- "Dataset" => "DATA",
394
- "Dissertation" => "THES",
395
- "Event" => nil,
396
- "Image" => "FIGURE",
397
- "InteractiveResource" => nil,
398
- "Journal" => nil,
399
- "JournalArticle" => "JOUR",
400
- "Model" => nil,
401
- "OutputManagementPlan" => nil,
402
- "PeerReview" => nil,
403
- "PhysicalObject" => nil,
404
- "Preprint" => "RPRT",
405
- "Report" => "RRPT",
406
- "Service" => nil,
407
- "Software" => "COMP",
408
- "Sound" => "SOUND",
409
- "Standard" => nil,
410
- "Text" => "RPRT",
411
- "Workflow" => nil,
412
- "Other" => nil
387
+ 'Audiovisual' => 'MPCT',
388
+ 'Book' => 'BOOK',
389
+ 'BookChapter' => 'CHAP',
390
+ 'Collection' => nil,
391
+ 'ComputationalNotebook' => 'COMP',
392
+ 'ConferencePaper' => 'CPAPER',
393
+ 'ConferenceProceeding' => 'CONF',
394
+ 'DataPaper' => nil,
395
+ 'Dataset' => 'DATA',
396
+ 'Dissertation' => 'THES',
397
+ 'Event' => nil,
398
+ 'Image' => 'FIGURE',
399
+ 'InteractiveResource' => nil,
400
+ 'Journal' => nil,
401
+ 'JournalArticle' => 'JOUR',
402
+ 'Model' => nil,
403
+ 'OutputManagementPlan' => nil,
404
+ 'PeerReview' => nil,
405
+ 'PhysicalObject' => nil,
406
+ 'Preprint' => 'RPRT',
407
+ 'Report' => 'RRPT',
408
+ 'Service' => nil,
409
+ 'Software' => 'COMP',
410
+ 'Sound' => 'SOUND',
411
+ 'Standard' => nil,
412
+ 'Text' => 'RPRT',
413
+ 'Workflow' => nil,
414
+ 'Other' => nil
413
415
  }
414
416
 
415
417
  RIS_TO_DC_TRANSLATIONS = {
416
- "BLOG" => "Text",
417
- "GEN" => "Text",
418
- "CTLG" => "Collection",
419
- "DATA" => "Dataset",
420
- "FIGURE" => "Image",
421
- "THES" => "Dissertation",
422
- "MPCT" => "Audiovisual",
423
- "JOUR" => "JournalArticle",
424
- "COMP" => "Software",
425
- "VIDEO" => "Audiovisual",
426
- "ELEC" => "Text"
418
+ 'BLOG' => 'Text',
419
+ 'GEN' => 'Text',
420
+ 'CTLG' => 'Collection',
421
+ 'DATA' => 'Dataset',
422
+ 'FIGURE' => 'Image',
423
+ 'THES' => 'Dissertation',
424
+ 'MPCT' => 'Audiovisual',
425
+ 'JOUR' => 'JournalArticle',
426
+ 'COMP' => 'Software',
427
+ 'VIDEO' => 'Audiovisual',
428
+ 'ELEC' => 'Text'
427
429
  }
428
430
 
429
431
  BIB_TO_DC_TRANSLATIONS = {
430
- "article" => "JournalArticle",
431
- "book" => "Book",
432
- "inbook" => "BookChapter",
433
- "inproceedings" => nil,
434
- "manual" => nil,
435
- "misc" => "Other",
436
- "phdthesis" => "Dissertation",
437
- "proceedings" => "ConferenceProceeding",
438
- "techreport" => "Report",
439
- "unpublished" => nil
432
+ 'article' => 'JournalArticle',
433
+ 'book' => 'Book',
434
+ 'inbook' => 'BookChapter',
435
+ 'inproceedings' => nil,
436
+ 'manual' => nil,
437
+ 'misc' => 'Other',
438
+ 'phdthesis' => 'Dissertation',
439
+ 'proceedings' => 'ConferenceProceeding',
440
+ 'techreport' => 'Report',
441
+ 'unpublished' => nil
440
442
  }
441
443
 
442
444
  CP_TO_DC_TRANSLATIONS = {
443
- "song" => "Audiovisual",
444
- "post-weblog" => "Text",
445
- "dataset" => "Dataset",
446
- "graphic" => "Image",
447
- "motion_picture" => "Audiovisual",
448
- "article-journal" => "JournalArticle",
449
- "broadcast" => "Audiovisual",
450
- "webpage" => "Text"
445
+ 'song' => 'Audiovisual',
446
+ 'post-weblog' => 'Text',
447
+ 'dataset' => 'Dataset',
448
+ 'graphic' => 'Image',
449
+ 'motion_picture' => 'Audiovisual',
450
+ 'article-journal' => 'JournalArticle',
451
+ 'broadcast' => 'Audiovisual',
452
+ 'webpage' => 'Text'
451
453
  }
452
454
 
453
455
  SO_TO_BIB_TRANSLATIONS = {
454
- "Article" => "article",
455
- "AudioObject" => "misc",
456
- "Thesis" => "phdthesis",
457
- "Blog" => "misc",
458
- "BlogPosting" => "article",
459
- "Collection" => "misc",
460
- "CreativeWork" => "misc",
461
- "DataCatalog" => "misc",
462
- "Dataset" => "misc",
463
- "Event" => "misc",
464
- "ImageObject" => "misc",
465
- "Movie" => "misc",
466
- "PublicationIssue" => "misc",
467
- "ScholarlyArticle" => "article",
468
- "Service" => "misc",
469
- "SoftwareSourceCode" => "misc",
470
- "VideoObject" => "misc",
471
- "WebPage" => "misc",
472
- "WebSite" => "misc"
456
+ 'Article' => 'article',
457
+ 'AudioObject' => 'misc',
458
+ 'Thesis' => 'phdthesis',
459
+ 'Blog' => 'misc',
460
+ 'BlogPosting' => 'article',
461
+ 'Collection' => 'misc',
462
+ 'CreativeWork' => 'misc',
463
+ 'DataCatalog' => 'misc',
464
+ 'Dataset' => 'misc',
465
+ 'Event' => 'misc',
466
+ 'ImageObject' => 'misc',
467
+ 'Movie' => 'misc',
468
+ 'PublicationIssue' => 'misc',
469
+ 'ScholarlyArticle' => 'article',
470
+ 'Service' => 'misc',
471
+ 'SoftwareSourceCode' => 'misc',
472
+ 'VideoObject' => 'misc',
473
+ 'WebPage' => 'misc',
474
+ 'WebSite' => 'misc'
473
475
  }
474
476
 
475
477
  UNKNOWN_INFORMATION = {
476
- ":unac" => "temporarily inaccessible",
477
- ":unal" => "unallowed, suppressed intentionally",
478
- ":unap" => "not applicable, makes no sense",
479
- ":unas" => "value unassigned (e.g., Untitled)",
480
- ":unav" => "value unavailable, possibly unknown",
481
- ":unkn" => "known to be unknown (e.g., Anonymous, Inconnue)",
482
- ":none" => "never had a value, never will",
483
- ":null" => "explicitly and meaningfully empty",
484
- ":tba" => "to be assigned or announced later",
485
- ":etal" => "too numerous to list (et alia)"
478
+ ':unac' => 'temporarily inaccessible',
479
+ ':unal' => 'unallowed, suppressed intentionally',
480
+ ':unap' => 'not applicable, makes no sense',
481
+ ':unas' => 'value unassigned (e.g., Untitled)',
482
+ ':unav' => 'value unavailable, possibly unknown',
483
+ ':unkn' => 'known to be unknown (e.g., Anonymous, Inconnue)',
484
+ ':none' => 'never had a value, never will',
485
+ ':null' => 'explicitly and meaningfully empty',
486
+ ':tba' => 'to be assigned or announced later',
487
+ ':etal' => 'too numerous to list (et alia)'
486
488
  }
487
489
 
488
490
  def find_from_format(id: nil, string: nil, ext: nil, filename: nil)
@@ -493,93 +495,104 @@ module Briard
493
495
  elsif string.present?
494
496
  find_from_format_by_string(string)
495
497
  else
496
- "datacite"
498
+ 'datacite'
497
499
  end
498
500
  end
499
501
 
500
502
  def find_from_format_by_id(id)
501
503
  id = normalize_id(id)
502
504
 
503
- if /\A(?:(http|https):\/(\/)?(dx\.)?(doi\.org|handle\.stage\.datacite\.org)\/)?(doi:)?(10\.\d{4,5}\/.+)\z/.match(id)
505
+ if %r{\A(?:(http|https):/(/)?(dx\.)?(doi\.org|handle\.stage\.datacite\.org)/)?(doi:)?(10\.\d{4,5}/.+)\z}.match?(id)
504
506
  ra = get_doi_ra(id)
505
- %w(DataCite Crossref mEDRA KISTI JaLC OP).include?(ra) ? ra.downcase : nil
506
- elsif /\A(?:(http|https):\/(\/)?orcid\.org\/)?(\d{4}-\d{4}-\d{4}-\d{3}[0-9X]+)\z/.match(id)
507
- "orcid"
508
- elsif /\A(http|https):\/(\/)?github\.com\/(.+)\/package.json\z/.match(id)
509
- "npm"
510
- elsif /\A(http|https):\/(\/)?github\.com\/(.+)\/codemeta.json\z/.match(id)
511
- "codemeta"
512
- elsif /\A(http|https):\/(\/)?github\.com\/(.+)\/CITATION.cff\z/.match(id)
513
- "cff"
514
- elsif /\A(http|https):\/(\/)?github\.com\/(.+)\z/.match(id)
515
- "cff"
507
+ %w[DataCite Crossref mEDRA KISTI JaLC OP].include?(ra) ? ra.downcase : nil
508
+ elsif %r{\A(?:(http|https):/(/)?orcid\.org/)?(\d{4}-\d{4}-\d{4}-\d{3}[0-9X]+)\z}.match?(id)
509
+ 'orcid'
510
+ elsif %r{\A(http|https):/(/)?github\.com/(.+)/package.json\z}.match?(id)
511
+ 'npm'
512
+ elsif %r{\A(http|https):/(/)?github\.com/(.+)/codemeta.json\z}.match?(id)
513
+ 'codemeta'
514
+ elsif %r{\A(http|https):/(/)?github\.com/(.+)/CITATION.cff\z}.match?(id)
515
+ 'cff'
516
+ elsif %r{\A(http|https):/(/)?github\.com/(.+)\z}.match?(id)
517
+ 'cff'
516
518
  else
517
- "schema_org"
519
+ 'schema_org'
518
520
  end
519
521
  end
520
522
 
521
523
  def find_from_format_by_filename(filename)
522
- if filename == "package.json"
523
- "npm"
524
- elsif filename == "CITATION.cff"
525
- "cff"
524
+ if filename == 'package.json'
525
+ 'npm'
526
+ elsif filename == 'CITATION.cff'
527
+ 'cff'
526
528
  end
527
529
  end
528
530
 
529
- def find_from_format_by_ext(string, options={})
530
- if options[:ext] == ".bib"
531
- "bibtex"
532
- elsif options[:ext] == ".ris"
533
- "ris"
534
- elsif options[:ext] == ".xml" && Maremma.from_xml(string).to_h.dig("crossref_result", "query_result", "body", "query", "doi_record", "crossref")
535
- "crossref"
536
- elsif options[:ext] == ".xml" && Nokogiri::XML(string, nil, 'UTF-8', &:noblanks).collect_namespaces.find { |k, v| v.start_with?("http://datacite.org/schema/kernel") }
537
- "datacite"
538
- elsif options[:ext] == ".cff"
539
- "cff"
540
- elsif options[:ext] == ".json" && URI(Maremma.from_json(string).to_h.fetch("@context", "")).host == "schema.org"
541
- "schema_org"
542
- elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("@context") == ("https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld")
543
- "codemeta"
544
- elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("schemaVersion").to_s.start_with?("http://datacite.org/schema/kernel")
545
- "datacite_json"
546
- elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("types") && Maremma.from_json(string).to_h.dig("publication_year").present?
547
- "crosscite"
548
- elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("issued", "date-parts").present?
549
- "citeproc"
531
+ def find_from_format_by_ext(string, options = {})
532
+ if options[:ext] == '.bib'
533
+ 'bibtex'
534
+ elsif options[:ext] == '.ris'
535
+ 'ris'
536
+ elsif options[:ext] == '.xml' && Maremma.from_xml(string).to_h.dig('crossref_result',
537
+ 'query_result', 'body', 'query', 'doi_record', 'crossref')
538
+ 'crossref'
539
+ elsif options[:ext] == '.xml' && Nokogiri::XML(string, nil, 'UTF-8',
540
+ &:noblanks).collect_namespaces.find do |_k, v|
541
+ v.start_with?('http://datacite.org/schema/kernel')
542
+ end
543
+ 'datacite'
544
+ elsif options[:ext] == '.cff'
545
+ 'cff'
546
+ elsif options[:ext] == '.json' && URI(Maremma.from_json(string).to_h.fetch('@context',
547
+ '')).host == 'schema.org'
548
+ 'schema_org'
549
+ elsif options[:ext] == '.json' && Maremma.from_json(string).to_h.dig('source') == 'Crossref'
550
+ 'crossref_json'
551
+ elsif options[:ext] == '.json' && Maremma.from_json(string).to_h.dig('@context') == ('https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld')
552
+ 'codemeta'
553
+ elsif options[:ext] == '.json' && Maremma.from_json(string).to_h.dig('schemaVersion').to_s.start_with?('http://datacite.org/schema/kernel')
554
+ 'datacite_json'
555
+ elsif options[:ext] == '.json' && Maremma.from_json(string).to_h.dig('types') && Maremma.from_json(string).to_h.dig('publication_year').present?
556
+ 'crosscite'
557
+ elsif options[:ext] == '.json' && Maremma.from_json(string).to_h.dig('issued',
558
+ 'date-parts').present?
559
+ 'citeproc'
550
560
  end
551
561
  end
552
562
 
553
563
  def find_from_format_by_string(string)
554
- if Maremma.from_xml(string).to_h.dig("crossref_result", "query_result", "body", "query", "doi_record", "crossref").present?
555
- "crossref"
556
- elsif Nokogiri::XML(string, nil, 'UTF-8', &:noblanks).collect_namespaces.find { |k, v| v.start_with?("http://datacite.org/schema/kernel") }
557
- "datacite"
558
- elsif URI(Maremma.from_json(string).to_h.fetch("@context", "")).host == "schema.org"
559
- "schema_org"
560
- elsif Maremma.from_json(string).to_h.dig("@context") == ("https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld")
561
- "codemeta"
562
- elsif Maremma.from_json(string).to_h.dig("schema-version").to_s.start_with?("http://datacite.org/schema/kernel")
563
- "datacite_json"
564
- elsif Maremma.from_json(string).to_h.dig("types").present? && Maremma.from_json(string).to_h.dig("publication_year").present?
565
- "crosscite"
566
- elsif Maremma.from_json(string).to_h.dig("issued", "date-parts").present?
567
- "citeproc"
568
- elsif string.start_with?("TY - ")
569
- "ris"
570
- elsif YAML.load(string).to_h.fetch("cff-version", nil).present?
571
- "cff"
564
+ if Maremma.from_xml(string).to_h.dig('crossref_result', 'query_result', 'body', 'query',
565
+ 'doi_record', 'crossref').present?
566
+ 'crossref'
567
+ elsif Nokogiri::XML(string, nil, 'UTF-8', &:noblanks).collect_namespaces.find do |_k, v|
568
+ v.start_with?('http://datacite.org/schema/kernel')
569
+ end
570
+ 'datacite'
571
+ elsif URI(Maremma.from_json(string).to_h.fetch('@context', '')).host == 'schema.org'
572
+ 'schema_org'
573
+ elsif Maremma.from_json(string).to_h.dig('@context') == ('https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld')
574
+ 'codemeta'
575
+ elsif Maremma.from_json(string).to_h.dig('schema-version').to_s.start_with?('http://datacite.org/schema/kernel')
576
+ 'datacite_json'
577
+ elsif Maremma.from_json(string).to_h.dig('types').present? && Maremma.from_json(string).to_h.dig('publication_year').present?
578
+ 'crosscite'
579
+ elsif Maremma.from_json(string).to_h.dig('issued', 'date-parts').present?
580
+ 'citeproc'
581
+ elsif string.start_with?('TY - ')
582
+ 'ris'
583
+ elsif YAML.load(string).to_h.fetch('cff-version', nil).present?
584
+ 'cff'
572
585
  elsif BibTeX.parse(string).first
573
- "bibtex"
586
+ 'bibtex'
574
587
  end
575
- rescue Psych::SyntaxError => error
576
- "bibtex"
577
- rescue BibTeX::ParseError => error
588
+ rescue Psych::SyntaxError => e
589
+ 'bibtex'
590
+ rescue BibTeX::ParseError => e
578
591
  nil
579
592
  end
580
593
 
581
594
  def orcid_from_url(url)
582
- Array(/\A:(http|https):\/\/orcid\.org\/(.+)/.match(url)).last
595
+ Array(%r{\A:(http|https)://orcid\.org/(.+)}.match(url)).last
583
596
  end
584
597
 
585
598
  def orcid_as_url(orcid)
@@ -587,40 +600,38 @@ module Briard
587
600
  end
588
601
 
589
602
  def validate_orcid(orcid)
590
- orcid = Array(/\A(?:(?:http|https):\/\/(?:(?:www|sandbox)?\.)?orcid\.org\/)?(\d{4}[[:space:]-]\d{4}[[:space:]-]\d{4}[[:space:]-]\d{3}[0-9X]+)\z/.match(orcid)).last
591
- orcid.gsub(/[[:space:]]/, "-") if orcid.present?
603
+ orcid = Array(%r{\A(?:(?:http|https)://(?:(?:www|sandbox)?\.)?orcid\.org/)?(\d{4}[[:space:]-]\d{4}[[:space:]-]\d{4}[[:space:]-]\d{3}[0-9X]+)\z}.match(orcid)).last
604
+ orcid.gsub(/[[:space:]]/, '-') if orcid.present?
592
605
  end
593
606
 
594
607
  def validate_orcid_scheme(orcid_scheme)
595
- Array(/\A(http|https):\/\/(www\.)?(orcid\.org)/.match(orcid_scheme)).last
608
+ Array(%r{\A(http|https)://(www\.)?(orcid\.org)}.match(orcid_scheme)).last
596
609
  end
597
610
 
598
611
  def validate_url(str)
599
- if /\A(?:(http|https):\/\/(dx\.)?doi.org\/)?(doi:)?(10\.\d{4,5}\/.+)\z/.match(str)
600
- "DOI"
601
- elsif /\A(http|https):\/\//.match(str)
602
- "URL"
603
- elsif /\A(ISSN|eISSN) (\d{4}-\d{3}[0-9X]+)\z/.match(str)
604
- "ISSN"
612
+ if %r{\A(?:(http|https)://(dx\.)?doi.org/)?(doi:)?(10\.\d{4,5}/.+)\z}.match?(str)
613
+ 'DOI'
614
+ elsif %r{\A(http|https)://}.match?(str)
615
+ 'URL'
616
+ elsif /\A(ISSN|eISSN) (\d{4}-\d{3}[0-9X]+)\z/.match?(str)
617
+ 'ISSN'
605
618
  end
606
619
  end
607
620
 
608
- def parse_attributes(element, options={})
609
- content = options[:content] || "__content__"
621
+ def parse_attributes(element, options = {})
622
+ content = options[:content] || '__content__'
610
623
 
611
624
  if element.is_a?(String) && options[:content].nil?
612
625
  CGI.unescapeHTML(element)
613
626
  elsif element.is_a?(Hash)
614
- element.fetch( CGI.unescapeHTML(content), nil)
627
+ element.fetch(CGI.unescapeHTML(content), nil)
615
628
  elsif element.is_a?(Array)
616
629
  a = element.map { |e| e.is_a?(Hash) ? e.fetch(CGI.unescapeHTML(content), nil) : e }.uniq
617
630
  a = options[:first] ? a.first : a.unwrap
618
- else
619
- nil
620
631
  end
621
632
  end
622
633
 
623
- def normalize_id(id, options={})
634
+ def normalize_id(id, options = {})
624
635
  return nil unless id.present?
625
636
 
626
637
  # check for valid DOI
@@ -629,7 +640,7 @@ module Briard
629
640
 
630
641
  # check for valid HTTP uri
631
642
  uri = Addressable::URI.parse(id)
632
- return nil unless uri && uri.host && %w(http https).include?(uri.scheme)
643
+ return nil unless uri && uri.host && %w[http https].include?(uri.scheme)
633
644
 
634
645
  # clean up URL
635
646
  PostRank::URI.clean(id)
@@ -637,19 +648,19 @@ module Briard
637
648
  nil
638
649
  end
639
650
 
640
- def normalize_url(id, options={})
651
+ def normalize_url(id, options = {})
641
652
  return nil unless id.present?
642
653
 
643
654
  # handle info URIs
644
- return id if id.to_s.start_with?("info")
655
+ return id if id.to_s.start_with?('info')
645
656
 
646
657
  # check for valid HTTP uri
647
658
  uri = Addressable::URI.parse(id)
648
659
 
649
- return nil unless uri && uri.host && %w(http https ftp).include?(uri.scheme)
660
+ return nil unless uri && uri.host && %w[http https ftp].include?(uri.scheme)
650
661
 
651
662
  # optionally turn into https URL
652
- uri.scheme = "https" if options[:https]
663
+ uri.scheme = 'https' if options[:https]
653
664
 
654
665
  # clean up URL
655
666
  uri.path = PostRank::URI.clean(uri.path)
@@ -669,74 +680,74 @@ module Briard
669
680
  return nil unless orcid.present?
670
681
 
671
682
  # turn ORCID ID into URL
672
- "https://orcid.org/" + Addressable::URI.encode(orcid)
683
+ 'https://orcid.org/' + Addressable::URI.encode(orcid)
673
684
  end
674
685
 
675
686
  def normalize_ids(ids: nil, relation_type: nil)
676
- Array.wrap(ids).select { |idx| idx["@id"].present? }.map do |idx|
677
- id = normalize_id(idx["@id"])
678
- related_identifier_type = doi_from_url(id).present? ? "DOI" : "URL"
687
+ Array.wrap(ids).select { |idx| idx['@id'].present? }.map do |idx|
688
+ id = normalize_id(idx['@id'])
689
+ related_identifier_type = doi_from_url(id).present? ? 'DOI' : 'URL'
679
690
  id = doi_from_url(id) || id
680
691
 
681
- { "relatedIdentifier" => id,
682
- "relationType" => relation_type,
683
- "relatedIdentifierType" => related_identifier_type,
684
- "resourceTypeGeneral" => Metadata::SO_TO_DC_TRANSLATIONS[idx["@type"]] }.compact
692
+ { 'relatedIdentifier' => id,
693
+ 'relationType' => relation_type,
694
+ 'relatedIdentifierType' => related_identifier_type,
695
+ 'resourceTypeGeneral' => Metadata::SO_TO_DC_TRANSLATIONS[idx['@type']] }.compact
685
696
  end.unwrap
686
697
  end
687
698
 
688
699
  # pick electronic issn if there are multiple
689
700
  # format issn as xxxx-xxxx
690
- def normalize_issn(input, options={})
691
- content = options[:content] || "__content__"
701
+ def normalize_issn(input, options = {})
702
+ content = options[:content] || '__content__'
692
703
 
693
704
  issn = if input.blank?
694
- nil
695
- elsif input.is_a?(String) && options[:content].nil?
696
- input
697
- elsif input.is_a?(Hash)
698
- input.fetch(content, nil)
699
- elsif input.is_a?(Array)
700
- a = input.find { |a| a["media_type"] == "electronic" } || input.first
701
- a.fetch(content, nil)
702
- end
705
+ nil
706
+ elsif input.is_a?(String) && options[:content].nil?
707
+ input
708
+ elsif input.is_a?(Hash)
709
+ input.fetch(content, nil)
710
+ elsif input.is_a?(Array)
711
+ a = input.find { |a| a['media_type'] == 'electronic' } || input.first
712
+ a.fetch(content, nil)
713
+ end
703
714
 
704
715
  case issn.to_s.length
705
716
  when 9
706
717
  issn
707
718
  when 8
708
- issn[0..3] + "-" + issn[4..7]
709
- else
710
- nil
719
+ issn[0..3] + '-' + issn[4..7]
711
720
  end
712
721
  end
713
722
 
714
723
  # find Creative Commons or OSI license in licenses array, normalize url and name
715
724
  def normalize_licenses(licenses)
716
- standard_licenses = Array.wrap(licenses).map { |l| URI.parse(l["url"]) }.select { |li| li.host && li.host[/(creativecommons.org|opensource.org)$/] }
725
+ standard_licenses = Array.wrap(licenses).map do |l|
726
+ URI.parse(l['url'])
727
+ end.select { |li| li.host && li.host[/(creativecommons.org|opensource.org)$/] }
717
728
  return licenses unless standard_licenses.present?
718
729
 
719
730
  # use HTTPS
720
- uri.scheme = "https"
731
+ uri.scheme = 'https'
721
732
 
722
733
  # use host name without subdomain
723
734
  uri.host = Array(/(creativecommons.org|opensource.org)/.match uri.host).last
724
735
 
725
736
  # normalize URLs
726
- if uri.host == "creativecommons.org"
727
- uri.path = uri.path.split('/')[0..-2].join("/") if uri.path.split('/').last == "legalcode"
737
+ if uri.host == 'creativecommons.org'
738
+ uri.path = uri.path.split('/')[0..-2].join('/') if uri.path.split('/').last == 'legalcode'
728
739
  uri.path << '/' unless uri.path.end_with?('/')
729
740
  else
730
741
  uri.path = uri.path.gsub(/(-license|\.php|\.html)/, '')
731
742
  uri.path = uri.path.sub(/(mit|afl|apl|osl|gpl|ecl)/) { |match| match.upcase }
732
743
  uri.path = uri.path.sub(/(artistic|apache)/) { |match| match.titleize }
733
- uri.path = uri.path.sub(/([^0-9\-]+)(-)?([1-9])?(\.)?([0-9])?$/) do
744
+ uri.path = uri.path.sub(/([^0-9-]+)(-)?([1-9])?(\.)?([0-9])?$/) do
734
745
  m = Regexp.last_match
735
746
  text = m[1]
736
747
 
737
748
  if m[3].present?
738
- version = [m[3], m[5].presence || "0"].join(".")
739
- [text, version].join("-")
749
+ version = [m[3], m[5].presence || '0'].join('.')
750
+ [text, version].join('-')
740
751
  else
741
752
  text
742
753
  end
@@ -748,103 +759,111 @@ module Briard
748
759
  nil
749
760
  end
750
761
 
751
- def to_datacite_json(element, options={})
762
+ def to_datacite_json(element, options = {})
752
763
  a = Array.wrap(element).map do |e|
753
- e.inject({}) {|h, (k,v)| h[k.dasherize] = v; h }
764
+ e.each_with_object({}) do |(k, v), h|
765
+ h[k.dasherize] = v
766
+ end
754
767
  end
755
768
  options[:first] ? a.unwrap : a.presence
756
769
  end
757
770
 
758
771
  def from_datacite_json(element)
759
772
  Array.wrap(element).map do |e|
760
- e.inject({}) {|h, (k,v)| h[k.underscore] = v; h }
773
+ e.each_with_object({}) do |(k, v), h|
774
+ h[k.underscore] = v
775
+ end
761
776
  end
762
777
  end
763
778
 
764
779
  def to_schema_org(element)
765
- mapping = { "type" => "@type", "id" => "@id", "title" => "name" }
780
+ mapping = { 'type' => '@type', 'id' => '@id', 'title' => 'name' }
766
781
 
767
782
  map_hash_keys(element: element, mapping: mapping)
768
783
  end
769
784
 
770
785
  def to_schema_org_creators(element)
771
786
  element = Array.wrap(element).map do |c|
772
- c["affiliation"] = Array.wrap(c["affiliation"]).map do |a|
787
+ c['affiliation'] = Array.wrap(c['affiliation']).map do |a|
773
788
  if a.is_a?(String)
774
789
  name = a
775
790
  affiliation_identifier = nil
776
791
  else
777
- name = a["name"]
778
- affiliation_identifier = a["affiliationIdentifier"]
792
+ name = a['name']
793
+ affiliation_identifier = a['affiliationIdentifier']
779
794
  end
780
795
 
781
- {
782
- "@type" => "Organization",
783
- "@id" => affiliation_identifier,
784
- "name" => name }.compact
796
+ { '@type' => 'Organization', '@id' => affiliation_identifier, 'name' => name }.compact
785
797
  end.unwrap
786
- c["@type"] = c["nameType"].present? ? c["nameType"][0..-3] : nil
787
- c["@id"] = Array.wrap(c["nameIdentifiers"]).first.to_h.fetch("nameIdentifier", nil)
788
- c["name"] = c["familyName"].present? ? [c["givenName"], c["familyName"]].join(" ") : c["name"]
789
- c.except("nameIdentifiers", "nameType").compact
798
+ c['@type'] = c['nameType'].present? ? c['nameType'][0..-3] : nil
799
+ c['@id'] = Array.wrap(c['nameIdentifiers']).first.to_h.fetch('nameIdentifier', nil)
800
+ c['name'] =
801
+ c['familyName'].present? ? [c['givenName'], c['familyName']].join(' ') : c['name']
802
+ c.except('nameIdentifiers', 'nameType').compact
790
803
  end.unwrap
791
804
  end
792
805
 
793
806
  def to_schema_org_contributors(element)
794
807
  element = Array.wrap(element).map do |c|
795
- c["affiliation"] = Array.wrap(c["affiliation"]).map do |a|
808
+ c['affiliation'] = Array.wrap(c['affiliation']).map do |a|
796
809
  if a.is_a?(String)
797
810
  name = a
798
811
  affiliation_identifier = nil
799
812
  else
800
- name = a["name"]
801
- affiliation_identifier = a["affiliationIdentifier"]
813
+ name = a['name']
814
+ affiliation_identifier = a['affiliationIdentifier']
802
815
  end
803
816
 
804
- {
805
- "@type" => "Organization",
806
- "@id" => affiliation_identifier,
807
- "name" => name }.compact
817
+ { '@type' => 'Organization', '@id' => affiliation_identifier, 'name' => name }.compact
808
818
  end.unwrap
809
- c["@type"] = c["nameType"].present? ? c["nameType"][0..-3] : nil
810
- c["@id"] = Array.wrap(c["nameIdentifiers"]).first.to_h.fetch("nameIdentifier", nil)
811
- c["name"] = c["familyName"].present? ? [c["givenName"], c["familyName"]].join(" ") : c["name"]
812
- c.except("nameIdentifiers", "nameType").compact
819
+ c['@type'] = c['nameType'].present? ? c['nameType'][0..-3] : nil
820
+ c['@id'] = Array.wrap(c['nameIdentifiers']).first.to_h.fetch('nameIdentifier', nil)
821
+ c['name'] =
822
+ c['familyName'].present? ? [c['givenName'], c['familyName']].join(' ') : c['name']
823
+ c.except('nameIdentifiers', 'nameType').compact
813
824
  end.unwrap
814
825
  end
815
826
 
816
- def to_schema_org_container(element, options={})
817
- return nil unless (element.is_a?(Hash) || (element.nil? && options[:container_title].present?))
827
+ def to_schema_org_container(element, options = {})
828
+ return nil unless element.is_a?(Hash) || (element.nil? && options[:container_title].present?)
818
829
 
819
830
  {
820
- "@id" => element["identifier"],
821
- "@type" => (options[:type] == "Dataset") ? "DataCatalog" : "Periodical",
822
- "name" => element["title"] || options[:container_title] }.compact
831
+ '@id' => element['identifier'],
832
+ '@type' => options[:type] == 'Dataset' ? 'DataCatalog' : 'Periodical',
833
+ 'name' => element['title'] || options[:container_title]
834
+ }.compact
823
835
  end
824
836
 
825
- def to_schema_org_identifiers(element, options={})
837
+ def to_schema_org_identifiers(element, _options = {})
826
838
  Array.wrap(element).map do |ai|
827
839
  {
828
- "@type" => "PropertyValue",
829
- "propertyID" => ai["identifierType"],
830
- "value" => ai["identifier"] }
840
+ '@type' => 'PropertyValue',
841
+ 'propertyID' => ai['identifierType'],
842
+ 'value' => ai['identifier']
843
+ }
831
844
  end.unwrap
832
845
  end
833
846
 
834
847
  def to_schema_org_relation(related_identifiers: nil, relation_type: nil)
835
848
  return nil unless related_identifiers.present? && relation_type.present?
836
849
 
837
- relation_type = relation_type == "References" ? ["References", "Cites", "Documents"] : [relation_type]
838
-
839
- Array.wrap(related_identifiers).select { |ri| relation_type.include?(ri["relationType"]) }.map do |r|
840
- if r["relatedIdentifierType"] == "ISSN" && r["relationType"] == "IsPartOf"
841
- {
842
- "@type" => "Periodical",
843
- "issn" => r["relatedIdentifier"] }.compact
850
+ relation_type = if relation_type == 'References'
851
+ %w[References Cites
852
+ Documents]
853
+ else
854
+ [relation_type]
855
+ end
856
+
857
+ Array.wrap(related_identifiers).select do |ri|
858
+ relation_type.include?(ri['relationType'])
859
+ end.map do |r|
860
+ if r['relatedIdentifierType'] == 'ISSN' && r['relationType'] == 'IsPartOf'
861
+ { '@type' => 'Periodical', 'issn' => r['relatedIdentifier'] }.compact
844
862
  else
845
- {
846
- "@id" => normalize_id(r["relatedIdentifier"]),
847
- "@type" => DC_TO_SO_TRANSLATIONS[r["resourceTypeGeneral"]] || "CreativeWork" }.compact
863
+ {
864
+ '@id' => normalize_id(r['relatedIdentifier']),
865
+ '@type' => DC_TO_SO_TRANSLATIONS[r['resourceTypeGeneral']] || 'CreativeWork'
866
+ }.compact
848
867
  end
849
868
  end.unwrap
850
869
  end
@@ -854,132 +873,162 @@ module Briard
854
873
 
855
874
  Array.wrap(funding_references).map do |fr|
856
875
  {
857
- "@id" => fr["funderIdentifier"],
858
- "@type" => "Organization",
859
- "name" => fr["funderName"] }.compact
876
+ '@id' => fr['funderIdentifier'],
877
+ '@type' => 'Organization',
878
+ 'name' => fr['funderName']
879
+ }.compact
860
880
  end.unwrap
861
881
  end
862
882
 
863
883
  def to_schema_org_spatial_coverage(geo_location)
864
884
  return nil unless geo_location.present?
865
885
 
866
- Array.wrap(geo_location).reduce([]) do |sum, gl|
867
- if gl.fetch("geoLocationPoint", nil)
886
+ Array.wrap(geo_location).each_with_object([]) do |gl, sum|
887
+ if gl.fetch('geoLocationPoint', nil)
868
888
  sum << {
869
- "@type" => "Place",
870
- "geo" => {
871
- "@type" => "GeoCoordinates",
872
- "address" => gl["geoLocationPlace"],
873
- "latitude" => gl.dig("geoLocationPoint", "pointLatitude"),
874
- "longitude" => gl.dig("geoLocationPoint", "pointLongitude") }
889
+ '@type' => 'Place',
890
+ 'geo' => {
891
+ '@type' => 'GeoCoordinates',
892
+ 'address' => gl['geoLocationPlace'],
893
+ 'latitude' => gl.dig('geoLocationPoint', 'pointLatitude'),
894
+ 'longitude' => gl.dig('geoLocationPoint', 'pointLongitude')
895
+ }
875
896
  }.compact
876
897
  end
877
898
 
878
- if gl.fetch("geoLocationBox", nil)
899
+ if gl.fetch('geoLocationBox', nil)
879
900
  sum << {
880
- "@type" => "Place",
881
- "geo" => {
882
- "@type" => "GeoShape",
883
- "address" => gl["geoLocationPlace"],
884
- "box" => [gl.dig("geoLocationBox", "southBoundLatitude"),
885
- gl.dig("geoLocationBox", "westBoundLongitude"),
886
- gl.dig("geoLocationBox", "northBoundLatitude"),
887
- gl.dig("geoLocationBox", "eastBoundLongitude")].compact.join(" ").presence }.compact
901
+ '@type' => 'Place',
902
+ 'geo' => {
903
+ '@type' => 'GeoShape',
904
+ 'address' => gl['geoLocationPlace'],
905
+ 'box' => [gl.dig('geoLocationBox', 'southBoundLatitude'),
906
+ gl.dig('geoLocationBox', 'westBoundLongitude'),
907
+ gl.dig('geoLocationBox', 'northBoundLatitude'),
908
+ gl.dig('geoLocationBox', 'eastBoundLongitude')].compact.join(' ').presence
909
+ }.compact
888
910
  }.compact
889
911
  end
890
912
 
891
- if gl.fetch("geoLocationPolygon", nil)
913
+ if gl.fetch('geoLocationPolygon', nil)
892
914
  sum << {
893
- "@type" => "Place",
894
- "geo" => {
895
- "@type" => "GeoShape",
896
- "address" => gl["geoLocationPlace"],
897
- "polygon" => Array.wrap(gl.dig("geoLocationPolygon")).map do |glp|
915
+ '@type' => 'Place',
916
+ 'geo' => {
917
+ '@type' => 'GeoShape',
918
+ 'address' => gl['geoLocationPlace'],
919
+ 'polygon' => Array.wrap(gl.dig('geoLocationPolygon')).map do |glp|
898
920
  Array.wrap(glp).map do |glpp|
899
- [glpp.dig("polygonPoint", "pointLongitude"), glpp.dig("polygonPoint", "pointLatitude")].compact
921
+ [glpp.dig('polygonPoint', 'pointLongitude'),
922
+ glpp.dig('polygonPoint', 'pointLatitude')].compact
900
923
  end.compact
901
- end.compact.presence,
902
- }
924
+ end.compact.presence
925
+ }
903
926
  }
904
927
  end
905
928
 
906
- if gl.fetch("geoLocationPlace", nil) && !gl.fetch("geoLocationPoint", nil) && !gl.fetch("geoLocationBox", nil) && !gl.fetch("geoLocationPolygon", nil)
907
- sum << {
908
- "@type" => "Place",
909
- "geo" => {
910
- "@type" => "GeoCoordinates",
911
- "address" => gl["geoLocationPlace"] }
912
- }.compact
913
- end
914
-
915
- sum
929
+ next unless gl.fetch('geoLocationPlace',
930
+ nil) && !gl.fetch('geoLocationPoint',
931
+ nil) && !gl.fetch('geoLocationBox',
932
+ nil) && !gl.fetch(
933
+ 'geoLocationPolygon', nil
934
+ )
935
+
936
+ sum << {
937
+ '@type' => 'Place',
938
+ 'geo' => {
939
+ '@type' => 'GeoCoordinates',
940
+ 'address' => gl['geoLocationPlace']
941
+ }
942
+ }.compact
916
943
  end.unwrap
917
944
  end
918
945
 
919
946
  def from_schema_org(element)
920
- mapping = { "@type" => "type", "@id" => "id" }
947
+ mapping = { '@type' => 'type', '@id' => 'id' }
921
948
 
922
949
  map_hash_keys(element: element, mapping: mapping)
923
950
  end
924
951
 
925
952
  def from_schema_org_creators(element)
926
953
  element = Array.wrap(element).map do |c|
927
- if c["affiliation"].is_a?(String)
928
- c["affiliation"] = { "name" => c["affiliation"] }
954
+ if c['affiliation'].is_a?(String)
955
+ c['affiliation'] = { 'name' => c['affiliation'] }
929
956
  affiliation_identifier_scheme = nil
930
957
  scheme_uri = nil
931
- elsif c.dig("affiliation", "@id").to_s.starts_with?("https://ror.org")
932
- affiliation_identifier_scheme = "ROR"
933
- scheme_uri = "https://ror.org/"
934
- elsif c.dig("affiliation", "@id").to_s.starts_with?("https://isni.org")
935
- affiliation_identifier_scheme = "ISNI"
936
- scheme_uri = "https://isni.org/isni/"
958
+ elsif c.dig('affiliation', '@id').to_s.starts_with?('https://ror.org')
959
+ affiliation_identifier_scheme = 'ROR'
960
+ scheme_uri = 'https://ror.org/'
961
+ elsif c.dig('affiliation', '@id').to_s.starts_with?('https://isni.org')
962
+ affiliation_identifier_scheme = 'ISNI'
963
+ scheme_uri = 'https://isni.org/isni/'
937
964
  else
938
965
  affiliation_identifier_scheme = nil
939
966
  scheme_uri = nil
940
967
  end
941
968
 
942
969
  # alternatively find the nameIdentifier in the identifer attribute
943
- c["@id"] = c["identifier"] if c["identifier"].present? && c["@id"].blank?
970
+ c['@id'] = c['identifier'] if c['identifier'].present? && c['@id'].blank?
944
971
 
945
972
  # alternatively find the nameIdentifier in the sameAs attribute
946
- c["@id"] = c["sameAs"].first if Array(c["sameAs"]).find { |item| URI(item).host == "orcid.org" }
947
-
948
- c["nameIdentifier"] = [{ "__content__" => c["@id"], "nameIdentifierScheme" => "ORCID", "schemeUri" => "https://orcid.org" }] if normalize_orcid(c["@id"])
949
- c["@type"] = c["@type"].find { |t| %w(Person Organization).include?(t) } if c["@type"].is_a?(Array)
950
- c["creatorName"] = { "nameType" => c["@type"].present? ? c["@type"].titleize + "al" : nil, "__content__" => c["name"] }.compact
951
- c["affiliation"] = { "__content__" => c.dig("affiliation", "name"), "affiliationIdentifier" => c.dig("affiliation", "@id"), "affiliationIdentifierScheme" => affiliation_identifier_scheme, "schemeUri" => scheme_uri }.compact.presence
952
- c.except("@id", "@type", "name").compact
973
+ c['@id'] = c['sameAs'].first if Array(c['sameAs']).find do |item|
974
+ URI(item).host == 'orcid.org'
975
+ end
976
+
977
+ if normalize_orcid(c['@id'])
978
+ c['nameIdentifier'] =
979
+ [{ '__content__' => c['@id'], 'nameIdentifierScheme' => 'ORCID',
980
+ 'schemeUri' => 'https://orcid.org' }]
981
+ end
982
+ if c['@type'].is_a?(Array)
983
+ c['@type'] = c['@type'].find do |t|
984
+ %w[Person Organization].include?(t)
985
+ end
986
+ end
987
+ c['creatorName'] =
988
+ { 'nameType' => c['@type'].present? ? c['@type'].titleize + 'al' : nil,
989
+ '__content__' => c['name'] }.compact
990
+ c['affiliation'] =
991
+ { '__content__' => c.dig('affiliation', 'name'),
992
+ 'affiliationIdentifier' => c.dig('affiliation', '@id'), 'affiliationIdentifierScheme' => affiliation_identifier_scheme, 'schemeUri' => scheme_uri }.compact.presence
993
+ c.except('@id', '@type', 'name').compact
953
994
  end
954
995
  end
955
996
 
956
997
  def from_schema_org_contributors(element)
957
998
  element = Array.wrap(element).map do |c|
958
- if c["affiliation"].is_a?(String)
959
- c["affiliation"] = { "name" => c["affiliation"] }
999
+ if c['affiliation'].is_a?(String)
1000
+ c['affiliation'] = { 'name' => c['affiliation'] }
960
1001
  affiliation_identifier_scheme = nil
961
1002
  scheme_uri = nil
962
- elsif c.dig("affiliation", "@id").to_s.starts_with?("https://ror.org")
963
- affiliation_identifier_scheme = "ROR"
964
- scheme_uri = "https://ror.org/"
965
- elsif c.dig("affiliation", "@id").to_s.starts_with?("https://isni.org")
966
- affiliation_identifier_scheme = "ISNI"
967
- scheme_uri = "https://isni.org/isni/"
1003
+ elsif c.dig('affiliation', '@id').to_s.starts_with?('https://ror.org')
1004
+ affiliation_identifier_scheme = 'ROR'
1005
+ scheme_uri = 'https://ror.org/'
1006
+ elsif c.dig('affiliation', '@id').to_s.starts_with?('https://isni.org')
1007
+ affiliation_identifier_scheme = 'ISNI'
1008
+ scheme_uri = 'https://isni.org/isni/'
968
1009
  else
969
1010
  affiliation_identifier_scheme = nil
970
1011
  scheme_uri = nil
971
1012
  end
972
1013
 
973
- c["nameIdentifier"] = [{ "__content__" => c["@id"], "nameIdentifierScheme" => "ORCID", "schemeUri" => "https://orcid.org" }] if normalize_orcid(c["@id"])
974
- c["contributorName"] = { "nameType" => c["@type"].present? ? c["@type"].titleize + "al" : nil, "__content__" => c["name"] }.compact
975
- c["affiliation"] = { "__content__" => c.dig("affiliation", "name"), "affiliationIdentifier" => c.dig("affiliation", "@id"), "affiliationIdentifierScheme" => affiliation_identifier_scheme, "schemeUri" => scheme_uri }.compact.presence
976
- c.except("@id", "@type", "name").compact
1014
+ if normalize_orcid(c['@id'])
1015
+ c['nameIdentifier'] =
1016
+ [{ '__content__' => c['@id'], 'nameIdentifierScheme' => 'ORCID',
1017
+ 'schemeUri' => 'https://orcid.org' }]
1018
+ end
1019
+ c['contributorName'] =
1020
+ { 'nameType' => c['@type'].present? ? c['@type'].titleize + 'al' : nil,
1021
+ '__content__' => c['name'] }.compact
1022
+ c['affiliation'] =
1023
+ { '__content__' => c.dig('affiliation', 'name'),
1024
+ 'affiliationIdentifier' => c.dig('affiliation', '@id'), 'affiliationIdentifierScheme' => affiliation_identifier_scheme, 'schemeUri' => scheme_uri }.compact.presence
1025
+ c.except('@id', '@type', 'name').compact
977
1026
  end
978
1027
  end
979
1028
 
980
1029
  def map_hash_keys(element: nil, mapping: nil)
981
1030
  Array.wrap(element).map do |a|
982
- a.map {|k, v| [mapping.fetch(k, k), v] }.reduce({}) do |hsh, (k, v)|
1031
+ a.map { |k, v| [mapping.fetch(k, k), v] }.reduce({}) do |hsh, (k, v)|
983
1032
  if v.is_a?(Hash)
984
1033
  hsh[k] = to_schema_org(v)
985
1034
  hsh
@@ -993,48 +1042,52 @@ module Briard
993
1042
 
994
1043
  def to_identifier(identifier)
995
1044
  {
996
- "@type" => "PropertyValue",
997
- "propertyID" => identifier["relatedIdentifierType"],
998
- "value" => identifier["relatedIdentifier"] }
1045
+ '@type' => 'PropertyValue',
1046
+ 'propertyID' => identifier['relatedIdentifierType'],
1047
+ 'value' => identifier['relatedIdentifier']
1048
+ }
999
1049
  end
1000
1050
 
1001
1051
  def from_citeproc(element)
1002
1052
  Array.wrap(element).map do |a|
1003
- if a["literal"].present?
1004
- a["@type"] = "Organization"
1005
- a["name"] = a["literal"]
1053
+ if a['literal'].present?
1054
+ a['@type'] = 'Organization'
1055
+ a['name'] = a['literal']
1056
+ elsif a['name'].present?
1057
+ a['@type'] = 'Organization'
1006
1058
  else
1007
- a["@type"] = "Person"
1008
- a["name"] = [a["given"], a["family"]].compact.join(" ")
1059
+ a['@type'] = 'Person'
1060
+ a['name'] = [a['given'], a['family']].compact.join(' ')
1009
1061
  end
1010
- a["givenName"] = a["given"]
1011
- a["familyName"] = a["family"]
1012
- a.except("given", "family", "literal").compact
1062
+ a['givenName'] = a['given']
1063
+ a['familyName'] = a['family']
1064
+ a.except('given', 'family', 'literal').compact
1013
1065
  end.unwrap
1014
1066
  end
1015
1067
 
1016
1068
  def to_citeproc(element)
1017
1069
  Array.wrap(element).map do |a|
1018
- a["family"] = a["familyName"]
1019
- a["given"] = a["givenName"]
1020
- a["literal"] = a["name"] unless a["familyName"].present?
1021
- a.except("nameType", "type", "@type", "id", "@id", "name", "familyName", "givenName", "affiliation", "nameIdentifiers", "contributorType").compact
1070
+ a['family'] = a['familyName']
1071
+ a['given'] = a['givenName']
1072
+ a['literal'] = a['name'] unless a['familyName'].present?
1073
+ a.except('nameType', 'type', '@type', 'id', '@id', 'name', 'familyName', 'givenName',
1074
+ 'affiliation', 'nameIdentifiers', 'contributorType').compact
1022
1075
  end.presence
1023
1076
  end
1024
1077
 
1025
1078
  def to_ris(element)
1026
1079
  Array.wrap(element).map do |a|
1027
- if a["familyName"].present?
1028
- [a["familyName"], a["givenName"]].join(", ")
1080
+ if a['familyName'].present?
1081
+ [a['familyName'], a['givenName']].join(', ')
1029
1082
  else
1030
- a["name"]
1083
+ a['name']
1031
1084
  end
1032
1085
  end.unwrap
1033
1086
  end
1034
1087
 
1035
- def sanitize(text, options={})
1036
- options[:tags] ||= Set.new(%w(strong em b i code pre sub sup br))
1037
- content = options[:content] || "__content__"
1088
+ def sanitize(text, options = {})
1089
+ options[:tags] ||= Set.new(%w[strong em b i code pre sub sup br])
1090
+ content = options[:content] || '__content__'
1038
1091
  custom_scrubber = Briard::WhitelistScrubber.new(options)
1039
1092
 
1040
1093
  if text.is_a?(String)
@@ -1045,20 +1098,16 @@ module Briard
1045
1098
  elsif text.is_a?(Array)
1046
1099
  a = text.map { |e| e.is_a?(Hash) ? sanitize(e.fetch(content, nil)) : sanitize(e) }.uniq
1047
1100
  a = options[:first] ? a.first : a.unwrap
1048
- else
1049
- nil
1050
1101
  end
1051
1102
  end
1052
1103
 
1053
1104
  def github_from_url(url)
1054
- return {} unless /\Ahttps:\/\/github\.com\/(.+)(?:\/)?(.+)?(?:\/tree\/)?(.*)\z/.match(url)
1105
+ return {} unless %r{\Ahttps://github\.com/(.+)(?:/)?(.+)?(?:/tree/)?(.*)\z}.match?(url)
1106
+
1055
1107
  words = URI.parse(url).path[1..-1].split('/')
1056
- path = words.length > 3 ? words[4...words.length].join("/") : nil
1108
+ path = words.length > 3 ? words[4...words.length].join('/') : nil
1057
1109
 
1058
- { owner: words[0],
1059
- repo: words[1],
1060
- release: words[3],
1061
- path: path }.compact
1110
+ { owner: words[0], repo: words[1], release: words[3], path: path }.compact
1062
1111
  end
1063
1112
 
1064
1113
  def github_repo_from_url(url)
@@ -1080,18 +1129,22 @@ module Briard
1080
1129
 
1081
1130
  def github_as_repo_url(url)
1082
1131
  github_hash = github_from_url(url)
1083
- "https://github.com/#{github_hash[:owner]}/#{github_hash[:repo]}" if github_hash[:repo].present?
1132
+ return unless github_hash[:repo].present?
1133
+
1134
+ "https://github.com/#{github_hash[:owner]}/#{github_hash[:repo]}"
1084
1135
  end
1085
1136
 
1086
1137
  def github_as_release_url(url)
1087
1138
  github_hash = github_from_url(url)
1088
- "https://github.com/#{github_hash[:owner]}/#{github_hash[:repo]}/tree/#{github_hash[:release]}" if github_hash[:release].present?
1139
+ return unless github_hash[:release].present?
1140
+
1141
+ "https://github.com/#{github_hash[:owner]}/#{github_hash[:repo]}/tree/#{github_hash[:release]}"
1089
1142
  end
1090
1143
 
1091
1144
  def github_as_codemeta_url(url)
1092
1145
  github_hash = github_from_url(url)
1093
1146
 
1094
- if github_hash[:path].to_s.end_with?("codemeta.json")
1147
+ if github_hash[:path].to_s.end_with?('codemeta.json')
1095
1148
  "https://raw.githubusercontent.com/#{github_hash[:owner]}/#{github_hash[:repo]}/#{github_hash[:release]}/#{github_hash[:path]}"
1096
1149
  elsif github_hash[:owner].present?
1097
1150
  "https://raw.githubusercontent.com/#{github_hash[:owner]}/#{github_hash[:repo]}/master/codemeta.json"
@@ -1101,7 +1154,7 @@ module Briard
1101
1154
  def github_as_cff_url(url)
1102
1155
  github_hash = github_from_url(url)
1103
1156
 
1104
- if github_hash[:path].to_s.end_with?("CITATION.cff")
1157
+ if github_hash[:path].to_s.end_with?('CITATION.cff')
1105
1158
  "https://raw.githubusercontent.com/#{github_hash[:owner]}/#{github_hash[:repo]}/#{github_hash[:release]}/#{github_hash[:path]}"
1106
1159
  elsif github_hash[:owner].present?
1107
1160
  "https://raw.githubusercontent.com/#{github_hash[:owner]}/#{github_hash[:repo]}/main/CITATION.cff"
@@ -1120,13 +1173,21 @@ module Briard
1120
1173
  end
1121
1174
 
1122
1175
  def get_date_from_date_parts(date_as_parts)
1123
- date_parts = date_as_parts.fetch("date-parts", []).first
1124
- year, month, day = date_parts[0], date_parts[1], date_parts[2]
1176
+ date_parts = date_as_parts.fetch('date-parts', []).first
1177
+ return nil if date_parts == [nil]
1178
+
1179
+ year = date_parts[0]
1180
+ month = date_parts[1]
1181
+ day = date_parts[2]
1125
1182
  get_date_from_parts(year, month, day)
1183
+ rescue NoMethodError # if date_parts is nil
1184
+ nil
1126
1185
  end
1127
1186
 
1128
1187
  def get_date_from_parts(year, month = nil, day = nil)
1129
- [year.to_s.rjust(4, '0'), month.to_s.rjust(2, '0'), day.to_s.rjust(2, '0')].reject { |part| part == "00" }.join("-")
1188
+ [year.to_s.rjust(4, '0'), month.to_s.rjust(2, '0'), day.to_s.rjust(2, '0')].reject do |part|
1189
+ part == '00'
1190
+ end.join('-')
1130
1191
  end
1131
1192
 
1132
1193
  def get_date_parts_from_parts(year, month = nil, day = nil)
@@ -1163,67 +1224,67 @@ module Briard
1163
1224
  # return nil if invalid iso8601 timestamp
1164
1225
  def get_datetime_from_iso8601(iso8601_time)
1165
1226
  ISO8601::DateTime.new(iso8601_time).to_time.utc
1166
- rescue
1227
+ rescue StandardError
1167
1228
  nil
1168
1229
  end
1169
1230
 
1170
1231
  # strip milliseconds if there is a time, as it interferes with edtc parsing
1171
1232
  # keep dates unchanged
1172
1233
  def strip_milliseconds(iso8601_time)
1173
- return iso8601_time.split(" ").first if iso8601_time.to_s.include? " "
1234
+ return iso8601_time.split(' ').first if iso8601_time.to_s.include? ' '
1174
1235
 
1175
- return iso8601_time.split(".").first + "Z" if iso8601_time.to_s.include? "."
1236
+ return iso8601_time.split('.').first + 'Z' if iso8601_time.to_s.include? '.'
1176
1237
 
1177
- return iso8601_time
1178
- end
1238
+ iso8601_time
1239
+ end
1179
1240
 
1180
1241
  # iso8601 datetime without hyphens and colons, used by Crossref
1181
1242
  # return nil if invalid
1182
1243
  def get_datetime_from_time(time)
1183
- DateTime.strptime(time.to_s, "%Y%m%d%H%M%S").strftime('%Y-%m-%dT%H:%M:%SZ')
1244
+ DateTime.strptime(time.to_s, '%Y%m%d%H%M%S').strftime('%Y-%m-%dT%H:%M:%SZ')
1184
1245
  rescue ArgumentError
1185
1246
  nil
1186
1247
  end
1187
1248
 
1188
1249
  def get_date(dates, date_type)
1189
- dd = Array.wrap(dates).find { |d| d["dateType"] == date_type } || {}
1190
- dd.fetch("date", nil)
1250
+ dd = Array.wrap(dates).find { |d| d['dateType'] == date_type } || {}
1251
+ dd.fetch('date', nil)
1191
1252
  end
1192
1253
 
1193
1254
  def get_contributor(contributor, contributor_type)
1194
- contributor.select { |c| c["contributorType"] == contributor_type }
1255
+ contributor.select { |c| c['contributorType'] == contributor_type }
1195
1256
  end
1196
1257
 
1197
1258
  def get_identifier(identifiers, identifier_type)
1198
- id = Array.wrap(identifiers).find { |i| i["identifierType"] == identifier_type } || {}
1199
- id.fetch("identifier", nil)
1259
+ id = Array.wrap(identifiers).find { |i| i['identifierType'] == identifier_type } || {}
1260
+ id.fetch('identifier', nil)
1200
1261
  end
1201
1262
 
1202
1263
  def get_identifier_type(identifier_type)
1203
1264
  return nil unless identifier_type.present?
1204
1265
 
1205
1266
  identifierTypes = {
1206
- "ark" => "ARK",
1207
- "arxiv" => "arXiv",
1208
- "bibcode" => "bibcode",
1209
- "doi" => "DOI",
1210
- "ean13" => "EAN13",
1211
- "eissn" => "EISSN",
1212
- "handle" => "Handle",
1213
- "igsn" => "IGSN",
1214
- "isbn" => "ISBN",
1215
- "issn" => "ISSN",
1216
- "istc" => "ISTC",
1217
- "lissn" => "LISSN",
1218
- "lsid" => "LSID",
1219
- "pmid" => "PMID",
1220
- "purl" => "PURL",
1221
- "upc" => "UPC",
1222
- "url" => "URL",
1223
- "urn" => "URN",
1224
- "md5" => "md5",
1225
- "minid" => "minid",
1226
- "dataguid" => "dataguid"
1267
+ 'ark' => 'ARK',
1268
+ 'arxiv' => 'arXiv',
1269
+ 'bibcode' => 'bibcode',
1270
+ 'doi' => 'DOI',
1271
+ 'ean13' => 'EAN13',
1272
+ 'eissn' => 'EISSN',
1273
+ 'handle' => 'Handle',
1274
+ 'igsn' => 'IGSN',
1275
+ 'isbn' => 'ISBN',
1276
+ 'issn' => 'ISSN',
1277
+ 'istc' => 'ISTC',
1278
+ 'lissn' => 'LISSN',
1279
+ 'lsid' => 'LSID',
1280
+ 'pmid' => 'PMID',
1281
+ 'purl' => 'PURL',
1282
+ 'upc' => 'UPC',
1283
+ 'url' => 'URL',
1284
+ 'urn' => 'URN',
1285
+ 'md5' => 'md5',
1286
+ 'minid' => 'minid',
1287
+ 'dataguid' => 'dataguid'
1227
1288
  }
1228
1289
 
1229
1290
  identifierTypes[identifier_type.downcase] || identifier_type
@@ -1232,26 +1293,27 @@ module Briard
1232
1293
  def get_series_information(str)
1233
1294
  return {} unless str.present?
1234
1295
 
1235
- str = str.split(",").map(&:strip)
1296
+ str = str.split(',').map(&:strip)
1236
1297
 
1237
1298
  title = str.first
1238
1299
  volume_issue = str.length > 2 ? str[1].rpartition(/\(([^)]+)\)/) : nil
1239
1300
  volume = volume_issue.present? ? volume_issue[0].presence || volume_issue[2].presence : nil
1240
1301
  issue = volume_issue.present? ? volume_issue[1][1...-1].presence : nil
1241
1302
  pages = str.length > 1 ? str.last : nil
1242
- first_page = pages.present? ? pages.split("-").map(&:strip)[0] : nil
1243
- last_page = pages.present? ? pages.split("-").map(&:strip)[1] : nil
1303
+ first_page = pages.present? ? pages.split('-').map(&:strip)[0] : nil
1304
+ last_page = pages.present? ? pages.split('-').map(&:strip)[1] : nil
1244
1305
 
1245
1306
  {
1246
- "title" => title,
1247
- "volume" => volume,
1248
- "issue" => issue,
1249
- "firstPage" => first_page,
1250
- "lastPage" => last_page }.compact
1307
+ 'title' => title,
1308
+ 'volume' => volume,
1309
+ 'issue' => issue,
1310
+ 'firstPage' => first_page,
1311
+ 'lastPage' => last_page
1312
+ }.compact
1251
1313
  end
1252
1314
 
1253
1315
  def jsonlint(json)
1254
- return ["No JSON provided"] unless json.present?
1316
+ return ['No JSON provided'] unless json.present?
1255
1317
 
1256
1318
  error_array = []
1257
1319
  linter = JsonLint::Linter.new
@@ -1260,149 +1322,172 @@ module Briard
1260
1322
  end
1261
1323
 
1262
1324
  def name_to_spdx(name)
1263
- spdx = JSON.load(File.read(File.expand_path('../../../resources/spdx/licenses.json', __FILE__))).fetch("licenses")
1264
- license = spdx.find { |l| l["name"] == name || l["licenseId"] == name || l["seeAlso"].first == normalize_cc_url(name) }
1325
+ spdx = JSON.load(File.read(File.expand_path('../../resources/spdx/licenses.json',
1326
+ __dir__))).fetch('licenses')
1327
+ license = spdx.find do |l|
1328
+ l['name'] == name || l['licenseId'] == name || l['seeAlso'].first == normalize_cc_url(name)
1329
+ end
1265
1330
 
1266
1331
  if license
1267
1332
  {
1268
- "rights" => license["name"],
1269
- "rightsUri" => license["seeAlso"].first,
1270
- "rightsIdentifier" => license["licenseId"].downcase,
1271
- "rightsIdentifierScheme" => "SPDX",
1272
- "schemeUri" => "https://spdx.org/licenses/" }.compact
1333
+ 'rights' => license['name'],
1334
+ 'rightsUri' => license['seeAlso'].first,
1335
+ 'rightsIdentifier' => license['licenseId'].downcase,
1336
+ 'rightsIdentifierScheme' => 'SPDX',
1337
+ 'schemeUri' => 'https://spdx.org/licenses/'
1338
+ }.compact
1273
1339
  else
1274
- { "rights" => name }
1340
+ { 'rights' => name }
1275
1341
  end
1276
1342
  end
1277
1343
 
1278
1344
  def hsh_to_spdx(hsh)
1279
- spdx = JSON.load(File.read(File.expand_path('../../../resources/spdx/licenses.json', __FILE__))).fetch("licenses")
1280
- license = spdx.find { |l| l["licenseId"].casecmp?(hsh["rightsIdentifier"]) || l["seeAlso"].first == normalize_cc_url(hsh["rightsURI"]) || l["name"] == hsh["rights"] || l["seeAlso"].first == normalize_cc_url(hsh["rights"]) }
1345
+ spdx = JSON.load(File.read(File.expand_path('../../resources/spdx/licenses.json',
1346
+ __dir__))).fetch('licenses')
1347
+ license = spdx.find do |l|
1348
+ l['licenseId'].casecmp?(hsh['rightsIdentifier']) || l['seeAlso'].first == normalize_cc_url(hsh['rightsURI']) || l['name'] == hsh['rights'] || l['seeAlso'].first == normalize_cc_url(hsh['rights'])
1349
+ end
1281
1350
 
1282
1351
  if license
1283
1352
  {
1284
- "rights" => license["name"],
1285
- "rightsUri" => license["seeAlso"].first,
1286
- "rightsIdentifier" => license["licenseId"].downcase,
1287
- "rightsIdentifierScheme" => "SPDX",
1288
- "schemeUri" => "https://spdx.org/licenses/",
1289
- "lang" => hsh["lang"] }.compact
1353
+ 'rights' => license['name'],
1354
+ 'rightsUri' => license['seeAlso'].first,
1355
+ 'rightsIdentifier' => license['licenseId'].downcase,
1356
+ 'rightsIdentifierScheme' => 'SPDX',
1357
+ 'schemeUri' => 'https://spdx.org/licenses/',
1358
+ 'lang' => hsh['lang']
1359
+ }.compact
1290
1360
  else
1291
1361
  {
1292
- "rights" => hsh["__content__"] || hsh["rights"],
1293
- "rightsUri" => hsh["rightsURI"] || hsh["rightsUri"],
1294
- "rightsIdentifier" => hsh["rightsIdentifier"].present? ? hsh["rightsIdentifier"].downcase : nil,
1295
- "rightsIdentifierScheme" => hsh["rightsIdentifierScheme"],
1296
- "schemeUri" => hsh["schemeUri"],
1297
- "lang" => hsh["lang"] }.compact
1362
+ 'rights' => hsh['__content__'] || hsh['rights'],
1363
+ 'rightsUri' => hsh['rightsURI'] || hsh['rightsUri'],
1364
+ 'rightsIdentifier' => hsh['rightsIdentifier'].present? ? hsh['rightsIdentifier'].downcase : nil,
1365
+ 'rightsIdentifierScheme' => hsh['rightsIdentifierScheme'],
1366
+ 'schemeUri' => hsh['schemeUri'],
1367
+ 'lang' => hsh['lang']
1368
+ }.compact
1298
1369
  end
1299
1370
  end
1300
1371
 
1301
1372
  def name_to_fos(name)
1302
1373
  # first find subject in Fields of Science (OECD)
1303
- fos = JSON.load(File.read(File.expand_path('../../../resources/oecd/fos-mappings.json', __FILE__))).fetch("fosFields")
1374
+ fos = JSON.load(File.read(File.expand_path('../../resources/oecd/fos-mappings.json',
1375
+ __dir__))).fetch('fosFields')
1304
1376
 
1305
- subject = fos.find { |l| l["fosLabel"] == name || "FOS: " + l["fosLabel"] == name }
1377
+ subject = fos.find { |l| l['fosLabel'] == name || 'FOS: ' + l['fosLabel'] == name }
1306
1378
 
1307
1379
  if subject
1308
1380
  return [{
1309
- "subject" => sanitize(name).downcase
1381
+ 'subject' => sanitize(name).downcase
1310
1382
  },
1311
- {
1312
- "subject" => "FOS: " + subject["fosLabel"],
1313
- "subjectScheme" => "Fields of Science and Technology (FOS)",
1314
- "schemeUri" => "http://www.oecd.org/science/inno/38235147.pdf"
1315
- }]
1383
+ {
1384
+ 'subject' => 'FOS: ' + subject['fosLabel'],
1385
+ 'subjectScheme' => 'Fields of Science and Technology (FOS)',
1386
+ 'schemeUri' => 'http://www.oecd.org/science/inno/38235147.pdf'
1387
+ }]
1316
1388
  end
1317
1389
 
1318
1390
  # if not found, look in Fields of Research (Australian and New Zealand Standard Research Classification)
1319
1391
  # and map to Fields of Science. Add an extra entry for the latter
1320
- fores = JSON.load(File.read(File.expand_path('../../../resources/oecd/for-mappings.json', __FILE__)))
1321
- for_fields = fores.fetch("forFields")
1322
- for_disciplines = fores.fetch("forDisciplines")
1392
+ fores = JSON.load(File.read(File.expand_path('../../resources/oecd/for-mappings.json',
1393
+ __dir__)))
1394
+ for_fields = fores.fetch('forFields')
1395
+ for_disciplines = fores.fetch('forDisciplines')
1323
1396
 
1324
- subject = for_fields.find { |l| l["forLabel"] == name } ||
1325
- for_disciplines.find { |l| l["forLabel"] == name }
1397
+ subject = for_fields.find { |l| l['forLabel'] == name } ||
1398
+ for_disciplines.find { |l| l['forLabel'] == name }
1326
1399
 
1327
1400
  if subject
1328
1401
  [{
1329
- "subject" => sanitize(name).downcase
1402
+ 'subject' => sanitize(name).downcase
1330
1403
  },
1331
- {
1332
- "subject" => "FOS: " + subject["fosLabel"],
1333
- "subjectScheme" => "Fields of Science and Technology (FOS)",
1334
- "schemeUri" => "http://www.oecd.org/science/inno/38235147.pdf"
1335
- }]
1404
+ {
1405
+ 'subject' => 'FOS: ' + subject['fosLabel'],
1406
+ 'subjectScheme' => 'Fields of Science and Technology (FOS)',
1407
+ 'schemeUri' => 'http://www.oecd.org/science/inno/38235147.pdf'
1408
+ }]
1336
1409
  else
1337
- [{ "subject" => sanitize(name).downcase }]
1410
+ [{ 'subject' => sanitize(name).downcase }]
1338
1411
  end
1339
1412
  end
1340
1413
 
1341
1414
  def hsh_to_fos(hsh)
1342
1415
  # first find subject in Fields of Science (OECD)
1343
- fos = JSON.load(File.read(File.expand_path('../../../resources/oecd/fos-mappings.json', __FILE__))).fetch("fosFields")
1344
- subject = fos.find { |l| l["fosLabel"] == hsh["__content__"] || "FOS: " + l["fosLabel"] == hsh["__content__"] || l["fosLabel"] == hsh["subject"]}
1416
+ fos = JSON.load(File.read(File.expand_path('../../resources/oecd/fos-mappings.json',
1417
+ __dir__))).fetch('fosFields')
1418
+ subject = fos.find do |l|
1419
+ l['fosLabel'] == hsh['__content__'] || 'FOS: ' + l['fosLabel'] == hsh['__content__'] || l['fosLabel'] == hsh['subject']
1420
+ end
1345
1421
 
1346
1422
  if subject
1347
1423
  return [{
1348
- "subject" => sanitize(hsh["__content__"] || hsh["subject"]),
1349
- "subjectScheme" => hsh["subjectScheme"],
1350
- "schemeUri" => hsh["schemeURI"] || hsh["schemeUri"],
1351
- "valueUri" => hsh["valueURI"] || hsh["valueUri"],
1352
- "classificationCode" => hsh["classificationCode"],
1353
- "lang" => hsh["lang"] }.compact,
1354
- {
1355
- "subject" => "FOS: " + subject["fosLabel"],
1356
- "subjectScheme" => "Fields of Science and Technology (FOS)",
1357
- "schemeUri" => "http://www.oecd.org/science/inno/38235147.pdf" }.compact]
1424
+ 'subject' => sanitize(hsh['__content__'] || hsh['subject']),
1425
+ 'subjectScheme' => hsh['subjectScheme'],
1426
+ 'schemeUri' => hsh['schemeURI'] || hsh['schemeUri'],
1427
+ 'valueUri' => hsh['valueURI'] || hsh['valueUri'],
1428
+ 'classificationCode' => hsh['classificationCode'],
1429
+ 'lang' => hsh['lang']
1430
+ }.compact,
1431
+ {
1432
+ 'subject' => 'FOS: ' + subject['fosLabel'],
1433
+ 'subjectScheme' => 'Fields of Science and Technology (FOS)',
1434
+ 'schemeUri' => 'http://www.oecd.org/science/inno/38235147.pdf'
1435
+ }.compact]
1358
1436
  end
1359
1437
 
1360
1438
  # if not found, look in Fields of Research (Australian and New Zealand Standard Research Classification)
1361
1439
  # and map to Fields of Science. Add an extra entry for the latter
1362
- fores = JSON.load(File.read(File.expand_path('../../../resources/oecd/for-mappings.json', __FILE__)))
1363
- for_fields = fores.fetch("forFields")
1364
- for_disciplines = fores.fetch("forDisciplines")
1440
+ fores = JSON.load(File.read(File.expand_path('../../resources/oecd/for-mappings.json',
1441
+ __dir__)))
1442
+ for_fields = fores.fetch('forFields')
1443
+ for_disciplines = fores.fetch('forDisciplines')
1365
1444
 
1366
1445
  # try to extract forId
1367
- if hsh["subjectScheme"] == "FOR"
1368
- for_id = hsh["__content__"].to_s.split(" ").first || hsh["subject"].to_s.split(" ").first
1369
- for_id = for_id.rjust(6, "0")
1446
+ if hsh['subjectScheme'] == 'FOR'
1447
+ for_id = hsh['__content__'].to_s.split(' ').first || hsh['subject'].to_s.split(' ').first
1448
+ for_id = for_id.rjust(6, '0')
1370
1449
 
1371
- subject = for_fields.find { |l| l["forId"] == for_id } ||
1372
- for_disciplines.find { |l| l["forId"] == for_id[0..3] }
1450
+ subject = for_fields.find { |l| l['forId'] == for_id } ||
1451
+ for_disciplines.find { |l| l['forId'] == for_id[0..3] }
1373
1452
  else
1374
- subject = for_fields.find { |l| l["forLabel"] == hsh["__content__"] || l["forLabel"] == hsh["subject"] } ||
1375
- for_disciplines.find { |l| l["forLabel"] == hsh["__content__"] || l["forLabel"] == hsh["subject"] }
1453
+ subject = for_fields.find do |l|
1454
+ l['forLabel'] == hsh['__content__'] || l['forLabel'] == hsh['subject']
1455
+ end ||
1456
+ for_disciplines.find do |l|
1457
+ l['forLabel'] == hsh['__content__'] || l['forLabel'] == hsh['subject']
1458
+ end
1376
1459
  end
1377
1460
 
1378
1461
  if subject
1379
1462
  [{
1380
- "subject" => sanitize(hsh["__content__"] || hsh["subject"]),
1381
- "subjectScheme" => hsh["subjectScheme"],
1382
- "classificationCode" => hsh["classificationCode"],
1383
- "schemeUri" => hsh["schemeURI"] || hsh["schemeUri"],
1384
- "valueUri" => hsh["valueURI"] || hsh["valueUri"],
1385
- "lang" => hsh["lang"] }.compact,
1386
- {
1387
- "subject" => "FOS: " + subject["fosLabel"],
1388
- "subjectScheme" => "Fields of Science and Technology (FOS)",
1389
- "schemeUri" => "http://www.oecd.org/science/inno/38235147.pdf"
1390
- }]
1463
+ 'subject' => sanitize(hsh['__content__'] || hsh['subject']),
1464
+ 'subjectScheme' => hsh['subjectScheme'],
1465
+ 'classificationCode' => hsh['classificationCode'],
1466
+ 'schemeUri' => hsh['schemeURI'] || hsh['schemeUri'],
1467
+ 'valueUri' => hsh['valueURI'] || hsh['valueUri'],
1468
+ 'lang' => hsh['lang']
1469
+ }.compact,
1470
+ {
1471
+ 'subject' => 'FOS: ' + subject['fosLabel'],
1472
+ 'subjectScheme' => 'Fields of Science and Technology (FOS)',
1473
+ 'schemeUri' => 'http://www.oecd.org/science/inno/38235147.pdf'
1474
+ }]
1391
1475
  else
1392
1476
  [{
1393
- "subject" => sanitize(hsh["__content__"] || hsh["subject"]),
1394
- "subjectScheme" => hsh["subjectScheme"],
1395
- "classificationCode" => hsh["classificationCode"],
1396
- "schemeUri" => hsh["schemeURI"] || hsh["schemeUri"],
1397
- "valueUri" => hsh["valueURI"] || hsh["valueUri"],
1398
- "lang" => hsh["lang"] }.compact]
1477
+ 'subject' => sanitize(hsh['__content__'] || hsh['subject']),
1478
+ 'subjectScheme' => hsh['subjectScheme'],
1479
+ 'classificationCode' => hsh['classificationCode'],
1480
+ 'schemeUri' => hsh['schemeURI'] || hsh['schemeUri'],
1481
+ 'valueUri' => hsh['valueURI'] || hsh['valueUri'],
1482
+ 'lang' => hsh['lang']
1483
+ }.compact]
1399
1484
  end
1400
1485
  end
1401
1486
 
1402
1487
  def encode_doi(prefix)
1403
- random_int = SecureRandom.random_number(2**63..2**64-1)
1488
+ random_int = SecureRandom.random_number(2**63..(2**64) - 1)
1404
1489
  suffix = Base32::URL.encode(random_int)
1405
- str = "#{suffix[0,7]}-#{suffix[6,7]}"
1490
+ str = "#{suffix[0, 7]}-#{suffix[6, 7]}"
1406
1491
  "https://doi.org/#{prefix}/#{str}"
1407
1492
  end
1408
1493