bolognese 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (322) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +16 -16
  3. data/README.md +9 -0
  4. data/lib/bolognese.rb +0 -8
  5. data/lib/bolognese/array.rb +2 -2
  6. data/lib/bolognese/author_utils.rb +18 -6
  7. data/lib/bolognese/cli.rb +2 -17
  8. data/lib/bolognese/datacite_utils.rb +8 -7
  9. data/lib/bolognese/metadata.rb +291 -178
  10. data/lib/bolognese/readers/bibtex_reader.rb +66 -0
  11. data/lib/bolognese/readers/citeproc_reader.rb +74 -0
  12. data/lib/bolognese/readers/codemeta_reader.rb +71 -0
  13. data/lib/bolognese/readers/crosscite_reader.rb +12 -0
  14. data/lib/bolognese/readers/crossref_reader.rb +209 -0
  15. data/lib/bolognese/readers/datacite_json_reader.rb +75 -0
  16. data/lib/bolognese/readers/datacite_reader.rb +181 -0
  17. data/lib/bolognese/readers/ris_reader.rb +84 -0
  18. data/lib/bolognese/readers/schema_org_reader.rb +119 -0
  19. data/lib/bolognese/utils.rb +42 -67
  20. data/lib/bolognese/version.rb +1 -1
  21. data/lib/bolognese/writers/bibtex_writer.rb +25 -0
  22. data/lib/bolognese/writers/citeproc_writer.rb +29 -0
  23. data/lib/bolognese/writers/codemeta_writer.rb +25 -0
  24. data/lib/bolognese/writers/crosscite_writer.rb +49 -0
  25. data/lib/bolognese/writers/crossref_writer.rb +9 -0
  26. data/lib/bolognese/writers/datacite_json_writer.rb +45 -0
  27. data/lib/bolognese/writers/datacite_writer.rb +10 -0
  28. data/lib/bolognese/writers/rdf_xml_writer.rb +9 -0
  29. data/lib/bolognese/writers/ris_writer.rb +26 -0
  30. data/lib/bolognese/writers/schema_org_writer.rb +45 -0
  31. data/lib/bolognese/writers/turtle_writer.rb +9 -0
  32. data/spec/author_utils_spec.rb +74 -34
  33. data/spec/cli_spec.rb +6 -6
  34. data/spec/datacite_utils_spec.rb +10 -11
  35. data/spec/doi_utils_spec.rb +2 -1
  36. data/spec/fixtures/crossref.ris +2 -1
  37. data/spec/fixtures/datacite.json +6 -9
  38. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/default.yml +9 -7
  39. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_bibtex.yml +9 -7
  40. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_crossref.yml +6 -6
  41. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_datacite.yml +6 -6
  42. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/crossref/to_schema_org.yml +8 -6
  43. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/default.yml +10 -6
  44. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_bibtex.yml +8 -6
  45. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_datacite.yml +11 -7
  46. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_datacite_json.yml +10 -6
  47. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_schema_org.yml +10 -6
  48. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/default.yml +201 -200
  49. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/to_bibtex.yml +201 -200
  50. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/to_datacite.yml +201 -200
  51. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/schema_org/to_schema_org.yml +201 -200
  52. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/is_personal_name_/has_type_organization.yml → Bolognese_Metadata/authors_as_string/author.yml} +61 -2
  53. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/authors_as_string/single_author.yml → Bolognese_Metadata/authors_as_string/no_author.yml} +60 -3
  54. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/authors_as_string/single_author.yml +203 -0
  55. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/authors_as_string/with_organization.yml +203 -0
  56. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_from_url/doi.yml +203 -0
  57. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_from_url/not_a_doi.yml +203 -0
  58. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_from_url/url.yml +203 -0
  59. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/crossref.yml +204 -6
  60. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/datacite.yml +204 -4
  61. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/medra.yml +204 -4
  62. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/not_a_valid_prefix.yml +203 -0
  63. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/doi_registration_agency/not_found.yml +204 -4
  64. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/crossref.yml +102 -4
  65. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/crossref_doi_not_url.yml +100 -4
  66. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/datacite.yml +102 -4
  67. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/datacite_doi_http.yml +100 -4
  68. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/github.yml +97 -0
  69. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_by_ID/orcid.yml +99 -0
  70. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_name_identifier/has_ORCID.yml → Bolognese_Metadata/find_from_format_by_ID/schema_org.yml} +61 -2
  71. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/bibtex.yml +99 -0
  72. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/citeproc.yml +99 -0
  73. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_one_author/has_familyName.yml → Bolognese_Metadata/find_from_format_from_file/codemeta.yml} +61 -2
  74. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/crossref.yml +99 -0
  75. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/datacite.yml +99 -0
  76. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/datacite_json.yml +99 -0
  77. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/ris.yml +99 -0
  78. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_from_format_from_file/schema_org.yml +97 -0
  79. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/is_personal_name_/has_no_info.yml → Bolognese_Metadata/from_schema_org/with_id.yml} +59 -2
  80. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata → Bolognese_Metadata/get_codemeta_metadata}/maremma.yml +9 -9
  81. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata → Bolognese_Metadata/get_codemeta_metadata}/no_codemeta_json.yml +8 -8
  82. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata → Bolognese_Metadata/get_codemeta_metadata}/not_found_error.yml +8 -8
  83. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/DOI_with_ORCID_ID.yml +61 -2
  84. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/DOI_with_SICI_DOI.yml +62 -3
  85. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/DOI_with_data_citation.yml +61 -2
  86. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/date_in_future.yml +61 -2
  87. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata → Bolognese_Metadata/get_crossref_metadata}/journal_article.yml +62 -3
  88. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/not_found_error.yml +97 -0
  89. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_crossref_metadata/posted_content.yml +203 -0
  90. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/BlogPosting.yml +99 -0
  91. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Dataset.yml +99 -0
  92. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/Funding_schema_version_4.yml +97 -0
  93. data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata → Bolognese_Metadata/get_datacite_metadata}/author_only_full_name.yml +61 -2
  94. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/author_with_scheme.yml +97 -0
  95. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_name_identifier/has_no_ORCID.yml → Bolognese_Metadata/get_datacite_metadata/date.yml} +63 -2
  96. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/funding_schema_version_3.yml +99 -0
  97. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_datacite_metadata/is_identical_to.yml +99 -0
  98. data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata → Bolognese_Metadata/get_datacite_metadata}/keywords_with_attributes.yml +64 -3
  99. data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata → Bolognese_Metadata/get_datacite_metadata}/multiple_author_names_in_one_creatorName.yml +63 -2
  100. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_one_author/has_name_in_display-order.yml → Bolognese_Metadata/get_datacite_metadata/multiple_licenses.yml} +63 -2
  101. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata/posted_content.yml → Bolognese_Metadata/get_date_from_date_parts/date.yml} +59 -2
  102. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_from_date_parts/year-month.yml +203 -0
  103. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_from_date_parts/year.yml +203 -0
  104. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_parts/date.yml +203 -0
  105. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_parts/year-month.yml +203 -0
  106. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date_parts/year.yml +201 -0
  107. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_name_identifier/has_ORCID.yml +136 -0
  108. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_name_identifier/has_jacow_org_scheme.yml +136 -0
  109. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_name_identifier/has_no_ORCID.yml +136 -0
  110. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_familyName.yml +136 -0
  111. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_multiple_names_in_display-order.yml +136 -0
  112. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_name_in_Thai.yml +134 -0
  113. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_name_in_display-order.yml +136 -0
  114. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_name_in_display-order_with_ORCID.yml +136 -0
  115. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/has_name_in_sort-order.yml +136 -0
  116. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/hyper-authorship.yml +132 -0
  117. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/is_organization.yml +203 -0
  118. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/multiple_author_names_in_one_field.yml +136 -0
  119. data/spec/fixtures/vcr_cassettes/{Bolognese_SchemaOrg/get_metadata → Bolognese_Metadata/get_schema_org_metadata}/BlogPosting.yml +201 -200
  120. data/spec/fixtures/vcr_cassettes/{Bolognese_SchemaOrg/get_metadata → Bolognese_Metadata/get_schema_org_metadata}/not_found_error.yml +2 -2
  121. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_alternate_identifiers/insert.yml +97 -0
  122. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_contributors/none.yml +99 -0
  123. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_creators/insert.yml +99 -0
  124. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_dates/insert.yml +99 -0
  125. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_descriptions/insert.yml +99 -0
  126. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_identifier/doi.yml +99 -0
  127. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_person/creator_only_name.yml +99 -0
  128. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_publication_year/insert.yml +99 -0
  129. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_publisher/insert.yml +99 -0
  130. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers/insert.yml +99 -0
  131. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_related_identifiers/related_identifier.yml +99 -0
  132. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_resource_type/insert.yml +99 -0
  133. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_rights_list/insert.yml +97 -0
  134. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_subjects/insert.yml +99 -0
  135. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_titles/insert.yml +99 -0
  136. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_version/insert.yml +97 -0
  137. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/is_personal_name_/has_comma.yml +203 -0
  138. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref → Bolognese_Metadata}/is_personal_name_/has_family_name.yml +61 -2
  139. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/is_personal_name_/has_id.yml +201 -0
  140. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref → Bolognese_Metadata}/is_personal_name_/has_known_given_name.yml +61 -2
  141. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/is_personal_name_/has_type_person.yml → Bolognese_Metadata/is_personal_name_/has_no_info.yml} +61 -2
  142. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/is_personal_name_/has_type_organization.yml +203 -0
  143. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/missing_comma.yml +99 -0
  144. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/nil.yml +99 -0
  145. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/overlapping_keys.yml +97 -0
  146. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/jsonlint/valid.yml +99 -0
  147. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/authors_as_string/author.yml → Bolognese_Metadata/normalize_doi/SICI_doi.yml} +59 -2
  148. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/doi.yml +203 -0
  149. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/doi_from_url_without_doi_proxy.yml +203 -0
  150. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/doi_prefix_too_long.yml +203 -0
  151. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/doi_prefix_with_string.yml +203 -0
  152. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/authors_as_string/no_author.yml → Bolognese_Metadata/normalize_doi/doi_with_protocol.yml} +59 -2
  153. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/dx_doi_org_url.yml +203 -0
  154. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/https_url.yml +203 -0
  155. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/not_valid_doi_prefix.yml +203 -0
  156. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_doi/url_with_one_slash.yml +203 -0
  157. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/doi.yml +203 -0
  158. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/doi_as_url.yml +203 -0
  159. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/ftp.yml +203 -0
  160. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/invalid_url.yml +203 -0
  161. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/string.yml +203 -0
  162. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_one_author/is_organization.yml → Bolognese_Metadata/normalize_id/url.yml} +59 -2
  163. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_id/url_with_utf-8.yml +203 -0
  164. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_ids/doi.yml +203 -0
  165. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/normalize_ids/url.yml +203 -0
  166. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/is_personal_name_/has_comma.yml → Bolognese_Metadata/normalize_url/uri.yml} +2 -2
  167. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/authors_as_string/with_organization.yml → Bolognese_Metadata/normalize_url/with_trailing_slash.yml} +2 -2
  168. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/parse_attributes/array.yml +203 -0
  169. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/is_personal_name_/has_id.yml → Bolognese_Metadata/parse_attributes/hash.yml} +59 -2
  170. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/parse_attributes/nil.yml +203 -0
  171. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/parse_attributes/string.yml +203 -0
  172. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/sanitize/should_only_keep_specific_tags.yml +203 -0
  173. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/sanitize/should_remove_a_tags.yml +203 -0
  174. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/to_schema_org/with_id.yml +203 -0
  175. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/validate_url/DOI.yml +203 -0
  176. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/validate_url/ISSN.yml +203 -0
  177. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/validate_url/URL.yml +203 -0
  178. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/validate_url/string.yml +203 -0
  179. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_bibtex/BlogPosting.yml +99 -0
  180. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_bibtex/Dataset.yml +99 -0
  181. data/spec/fixtures/vcr_cassettes/{Bolognese_SchemaOrg/get_metadata/BlogPosting_schema_org_JSON.yml → Bolognese_Metadata/write_metadata_as_bibtex/from_schema_org.yml} +201 -200
  182. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_datacite_xml → Bolognese_Metadata/write_metadata_as_bibtex}/maremma.yml +9 -9
  183. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_bibtex/with_data_citation.yml +731 -0
  184. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_citeproc → Bolognese_Metadata/write_metadata_as_bibtex}/with_pages.yml +61 -2
  185. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/BlogPosting.yml +99 -0
  186. data/spec/fixtures/vcr_cassettes/{Bolognese_SchemaOrg/get_metadata_as_bibtex/with_data_citation.yml → Bolognese_Metadata/write_metadata_as_citeproc/BlogPosting_schema_org.yml} +201 -200
  187. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_citeproc/Dataset.yml +99 -0
  188. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_citeproc → Bolognese_Metadata/write_metadata_as_citeproc}/journal_article.yml +62 -3
  189. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_ris → Bolognese_Metadata/write_metadata_as_citeproc}/maremma.yml +8 -8
  190. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_ris → Bolognese_Metadata/write_metadata_as_citeproc}/with_pages.yml +61 -2
  191. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_codemeta/SoftwareSourceCode_DataCite.yml +99 -0
  192. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_bibtex → Bolognese_Metadata/write_metadata_as_crosscite}/maremma.yml +9 -9
  193. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_datacite_xml → Bolognese_Metadata/write_metadata_as_crosscite}/with_ORCID_ID.yml +61 -2
  194. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_crosscite/with_data_citation.yml +731 -0
  195. data/spec/fixtures/vcr_cassettes/{Bolognese_SchemaOrg/get_metadata_as_citeproc/BlogPosting.yml → Bolognese_Metadata/write_metadata_as_crosscite/with_data_citation_schema_org.yml} +201 -200
  196. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_datacite_xml → Bolognese_Metadata/write_metadata_as_crosscite}/with_editor.yml +62 -3
  197. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_one_author/has_name_in_sort-order.yml → Bolognese_Metadata/write_metadata_as_crossref/from_DataCite.yml} +61 -2
  198. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_json/maremma.yml +100 -0
  199. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_json/with_ORCID_ID.yml +377 -0
  200. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_datacite_xml → Bolognese_Metadata/write_metadata_as_datacite_json}/with_data_citation.yml +61 -2
  201. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_json/with_data_citation_schema_org.yml +654 -0
  202. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_xml/Dataset_in_schema_4_0.yml +97 -0
  203. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_citeproc → Bolognese_Metadata/write_metadata_as_datacite_xml}/maremma.yml +9 -9
  204. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_xml/with_ORCID_ID.yml +377 -0
  205. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_ris/journal_article.yml → Bolognese_Metadata/write_metadata_as_datacite_xml/with_data_citation.yml} +61 -2
  206. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_xml/with_data_citation_schema_org.yml +654 -0
  207. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_datacite_xml/with_editor.yml +944 -0
  208. data/spec/fixtures/vcr_cassettes/{Bolognese_DataciteJson/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_rdf_xml}/BlogPosting.yml +88 -23
  209. data/spec/fixtures/vcr_cassettes/{Bolognese_Citeproc/get_metadata_as_rdf_xml/BlogPosting.yml → Bolognese_Metadata/write_metadata_as_rdf_xml/BlogPosting_Citeproc_JSON.yml} +26 -20
  210. data/spec/fixtures/vcr_cassettes/{Bolognese_Bibtex/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_rdf_xml}/Crossref_DOI.yml +26 -20
  211. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_rdf_xml}/journal_article.yml +87 -22
  212. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_rdf_xml}/maremma.yml +35 -29
  213. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_turtle → Bolognese_Metadata/write_metadata_as_rdf_xml}/with_pages.yml +88 -23
  214. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_ris/BlogPosting.yml +99 -0
  215. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_ris/BlogPosting_schema_org.yml +654 -0
  216. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_ris/Dataset.yml +99 -0
  217. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_bibtex/with_data_citation.yml → Bolognese_Metadata/write_metadata_as_ris/journal_article.yml} +59 -2
  218. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_ris/maremma.yml +100 -0
  219. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_bibtex → Bolognese_Metadata/write_metadata_as_ris}/with_pages.yml +62 -3
  220. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_schema_org/Schema_org_JSON_IsSupplementTo.yml +99 -0
  221. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_schema_org/Schema_org_JSON_isReferencedBy.yml +99 -0
  222. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata/Schema_org_JSON.yml → Bolognese_Metadata/write_metadata_as_schema_org/journal_article.yml} +61 -2
  223. data/spec/fixtures/vcr_cassettes/{Bolognese_Codemeta/get_metadata → Bolognese_Metadata/write_metadata_as_schema_org}/maremma_schema_org_JSON.yml +9 -9
  224. data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_turtle}/BlogPosting.yml +88 -23
  225. data/spec/fixtures/vcr_cassettes/{Bolognese_Citeproc/get_metadata_as_turtle/BlogPosting.yml → Bolognese_Metadata/write_metadata_as_turtle/BlogPosting_Citeproc_JSON.yml} +26 -20
  226. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_turtle/BlogPosting_DataCite_JSON.yml +4589 -0
  227. data/spec/fixtures/vcr_cassettes/{Bolognese_Bibtex/get_metadata_as_turtle → Bolognese_Metadata/write_metadata_as_turtle}/Crossref_DOI.yml +26 -20
  228. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/write_metadata_as_turtle/DataONE.yml +4589 -0
  229. data/spec/fixtures/vcr_cassettes/{Bolognese_Datacite/get_metadata_as_turtle → Bolognese_Metadata/write_metadata_as_turtle}/Dataset.yml +88 -23
  230. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_turtle → Bolognese_Metadata/write_metadata_as_turtle}/journal_article.yml +87 -22
  231. data/spec/fixtures/vcr_cassettes/{Bolognese_Crossref/get_metadata_as_rdf_xml → Bolognese_Metadata/write_metadata_as_turtle}/with_pages.yml +87 -22
  232. data/spec/metadata_spec.rb +8 -2
  233. data/spec/readers/bibtex_reader_spec.rb +30 -0
  234. data/spec/readers/citeproc_reader_spec.rb +28 -0
  235. data/spec/readers/codemeta_reader_spec.rb +90 -0
  236. data/spec/readers/crossref_reader_spec.rb +142 -0
  237. data/spec/readers/datacite_json_reader_spec.rb +48 -0
  238. data/spec/readers/datacite_reader_spec.rb +215 -0
  239. data/spec/readers/ris_reader_spec.rb +32 -0
  240. data/spec/readers/schema_org_reader_spec.rb +63 -0
  241. data/spec/utils_spec.rb +24 -25
  242. data/spec/writers/bibtex_writer_spec.rb +102 -0
  243. data/spec/writers/citeproc_writer_spec.rb +138 -0
  244. data/spec/writers/codemeta_writer_spec.rb +36 -0
  245. data/spec/writers/crosscite_writer_spec.rb +81 -0
  246. data/spec/writers/crossref_writer_spec.rb +19 -0
  247. data/spec/writers/datacite_json_writer_spec.rb +74 -0
  248. data/spec/writers/datacite_writer_spec.rb +124 -0
  249. data/spec/writers/rdf_xml_writer_spec.rb +97 -0
  250. data/spec/writers/ris_writer_spec.rb +153 -0
  251. data/spec/writers/schema_org_writer_spec.rb +59 -0
  252. data/spec/writers/turtle_writer_spec.rb +82 -0
  253. metadata +213 -132
  254. data/codemeta.json +0 -39
  255. data/lib/bolognese/bibtex.rb +0 -163
  256. data/lib/bolognese/citeproc.rb +0 -120
  257. data/lib/bolognese/codemeta.rb +0 -153
  258. data/lib/bolognese/crossref.rb +0 -281
  259. data/lib/bolognese/datacite.rb +0 -288
  260. data/lib/bolognese/datacite_json.rb +0 -220
  261. data/lib/bolognese/ris.rb +0 -117
  262. data/lib/bolognese/schema_org.rb +0 -196
  263. data/spec/bibtex_spec.rb +0 -90
  264. data/spec/citeproc_spec.rb +0 -66
  265. data/spec/codemeta_spec.rb +0 -221
  266. data/spec/crossref_spec.rb +0 -348
  267. data/spec/datacite_json_spec.rb +0 -125
  268. data/spec/datacite_spec.rb +0 -406
  269. data/spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_schema_org_JSON/maremma.yml +0 -100
  270. data/spec/fixtures/vcr_cassettes/Bolognese_Codemeta/get_metadata_as_turtle/maremma.yml +0 -4680
  271. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/not_found_error.yml +0 -38
  272. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_string/DOI_with_data_citation.yml +0 -672
  273. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/author.yml +0 -38
  274. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/has_multiple_names_in_display-order.yml +0 -38
  275. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/has_name_in_Thai.yml +0 -38
  276. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/has_name_in_display-order_with_ORCID.yml +0 -38
  277. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/hyper-authorship.yml +0 -38
  278. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/multiple_author_names.yml +0 -38
  279. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/multiple_author_names_in_one_field.yml +0 -38
  280. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/BlogPosting.yml +0 -40
  281. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Dataset.yml +0 -40
  282. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Date.yml +0 -40
  283. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Funding_schema_version_3.yml +0 -40
  284. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Funding_schema_version_4.yml +0 -38
  285. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Schema_org_JSON_IsSupplementTo.yml +0 -40
  286. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Schema_org_JSON_isReferencedBy.yml +0 -40
  287. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/author.yml +0 -38
  288. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/author_with_scheme.yml +0 -38
  289. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/is_identical_to.yml +0 -40
  290. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/jsonlint.yml +0 -38
  291. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/multiple_licenses.yml +0 -40
  292. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_bibtex/BlogPosting.yml +0 -40
  293. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_bibtex/Dataset.yml +0 -40
  294. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_citeproc/BlogPosting.yml +0 -38
  295. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_citeproc/Dataset.yml +0 -40
  296. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_codemeta/SoftwareSourceCode.yml +0 -40
  297. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_datacite_xml_4_0/Dataset.yml +0 -40
  298. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_ris/BlogPosting.yml +0 -40
  299. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_ris/Dataset.yml +0 -40
  300. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_turtle/BlogPosting.yml +0 -4620
  301. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_alternate_identifiers/insert.yml +0 -38
  302. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_contributors/none.yml +0 -40
  303. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_creators/insert.yml +0 -40
  304. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_dates/insert.yml +0 -40
  305. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_descriptions/insert.yml +0 -38
  306. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_identifier/doi.yml +0 -40
  307. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_person/creator_only_name.yml +0 -38
  308. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_publication_year/insert.yml +0 -38
  309. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_publisher/insert.yml +0 -38
  310. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_related_identifiers/insert.yml +0 -38
  311. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_related_identifiers/related_identifier.yml +0 -40
  312. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_resource_type/insert.yml +0 -40
  313. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_rights_list/insert.yml +0 -40
  314. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_subjects/insert.yml +0 -40
  315. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_titles/insert.yml +0 -40
  316. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_version/insert.yml +0 -40
  317. data/spec/fixtures/vcr_cassettes/Bolognese_DataciteJson/get_metadata_as_turtle/BlogPosting.yml +0 -4583
  318. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/generate/datacite.yml +0 -40
  319. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/read/datacite.yml +0 -40
  320. data/spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_datacite_xml/with_data_citation.yml +0 -653
  321. data/spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata_as_ris/BlogPosting.yml +0 -653
  322. data/spec/schema_org_spec.rb +0 -151
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bolognese::Metadata, vcr: true do
4
+ let(:input) { fixture_path + "datacite.json" }
5
+
6
+ subject { Bolognese::Metadata.new(input: input) }
7
+
8
+ context "get datacite_json raw" do
9
+ it "BlogPosting" do
10
+ expect(subject.raw).to eq(IO.read(input))
11
+ end
12
+ end
13
+
14
+ context "get datacite_json metadata" do
15
+ it "BlogPosting" do
16
+ expect(subject.valid?).to be true
17
+ expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
18
+ expect(subject.type).to eq("ScholarlyArticle")
19
+ expect(subject.additional_type).to eq("BlogPosting")
20
+ expect(subject.resource_type_general).to eq("Text")
21
+ expect(subject.author).to eq("type"=>"Person", "id"=>"http://orcid.org/0000-0003-1419-2405", "name"=>"Fenner, Martin", "givenName"=>"Martin", "familyName"=>"Fenner")
22
+ expect(subject.title).to eq("Eating your own Dog Food")
23
+ expect(subject.alternate_name).to eq("type"=>"Local accession number", "name"=>"MS-49-3632-5083")
24
+ expect(subject.date_published).to eq("2016-12-20")
25
+ expect(subject.is_part_of).to eq("id"=>"https://doi.org/10.5438/0000-00ss")
26
+ expect(subject.references).to eq([{"id"=>"https://doi.org/10.5438/0012"}, {"id"=>"https://doi.org/10.5438/55e5-t5c0"}])
27
+ expect(subject.provider).to eq("DataCite")
28
+ end
29
+
30
+ it "SoftwareSourceCode missing_comma" do
31
+ input = fixture_path + "datacite_software_missing_comma.json"
32
+ subject = Bolognese::Metadata.new(input: input, from: "datacite_json")
33
+ expect(subject.valid?).to be false
34
+ expect(subject.errors).to eq(["expected comma, not a string at line 4, column 11 [parse.c:381]"])
35
+ json = JSON.parse(subject.codemeta)
36
+ expect(json).to be_nil
37
+ end
38
+
39
+ it "SoftwareSourceCode overlapping_keys" do
40
+ input = fixture_path + "datacite_software_overlapping_keys.json"
41
+ subject = Bolognese::Metadata.new(input: input, from: "datacite_json")
42
+ expect(subject.valid?).to be false
43
+ expect(subject.errors).to eq(["The same key is defined more than once: id"])
44
+ json = JSON.parse(subject.codemeta)
45
+ expect(json).to be_nil
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,215 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bolognese::Metadata, vcr: true do
4
+ let(:input) { "https://doi.org/10.5061/DRYAD.8515" }
5
+
6
+ subject { Bolognese::Metadata.new(input: input) }
7
+
8
+ context "get datacite raw" do
9
+ it "BlogPosting" do
10
+ input = fixture_path + 'datacite.xml'
11
+ subject = Bolognese::Metadata.new(input: input)
12
+ expect(subject.raw).to eq(IO.read(input))
13
+ end
14
+ end
15
+
16
+ context "get datacite metadata" do
17
+ it "Dataset" do
18
+ expect(subject.valid?).to be true
19
+ expect(subject.id).to eq("https://doi.org/10.5061/dryad.8515")
20
+ expect(subject.type).to eq("Dataset")
21
+ expect(subject.additional_type).to eq("DataPackage")
22
+ expect(subject.resource_type_general).to eq("Dataset")
23
+ expect(subject.author.length).to eq(8)
24
+ expect(subject.author.first).to eq("type"=>"Person", "name"=>"Benjamin Ollomo", "givenName"=>"Benjamin", "familyName"=>"Ollomo")
25
+ expect(subject.title).to eq("Data from: A new malaria agent in African hominids.")
26
+ expect(subject.alternate_name).to eq("type"=>"citation", "name"=>"Ollomo B, Durand P, Prugnolle F, Douzery EJP, Arnathau C, Nkoghe D, Leroy E, Renaud F (2009) A new malaria agent in African hominids. PLoS Pathogens 5(5): e1000446.")
27
+ expect(subject.license).to eq("id"=>"http://creativecommons.org/publicdomain/zero/1.0")
28
+ expect(subject.date_published).to eq("2011")
29
+ expect(subject.has_part).to eq([{"id"=>"https://doi.org/10.5061/dryad.8515/1"}, {"id"=>"https://doi.org/10.5061/dryad.8515/2"}])
30
+ expect(subject.is_referenced_by).to eq("id"=>"https://doi.org/10.1371/journal.ppat.1000446")
31
+ expect(subject.publisher).to eq("Dryad Digital Repository")
32
+ expect(subject.provider).to eq("DataCite")
33
+ expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3")
34
+ end
35
+
36
+ it "BlogPosting" do
37
+ input = "https://doi.org/10.5438/4K3M-NYVG"
38
+ subject = Bolognese::Metadata.new(input: input)
39
+ expect(subject.valid?).to be true
40
+ expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
41
+ expect(subject.type).to eq("ScholarlyArticle")
42
+ expect(subject.additional_type).to eq("BlogPosting")
43
+ expect(subject.resource_type_general).to eq("Text")
44
+ expect(subject.author).to eq("type"=>"Person", "id"=>"http://orcid.org/0000-0003-1419-2405", "name"=>"Fenner, Martin", "givenName"=>"Martin", "familyName"=>"Fenner")
45
+ expect(subject.title).to eq("Eating your own Dog Food")
46
+ expect(subject.alternate_name).to eq("type"=>"Local accession number", "name"=>"MS-49-3632-5083")
47
+ expect(subject.description["text"]).to start_with("Eating your own dog food")
48
+ expect(subject.date_published).to eq("2016-12-20")
49
+ expect(subject.date_modified).to eq("2016-12-20")
50
+ expect(subject.is_part_of).to eq("id"=>"https://doi.org/10.5438/0000-00ss")
51
+ expect(subject.references).to eq([{"id"=>"https://doi.org/10.5438/0012"}, {"id"=>"https://doi.org/10.5438/55e5-t5c0"}])
52
+ expect(subject.publisher).to eq("DataCite")
53
+ expect(subject.provider).to eq("DataCite")
54
+ expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-4")
55
+ end
56
+
57
+ it "date" do
58
+ input = "https://doi.org/10.4230/lipics.tqc.2013.93"
59
+ subject = Bolognese::Metadata.new(input: input)
60
+ expect(subject.valid?).to be true
61
+ expect(subject.id).to eq("https://doi.org/10.4230/lipics.tqc.2013.93")
62
+ expect(subject.type).to eq("ScholarlyArticle")
63
+ expect(subject.additional_type).to eq("ConferencePaper")
64
+ expect(subject.resource_type_general).to eq("Text")
65
+ expect(subject.author).to eq("type"=>"Person", "name"=>"Nathaniel Johnston", "givenName"=>"Nathaniel", "familyName"=>"Johnston")
66
+ expect(subject.title).to eq("The Minimum Size of Qubit Unextendible Product Bases")
67
+ expect(subject.description["text"]).to start_with("We investigate the problem of constructing unextendible product bases in the qubit case")
68
+ expect(subject.date_published).to eq("2013")
69
+ expect(subject.publisher).to eq("Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik GmbH, Wadern/Saarbruecken, Germany")
70
+ expect(subject.provider).to eq("DataCite")
71
+ expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-2.1")
72
+ end
73
+
74
+ it "multiple licenses" do
75
+ input = "https://doi.org/10.5281/ZENODO.48440"
76
+ subject = Bolognese::Metadata.new(input: input)
77
+ expect(subject.valid?).to be true
78
+ expect(subject.id).to eq("https://doi.org/10.5281/zenodo.48440")
79
+ expect(subject.type).to eq("SoftwareSourceCode")
80
+ expect(subject.additional_type).to eq("Software")
81
+ expect(subject.resource_type_general).to eq("Software")
82
+ expect(subject.author).to eq("type"=>"Person", "name"=>"Kristian Garza", "givenName"=>"Kristian", "familyName"=>"Garza")
83
+ expect(subject.title).to eq("Analysis Tools for Crossover Experiment of UI using Choice Architecture")
84
+ expect(subject.description["text"]).to start_with("This tools are used to analyse the data produced by the Crosssover Experiment")
85
+ expect(subject.license).to eq([{"name"=>"Open Access"}, {"id"=>"https://creativecommons.org/licenses/by-nc-sa/4.0", "name"=>"Creative Commons Attribution-NonCommercial-ShareAlike"}])
86
+ expect(subject.date_published).to eq("2016-03-27")
87
+ expect(subject.is_supplement_to).to eq("id"=>"https://github.com/kjgarza/frame_experiment_analysis/tree/v1.0")
88
+ expect(subject.publisher).to eq("Zenodo")
89
+ expect(subject.provider).to eq("DataCite")
90
+ expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3")
91
+ end
92
+
93
+ it "is identical to" do
94
+ input = "10.6084/M9.FIGSHARE.4234751.V1"
95
+ subject = Bolognese::Metadata.new(input: input)
96
+ expect(subject.valid?).to be true
97
+ expect(subject.id).to eq("https://doi.org/10.6084/m9.figshare.4234751.v1")
98
+ expect(subject.type).to eq("Dataset")
99
+ expect(subject.additional_type).to eq("Dataset")
100
+ expect(subject.resource_type_general).to eq("Dataset")
101
+ expect(subject.author.count).to eq(11)
102
+ expect(subject.author.first).to eq("type"=>"Person", "id"=>"http://orcid.org/0000-0002-2410-9671", "name"=>"Alexander Junge", "givenName"=>"Alexander", "familyName"=>"Junge")
103
+ expect(subject.title).to eq("RAIN v1")
104
+ expect(subject.description["text"]).to start_with("<b>RAIN: RNA–protein Association and Interaction Networks")
105
+ expect(subject.license).to eq("id"=>"https://creativecommons.org/licenses/by/4.0", "name"=>"CC-BY")
106
+ expect(subject.date_published).to eq("2016")
107
+ expect(subject.is_identical_to).to eq("id"=>"https://doi.org/10.6084/m9.figshare.4234751")
108
+ expect(subject.publisher).to eq("Figshare")
109
+ expect(subject.provider).to eq("DataCite")
110
+ expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3")
111
+ end
112
+
113
+ it "funding schema version 3" do
114
+ input = "https://doi.org/10.5281/ZENODO.1239"
115
+ subject = Bolognese::Metadata.new(input: input)
116
+ expect(subject.valid?).to be true
117
+ expect(subject.id).to eq("https://doi.org/10.5281/zenodo.1239")
118
+ expect(subject.type).to eq("Dataset")
119
+ expect(subject.additional_type).to eq("Dataset")
120
+ expect(subject.resource_type_general).to eq("Dataset")
121
+ expect(subject.author.length).to eq(4)
122
+ expect(subject.author.first).to eq("type"=>"Person", "name"=>"Najko Jahn", "givenName"=>"Najko", "familyName"=>"Jahn")
123
+ expect(subject.title).to eq("Publication FP7 Funding Acknowledgment - PLOS OpenAIRE")
124
+ expect(subject.description["text"]).to start_with("The dataset contains a sample of metadata describing papers")
125
+ expect(subject.date_published).to eq("2013-04-03")
126
+ expect(subject.publisher).to eq("OpenAIRE Orphan Record Repository")
127
+ expect(subject.funder).to eq("name" => "European Commission")
128
+ expect(subject.provider).to eq("DataCite")
129
+ expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3")
130
+ end
131
+
132
+ it "author only full name" do
133
+ input = "https://doi.org/10.14457/KMITL.RES.2006.17"
134
+ subject = Bolognese::Metadata.new(input: input)
135
+ expect(subject.valid?).to be true
136
+ expect(subject.id).to eq("https://doi.org/10.14457/kmitl.res.2006.17")
137
+ expect(subject.type).to eq("Dataset")
138
+ expect(subject.author.length).to eq(1)
139
+ expect(subject.author.first).to eq(["name", "กัญจนา แซ่เตียว"])
140
+ end
141
+
142
+ it "multiple author names in one creatorName" do
143
+ input = "https://doi.org/10.7910/DVN/EQTQYO"
144
+ subject = Bolognese::Metadata.new(input: input)
145
+ expect(subject.valid?).to be true
146
+ expect(subject.id).to eq("https://doi.org/10.7910/dvn/eqtqyo")
147
+ expect(subject.type).to eq("Dataset")
148
+ expect(subject.author.length).to eq(3)
149
+ expect(subject.author.first).to eq("type"=>"Person", "name"=>"Ryan Enos", "givenName"=>"Ryan", "familyName"=>"Enos")
150
+ end
151
+
152
+ it "author with scheme" do
153
+ input = "https://doi.org/10.18429/JACOW-IPAC2016-TUPMY003"
154
+ subject = Bolognese::Metadata.new(input: input)
155
+ expect(subject.valid?).to be true
156
+ expect(subject.id).to eq("https://doi.org/10.18429/jacow-ipac2016-tupmy003")
157
+ expect(subject.type).to eq("ScholarlyArticle")
158
+ expect(subject.author.length).to eq(12)
159
+ expect(subject.author.first).to eq("type"=>"Person", "id"=>"http://jacow.org/JACoW-00077389", "name"=>"Masashi Otani", "givenName"=>"Masashi", "familyName"=>"Otani")
160
+ end
161
+
162
+ it "keywords with attributes" do
163
+ input = "https://doi.org/10.21233/n34n5q"
164
+ subject = Bolognese::Metadata.new(input: input)
165
+ expect(subject.valid?).to be true
166
+ expect(subject.id).to eq("https://doi.org/10.21233/n34n5q")
167
+ expect(subject.keywords).to eq("Paleoecology")
168
+ end
169
+
170
+ it "Funding schema version 4" do
171
+ input = "https://doi.org/10.5438/6423"
172
+ subject = Bolognese::Metadata.new(input: input)
173
+ expect(subject.valid?).to be true
174
+ expect(subject.id).to eq("https://doi.org/10.5438/6423")
175
+ expect(subject.type).to eq("Collection")
176
+ expect(subject.additional_type).to eq("Project")
177
+ expect(subject.resource_type_general).to eq("Collection")
178
+ expect(subject.author.length).to eq(24)
179
+ expect(subject.author.first).to eq("type"=>"Person", "id"=>"http://orcid.org/0000-0001-5331-6592", "name"=>"Farquhar, Adam", "givenName"=>"Adam", "familyName"=>"Farquhar")
180
+ expect(subject.title).to eq("Technical and Human Infrastructure for Open Research (THOR)")
181
+ expect(subject.description["text"]).to start_with("Five years ago, a global infrastructure")
182
+ expect(subject.date_published).to eq("2015")
183
+ expect(subject.publisher).to eq("DataCite")
184
+ expect(subject.funder).to eq("identifier"=>"https://doi.org/10.13039/501100000780", "name"=>"European Commission")
185
+ expect(subject.provider).to eq("DataCite")
186
+ expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-4")
187
+ end
188
+
189
+ it "BlogPosting from string" do
190
+ input = fixture_path + "datacite.xml"
191
+ subject = Bolognese::Metadata.new(input: input)
192
+ expect(subject.valid?).to be true
193
+ expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
194
+ expect(subject.type).to eq("ScholarlyArticle")
195
+ expect(subject.additional_type).to eq("BlogPosting")
196
+ expect(subject.resource_type_general).to eq("Text")
197
+ expect(subject.author).to eq("type"=>"Person", "id"=>"http://orcid.org/0000-0003-1419-2405", "name"=>"Fenner, Martin", "givenName"=>"Martin", "familyName"=>"Fenner")
198
+ expect(subject.title).to eq("Eating your own Dog Food")
199
+ expect(subject.alternate_name).to eq("type"=>"Local accession number", "name"=>"MS-49-3632-5083")
200
+ expect(subject.date_published).to eq("2016-12-20")
201
+ expect(subject.is_part_of).to eq("id"=>"https://doi.org/10.5438/0000-00ss")
202
+ expect(subject.references).to eq([{"id"=>"https://doi.org/10.5438/0012"}, {"id"=>"https://doi.org/10.5438/55e5-t5c0"}])
203
+ expect(subject.provider).to eq("DataCite")
204
+ end
205
+
206
+ # it "missing creator" do
207
+ # string = IO.read(fixture_path + "datacite_missing_creator.xml")
208
+ # subject = Bolognese::Metadata.new(string: string, regenerate: true)
209
+ # expect(subject.valid?).to be true
210
+ # expect(subject.datacite_errors).to eq(2)
211
+ # expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
212
+ # expect(subject.errors).to eq("Element '{http://datacite.org/schema/kernel-4}creators': Missing child element(s). Expected is ( {http://datacite.org/schema/kernel-4}creator ).")
213
+ # end
214
+ end
215
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bolognese::Metadata, vcr: true do
4
+ let(:input) { fixture_path + "crossref.ris" }
5
+
6
+ subject { Bolognese::Metadata.new(input: input) }
7
+
8
+ context "get ris raw" do
9
+ it "Crossref DOI" do
10
+ expect(subject.raw).to eq(IO.read(input))
11
+ end
12
+ end
13
+
14
+ context "get ris metadata" do
15
+ it "Crossref DOI" do
16
+ expect(subject.valid?).to be true
17
+ expect(subject.id).to eq("https://doi.org/10.7554/elife.01567")
18
+ expect(subject.type).to eq("ScholarlyArticle")
19
+ expect(subject.url).to eq("http://elifesciences.org/lookup/doi/10.7554/eLife.01567")
20
+ expect(subject.resource_type_general).to eq("Text")
21
+ expect(subject.author.length).to eq(5)
22
+ expect(subject.author.first).to eq("type"=>"Person",
23
+ "name"=>"Martial Sankar",
24
+ "givenName"=>"Martial",
25
+ "familyName"=>"Sankar")
26
+ expect(subject.title).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
27
+ expect(subject.description["text"]).to start_with("Among various advantages, their small size makes model organisms preferred subjects of investigation.")
28
+ expect(subject.date_published).to eq("2014")
29
+ expect(subject.is_part_of).to eq("type"=>"Periodical", "name"=>"eLife")
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bolognese::Metadata, vcr: true do
4
+ let(:input) { "https://blog.datacite.org/eating-your-own-dog-food/" }
5
+ let(:fixture_path) { "spec/fixtures/" }
6
+
7
+ subject { Bolognese::Metadata.new(input: input) }
8
+
9
+ context "get ris raw" do
10
+ it "BlogPosting" do
11
+ input = fixture_path + 'schema_org.json'
12
+ subject = Bolognese::Metadata.new(input: input)
13
+ expect(subject.raw).to eq(IO.read(input))
14
+ end
15
+ end
16
+
17
+ context "get schema_org metadata" do
18
+ it "BlogPosting" do
19
+ expect(subject.valid?).to be true
20
+ expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
21
+ expect(subject.url).to eq("https://blog.datacite.org/eating-your-own-dog-food")
22
+ expect(subject.type).to eq("BlogPosting")
23
+ expect(subject.author).to eq("type"=>"Person", "id"=>"http://orcid.org/0000-0003-1419-2405", "name"=>"Martin Fenner", "givenName"=>"Martin", "familyName"=>"Fenner")
24
+ expect(subject.title).to eq("Eating your own Dog Food")
25
+ expect(subject.alternate_name).to eq("MS-49-3632-5083")
26
+ expect(subject.description["text"]).to start_with("Eating your own dog food")
27
+ expect(subject.keywords).to eq("datacite, doi, metadata, featured")
28
+ expect(subject.date_published).to eq("2016-12-20")
29
+ expect(subject.date_modified).to eq("2016-12-20")
30
+ expect(subject.is_part_of).to eq("id"=>"https://doi.org/10.5438/0000-00ss", "type"=>"Blog", "name"=>"DataCite Blog")
31
+ expect(subject.references).to eq([{"id"=>"https://doi.org/10.5438/0012", "type"=>"CreativeWork"}, {"id"=>"https://doi.org/10.5438/55e5-t5c0", "type"=>"CreativeWork"}])
32
+ expect(subject.publisher).to eq("DataCite")
33
+ end
34
+
35
+ it "not found error" do
36
+ input = "https://doi.org/10.5438/4K3M-NYVGx"
37
+ subject = Bolognese::Metadata.new(input: input, from: "schema_org")
38
+ expect(subject.id).to be_nil
39
+ expect(subject.exists?).to be false
40
+ end
41
+ end
42
+
43
+ context "get schema_org metadata as string" do
44
+ it "BlogPosting" do
45
+ input = fixture_path + 'schema_org.json'
46
+ subject = Bolognese::Metadata.new(input: input)
47
+
48
+ expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
49
+ expect(subject.url).to eq("https://blog.datacite.org/eating-your-own-dog-food")
50
+ expect(subject.type).to eq("BlogPosting")
51
+ expect(subject.author).to eq("type"=>"Person", "id"=>"http://orcid.org/0000-0003-1419-2405", "name"=>"Martin Fenner", "givenName"=>"Martin", "familyName"=>"Fenner")
52
+ expect(subject.title).to eq("Eating your own Dog Food")
53
+ expect(subject.alternate_name).to eq("MS-49-3632-5083")
54
+ expect(subject.description["text"]).to start_with("Eating your own dog food")
55
+ expect(subject.keywords).to eq("datacite, doi, metadata, featured")
56
+ expect(subject.date_published).to eq("2016-12-20")
57
+ expect(subject.date_modified).to eq("2016-12-20")
58
+ expect(subject.is_part_of).to eq("id"=>"https://doi.org/10.5438/0000-00ss", "type"=>"Blog", "name"=>"DataCite Blog")
59
+ expect(subject.references).to eq([{"id"=>"https://doi.org/10.5438/0012", "type"=>"CreativeWork"}, {"id"=>"https://doi.org/10.5438/55e5-t5c0", "type"=>"CreativeWork"}])
60
+ expect(subject.publisher).to eq("DataCite")
61
+ end
62
+ end
63
+ end
data/spec/utils_spec.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Bolognese::Metadata, vcr: true do
4
+ let(:input) { "https://doi.org/10.1101/097196" }
4
5
 
5
- subject { Bolognese::Metadata.new }
6
+ subject { Bolognese::Metadata.new(input: input, from: "crossref") }
6
7
 
7
8
  context "validate url" do
8
9
  it "DOI" do
@@ -17,6 +18,12 @@ describe Bolognese::Metadata, vcr: true do
17
18
  expect(response).to eq("URL")
18
19
  end
19
20
 
21
+ it "ISSN" do
22
+ str = "ISSN 2050-084X"
23
+ response = subject.validate_url(str)
24
+ expect(response).to eq("ISSN")
25
+ end
26
+
20
27
  it "string" do
21
28
  str = "eating-your-own-dog-food"
22
29
  response = subject.validate_url(str)
@@ -98,13 +105,27 @@ describe Bolognese::Metadata, vcr: true do
98
105
  it "doi" do
99
106
  ids = [{"@type"=>"CreativeWork", "@id"=>"https://doi.org/10.5438/0012"}, {"@type"=>"CreativeWork", "@id"=>"https://doi.org/10.5438/55E5-T5C0"}]
100
107
  response = subject.normalize_ids(ids: ids)
101
- expect(response).to eq([{"id"=>"https://doi.org/10.5438/0012", "type"=>"CreativeWork", "relationType"=>"References", "resourceTypeGeneral" => "Other"}, {"id"=>"https://doi.org/10.5438/55e5-t5c0", "type"=>"CreativeWork", "relationType"=>"References", "resourceTypeGeneral" => "Other"}])
108
+ expect(response).to eq([{"id"=>"https://doi.org/10.5438/0012", "type"=>"CreativeWork"}, {"id"=>"https://doi.org/10.5438/55e5-t5c0", "type"=>"CreativeWork"}])
102
109
  end
103
110
 
104
111
  it "url" do
105
112
  ids = [{"@type"=>"CreativeWork", "@id"=>"https://blog.datacite.org/eating-your-own-dog-food/"}]
106
113
  response = subject.normalize_ids(ids: ids)
107
- expect(response).to eq("id"=>"https://blog.datacite.org/eating-your-own-dog-food", "resourceTypeGeneral" => "Other", "type"=>"CreativeWork", "relationType"=>"References")
114
+ expect(response).to eq("id"=>"https://blog.datacite.org/eating-your-own-dog-food", "type" => "CreativeWork")
115
+ end
116
+ end
117
+
118
+ context "normalize url" do
119
+ it "with trailing slash" do
120
+ url = "http://creativecommons.org/publicdomain/zero/1.0/"
121
+ response = subject.normalize_url(url)
122
+ expect(response).to eq("http://creativecommons.org/publicdomain/zero/1.0")
123
+ end
124
+
125
+ it "uri" do
126
+ url = "info:eu-repo/semantics/openAccess"
127
+ response = subject.normalize_url(url)
128
+ expect(response).to be_nil
108
129
  end
109
130
  end
110
131
 
@@ -138,28 +159,6 @@ describe Bolognese::Metadata, vcr: true do
138
159
  end
139
160
  end
140
161
 
141
- context "read" do
142
- let(:id) { "https://doi.org/10.5061/DRYAD.8515" }
143
- let(:from) { "datacite" }
144
-
145
- it "datacite" do
146
- response = subject.read(id: id, from: from)
147
- expect(response.id).to eq("https://doi.org/10.5061/dryad.8515")
148
- end
149
- end
150
-
151
- context "generate" do
152
- let(:id) { "https://doi.org/10.5061/DRYAD.8515" }
153
- let(:from) { "datacite" }
154
- let(:to) { "schema_org" }
155
-
156
- it "datacite" do
157
- response = subject.generate(id: id, from: from, to: to)
158
- json = JSON.parse(response)
159
- expect(json["@id"]).to eq("https://doi.org/10.5061/dryad.8515")
160
- end
161
- end
162
-
163
162
  context "get_date_parts" do
164
163
  it "date" do
165
164
  date = "2016-12-20"
@@ -0,0 +1,102 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bolognese::Metadata, vcr: true do
4
+ context "write metadata as bibtex" do
5
+ it "with data citation" do
6
+ input = "10.7554/eLife.01567"
7
+ subject = Bolognese::Metadata.new(input: input, from: "crossref")
8
+ bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first
9
+ expect(bibtex[:bibtex_type].to_s).to eq("article")
10
+ expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.7554/elife.01567")
11
+ expect(bibtex[:doi]).to eq("10.7554/eLife.01567")
12
+ expect(bibtex[:url]).to eq("http://elifesciences.org/lookup/doi/10.7554/eLife.01567")
13
+ expect(bibtex[:title]).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
14
+ expect(bibtex[:author]).to eq("Sankar, Martial and Nieminen, Kaisa and Ragni, Laura and Xenarios, Ioannis and Hardtke, Christian S")
15
+ expect(bibtex[:journal]).to eq("eLife")
16
+ expect(bibtex[:year]).to eq("2014")
17
+ end
18
+
19
+ it "with pages" do
20
+ input = "https://doi.org/10.1155/2012/291294"
21
+ subject = Bolognese::Metadata.new(input: input, from: "crossref")
22
+ bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first
23
+ expect(bibtex[:bibtex_type].to_s).to eq("article")
24
+ expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.1155/2012/291294")
25
+ expect(bibtex[:doi]).to eq("10.1155/2012/291294")
26
+ expect(bibtex[:url]).to eq("http://www.hindawi.com/journals/pm/2012/291294/")
27
+ expect(bibtex[:title]).to eq("Delineating a Retesting Zone Using Receiver Operating Characteristic Analysis on Serial QuantiFERON Tuberculosis Test Results in US Healthcare Workers")
28
+ expect(bibtex[:author]).to eq("Thanassi, Wendy and Noda, Art and Hernandez, Beatriz and Newell, Jeffery and Terpeluk, Paul and Marder, David and Yesavage, Jerome A.")
29
+ expect(bibtex[:journal]).to eq("Pulmonary Medicine")
30
+ expect(bibtex[:pages]).to eq("1-7")
31
+ expect(bibtex[:year]).to eq("2012")
32
+ end
33
+
34
+ it "maremma" do
35
+ input = "https://github.com/datacite/maremma"
36
+ subject = Bolognese::Metadata.new(input: input, from: "codemeta")
37
+ bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first
38
+ expect(bibtex[:bibtex_type].to_s).to eq("misc")
39
+ expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.5438/qeg0-3gm3")
40
+ expect(bibtex[:doi]).to eq("10.5438/qeg0-3gm3")
41
+ expect(bibtex[:url]).to eq("https://github.com/datacite/maremma")
42
+ expect(bibtex[:title]).to eq("Maremma: a Ruby library for simplified network calls")
43
+ expect(bibtex[:author]).to eq("Fenner, Martin")
44
+ expect(bibtex[:publisher]).to eq("DataCite")
45
+ expect(bibtex[:keywords]).to eq("faraday, excon, net/http")
46
+ expect(bibtex[:year]).to eq("2017")
47
+ end
48
+
49
+ it "BlogPosting from string" do
50
+ input = fixture_path + "datacite.json"
51
+ subject = Bolognese::Metadata.new(input: input, from: "datacite_json")
52
+ bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first
53
+ expect(bibtex[:bibtex_type].to_s).to eq("article")
54
+ expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.5438/4k3m-nyvg")
55
+ expect(bibtex[:doi]).to eq("10.5438/4K3M-NYVG")
56
+ expect(bibtex[:title]).to eq("Eating your own Dog Food")
57
+ expect(bibtex[:author]).to eq("Fenner, Martin")
58
+ expect(bibtex[:publisher]).to eq("DataCite")
59
+ expect(bibtex[:year]).to eq("2016")
60
+ end
61
+
62
+ it "BlogPosting" do
63
+ input = "https://doi.org/10.5438/4K3M-NYVG"
64
+ subject = Bolognese::Metadata.new(input: input, from: "datacite")
65
+ bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first
66
+ expect(bibtex[:bibtex_type].to_s).to eq("article")
67
+ expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.5438/4k3m-nyvg")
68
+ expect(bibtex[:doi]).to eq("10.5438/4k3m-nyvg")
69
+ expect(bibtex[:title]).to eq("Eating your own Dog Food")
70
+ expect(bibtex[:author]).to eq("Fenner, Martin")
71
+ expect(bibtex[:publisher]).to eq("DataCite")
72
+ expect(bibtex[:year]).to eq("2016")
73
+ end
74
+
75
+ it "Dataset" do
76
+ input = "https://doi.org/10.5061/dryad.8515"
77
+ subject = Bolognese::Metadata.new(input: input, from: "datacite")
78
+ bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first
79
+ expect(bibtex[:bibtex_type].to_s).to eq("misc")
80
+ expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.5061/dryad.8515")
81
+ expect(bibtex[:doi]).to eq("10.5061/dryad.8515")
82
+ expect(bibtex[:title]).to eq("Data from: A new malaria agent in African hominids.")
83
+ expect(bibtex[:author]).to eq("Ollomo, Benjamin and Durand, Patrick and Prugnolle, Franck and Douzery, Emmanuel J. P. and Arnathau, Céline and Nkoghe, Dieudonné and Leroy, Eric and Renaud, François")
84
+ expect(bibtex[:publisher]).to eq("Dryad Digital Repository")
85
+ expect(bibtex[:year]).to eq("2011")
86
+ end
87
+
88
+ it "from schema_org" do
89
+ input = "https://blog.datacite.org/eating-your-own-dog-food/"
90
+ subject = Bolognese::Metadata.new(input: input, from: "schema_org")
91
+ bibtex = BibTeX.parse(subject.bibtex).to_a(quotes: '').first
92
+ expect(bibtex[:bibtex_type].to_s).to eq("article")
93
+ expect(bibtex[:bibtex_key]).to eq("https://doi.org/10.5438/4k3m-nyvg")
94
+ expect(bibtex[:doi]).to eq("10.5438/4k3m-nyvg")
95
+ expect(bibtex[:title]).to eq("Eating your own Dog Food")
96
+ expect(bibtex[:author]).to eq("Fenner, Martin")
97
+ expect(bibtex[:publisher]).to eq("DataCite")
98
+ expect(bibtex[:keywords]).to eq("datacite, doi, metadata, featured")
99
+ expect(bibtex[:year]).to eq("2016")
100
+ end
101
+ end
102
+ end