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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1b985adff56f14d917d1c48050d65eec47551de
4
- data.tar.gz: 7446270f653147667df838080d6cbc6a0f7c1f74
3
+ metadata.gz: 9bacba9acee9d8a4338c5f8d205965044f2ea32b
4
+ data.tar.gz: 14ff4fdc282bc76b6836a4fe28b1553e10746c85
5
5
  SHA512:
6
- metadata.gz: bcbdc7a013ef6eb803ec23e104e7c863b6aa5b306b71f1cd6186853c34a3c27f4a1467f015c95aa02db40d802a682a0ed8f7b6959bca0660d7f7440208231e90
7
- data.tar.gz: e7b78a15cee66bff01a31a9ee937ff4858096c32336c354170091b22cb123bf7fbe6bada8e4f03aff3fc7b714c7ad4a56a33d1ad27705ab5b360bae51b582d3d
6
+ metadata.gz: e238cc8ba77137bd6ed6b8737644af53e35658cb8055bf97758652b9a85bd57d70c83c9bdc04304e3549b6cdb78907bb68f8d02bef226274b933203e599f90fa
7
+ data.tar.gz: ed8213e1277438363eac0a1838f85d52936b7ea4c0d70d49c3611f53c9ff2928bf99f891fa1bed2d02299af2529f3567caaf80406d652faa2bc7674a7fe2f1e1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (0.9.8)
4
+ bolognese (0.9.9)
5
5
  activesupport (>= 4.2.5, < 6)
6
6
  benchmark_methods (~> 0.7)
7
7
  bibtex-ruby (~> 4.1)
@@ -22,7 +22,7 @@ PATH
22
22
  GEM
23
23
  remote: https://rubygems.org/
24
24
  specs:
25
- activesupport (5.0.2)
25
+ activesupport (5.1.0)
26
26
  concurrent-ruby (~> 1.0, >= 1.0.2)
27
27
  i18n (~> 0.7)
28
28
  minitest (~> 5.1)
@@ -57,13 +57,13 @@ GEM
57
57
  tilt
58
58
  hamster (3.0.0)
59
59
  concurrent-ruby (~> 1.0)
60
- hashdiff (0.3.2)
60
+ hashdiff (0.3.4)
61
61
  htmlentities (4.3.4)
62
62
  i18n (0.8.1)
63
63
  json (2.1.0)
64
- json-ld (2.1.2)
64
+ json-ld (2.1.3)
65
65
  multi_json (~> 1.12)
66
- rdf (~> 2.1)
66
+ rdf (~> 2.2)
67
67
  jsonlint (0.2.0)
68
68
  oj (~> 2)
69
69
  trollop (~> 2)
@@ -121,19 +121,19 @@ GEM
121
121
  rdf (~> 2.2)
122
122
  rdf-xsd (2.1.0)
123
123
  rdf (~> 2.1)
124
- rspec (3.5.0)
125
- rspec-core (~> 3.5.0)
126
- rspec-expectations (~> 3.5.0)
127
- rspec-mocks (~> 3.5.0)
128
- rspec-core (3.5.4)
129
- rspec-support (~> 3.5.0)
130
- rspec-expectations (3.5.0)
124
+ rspec (3.6.0)
125
+ rspec-core (~> 3.6.0)
126
+ rspec-expectations (~> 3.6.0)
127
+ rspec-mocks (~> 3.6.0)
128
+ rspec-core (3.6.0)
129
+ rspec-support (~> 3.6.0)
130
+ rspec-expectations (3.6.0)
131
131
  diff-lcs (>= 1.2.0, < 2.0)
132
- rspec-support (~> 3.5.0)
133
- rspec-mocks (3.5.0)
132
+ rspec-support (~> 3.6.0)
133
+ rspec-mocks (3.6.0)
134
134
  diff-lcs (>= 1.2.0, < 2.0)
135
- rspec-support (~> 3.5.0)
136
- rspec-support (3.5.0)
135
+ rspec-support (~> 3.6.0)
136
+ rspec-support (3.6.0)
137
137
  rspec-xsd (0.1.0)
138
138
  nokogiri (~> 1.6)
139
139
  rspec (~> 3)
data/README.md CHANGED
@@ -93,9 +93,18 @@ Bolognese reads and/or writes these metadata formats:
93
93
  <td>Yes</td>
94
94
  <td>Yes</td>
95
95
  </tr>
96
+ <tr>
97
+ <td><a href='https://citation.crosscite.org/'>Crosscite</a></td>
98
+ <td>crosscite</td>
99
+ <td>application/vnd.crosscite.crosscite+json</td>
100
+ <td>Yes</td>
101
+ <td>Yes</td>
102
+ </tr>
96
103
  </tbody>
97
104
  </table>
98
105
 
106
+ **Crosscite** is the format used internally by bolognese.
107
+
99
108
  ## Installation
100
109
 
101
110
  Requires Ruby 2.2 or later. Then add the following to your `Gemfile` to install the
data/lib/bolognese.rb CHANGED
@@ -15,14 +15,6 @@ require 'gender_detector'
15
15
 
16
16
  require "bolognese/version"
17
17
  require "bolognese/metadata"
18
- require "bolognese/crossref"
19
- require "bolognese/datacite"
20
- require "bolognese/datacite_json"
21
- require "bolognese/schema_org"
22
- require "bolognese/codemeta"
23
- require "bolognese/bibtex"
24
- require "bolognese/ris"
25
- require "bolognese/citeproc"
26
18
  require "bolognese/orcid"
27
19
  require "bolognese/cli"
28
20
  require "bolognese/string"
@@ -1,5 +1,5 @@
1
- # turn array into hash or nil, depending on array size. Reverses Array.wrap,
2
- # but uses self to allow chaining with Array.wrap
1
+ # turn array into hash or nil, depending on array size.
2
+ # Reverses Array.wrap, but uses self to allow chaining with Array.wrap
3
3
  class Array
4
4
  def unwrap
5
5
  case self.length
@@ -2,7 +2,6 @@ require 'namae'
2
2
 
3
3
  module Bolognese
4
4
  module AuthorUtils
5
- # only assume personal name when using sort-order: "Turing, Alan"
6
5
  def get_one_author(author)
7
6
  type = author.fetch("type", nil) && author.fetch("type").titleize
8
7
  id = author.fetch("id", nil).presence || get_name_identifier(author)
@@ -10,6 +9,15 @@ module Bolognese
10
9
  author.fetch("contributorName", nil) ||
11
10
  author.fetch("name", nil)
12
11
 
12
+ if name.include?("; ")
13
+ authors = name.split("; ").map do |name|
14
+ { "type" => author.fetch("type", nil),
15
+ "id" => author.fetch("id", nil),
16
+ "name" => name }.compact
17
+ end
18
+ return get_authors(authors)
19
+ end
20
+
13
21
  name = cleanup_author(name)
14
22
  given_name = author.fetch("givenName", nil)
15
23
  family_name = author.fetch("familyName", nil)
@@ -43,6 +51,9 @@ module Bolognese
43
51
  # remove spaces around hyphens
44
52
  author = author.gsub(" - ", "-")
45
53
 
54
+ # remove text in parentheses
55
+ author = author.sub(/\s*\(.+\)$/, '')
56
+
46
57
  # titleize strings
47
58
  # remove non-standard space characters
48
59
  author.my_titleize
@@ -66,13 +77,14 @@ module Bolognese
66
77
 
67
78
  # parse nameIdentifier from DataCite
68
79
  def get_name_identifier(author)
69
- name_identifier = author.dig("nameIdentifier", "__content__")
70
- name_identifier = validate_orcid(name_identifier)
71
- name_identifier_scheme = author.dig("nameIdentifier", "nameIdentifierScheme") || "ORCID"
80
+ name_identifier_scheme_uri = author.dig("nameIdentifier", "schemeURI") || "http://orcid.org/"
81
+ name_identifier_scheme_uri << '/' unless name_identifier_scheme_uri.end_with?('/')
72
82
 
73
- return nil if name_identifier.blank? || name_identifier_scheme.upcase != "ORCID"
83
+ name_identifier = author.dig("nameIdentifier", "__content__")
84
+ name_identifier = validate_orcid(name_identifier) if name_identifier_scheme_uri == "http://orcid.org/"
85
+ return nil if name_identifier.blank? || name_identifier_scheme_uri.blank?
74
86
 
75
- "http://orcid.org/" + name_identifier
87
+ name_identifier_scheme_uri + name_identifier
76
88
  end
77
89
 
78
90
  def authors_as_string(authors)
data/lib/bolognese/cli.rb CHANGED
@@ -27,24 +27,9 @@ module Bolognese
27
27
  method_option :to, aliases: "-t", default: "schema_org"
28
28
  method_option :regenerate, :type => :boolean, :force => false
29
29
  def convert(input)
30
- id = normalize_id(input)
31
-
32
- if id.present?
33
- from = options[:from] || find_from_format(id: id)
34
- else
35
- ext = File.extname(input)
36
- if %w(.bib .ris .xml .json).include?(ext)
37
- string = IO.read(input)
38
- else
39
- $stderr.puts "File type #{ext} not supported"
40
- exit 1
41
- end
42
- from = options[:from] || find_from_format(string: string, ext: ext)
43
- end
44
-
30
+ metadata = Metadata.new(input: input, from: options[:from], regenerate: options[:regenerate])
45
31
  to = options[:to] || "schema_org"
46
-
47
- write(id: id, string: string, from: from, to: to, regenerate: options[:regenerate])
32
+ puts metadata.send(to)
48
33
  end
49
34
 
50
35
  default_task :convert
@@ -14,9 +14,9 @@ module Bolognese
14
14
  end.to_xml
15
15
  end
16
16
 
17
- def datacite
18
- datacite_xml
19
- end
17
+ # def datacite
18
+ # datacite_xml
19
+ # end
20
20
 
21
21
  def datacite_errors
22
22
  schema.validate(Nokogiri::XML(datacite, nil, 'UTF-8')).map { |error| error.to_s }.unwrap
@@ -88,7 +88,7 @@ module Bolognese
88
88
  end
89
89
 
90
90
  def insert_publisher(xml)
91
- xml.publisher(container_title)
91
+ xml.publisher(publisher)
92
92
  end
93
93
 
94
94
  def insert_publication_year(xml)
@@ -164,10 +164,11 @@ module Bolognese
164
164
 
165
165
  def rel_identifier
166
166
  Array.wrap(related_identifier).map do |r|
167
+ related_identifier_type = r["issn"].present? ? "ISSN" : validate_url(r["id"])
167
168
  { "__content__" => r["id"],
168
- "related_identifier_type" => validate_url(r["id"]),
169
+ "related_identifier_type" => related_identifier_type,
169
170
  "relation_type" => r["relationType"],
170
- "resource_type_general" => r["resourceTypeGeneral"] }
171
+ "resource_type_general" => r["resourceTypeGeneral"] }.compact
171
172
  end
172
173
  end
173
174
 
@@ -190,7 +191,7 @@ module Bolognese
190
191
 
191
192
  xml.rightsList do
192
193
  Array.wrap(license).each do |lic|
193
- xml.rights(lic["name"], 'rightsURI' => lic["url"])
194
+ xml.rights(lic["name"], 'rightsURI' => lic["id"])
194
195
  end
195
196
  end
196
197
  end
@@ -4,6 +4,28 @@ require_relative 'date_utils'
4
4
  require_relative 'datacite_utils'
5
5
  require_relative 'utils'
6
6
 
7
+ require_relative 'readers/bibtex_reader'
8
+ require_relative 'readers/citeproc_reader'
9
+ require_relative 'readers/codemeta_reader'
10
+ require_relative 'readers/crosscite_reader'
11
+ require_relative 'readers/crossref_reader'
12
+ require_relative 'readers/datacite_json_reader'
13
+ require_relative 'readers/datacite_reader'
14
+ require_relative 'readers/ris_reader'
15
+ require_relative 'readers/schema_org_reader'
16
+
17
+ require_relative 'writers/bibtex_writer'
18
+ require_relative 'writers/citeproc_writer'
19
+ require_relative 'writers/codemeta_writer'
20
+ require_relative 'writers/crosscite_writer'
21
+ require_relative 'writers/crossref_writer'
22
+ require_relative 'writers/datacite_writer'
23
+ require_relative 'writers/datacite_json_writer'
24
+ require_relative 'writers/rdf_xml_writer'
25
+ require_relative 'writers/ris_writer'
26
+ require_relative 'writers/schema_org_writer'
27
+ require_relative 'writers/turtle_writer'
28
+
7
29
  module Bolognese
8
30
  class Metadata
9
31
  # include BenchmarkMethods
@@ -13,7 +35,29 @@ module Bolognese
13
35
  include Bolognese::DataciteUtils
14
36
  include Bolognese::Utils
15
37
 
16
- attr_reader :id, :raw, :doc, :provider, :schema_version, :license, :citation,
38
+ include Bolognese::Readers::BibtexReader
39
+ include Bolognese::Readers::CiteprocReader
40
+ include Bolognese::Readers::CodemetaReader
41
+ include Bolognese::Readers::CrossciteReader
42
+ include Bolognese::Readers::CrossrefReader
43
+ include Bolognese::Readers::DataciteReader
44
+ include Bolognese::Readers::DataciteJsonReader
45
+ include Bolognese::Readers::RisReader
46
+ include Bolognese::Readers::SchemaOrgReader
47
+
48
+ include Bolognese::Writers::BibtexWriter
49
+ include Bolognese::Writers::CiteprocWriter
50
+ include Bolognese::Writers::CodemetaWriter
51
+ include Bolognese::Writers::CrossciteWriter
52
+ include Bolognese::Writers::CrossrefWriter
53
+ include Bolognese::Writers::DataciteWriter
54
+ include Bolognese::Writers::DataciteJsonWriter
55
+ include Bolognese::Writers::RdfXmlWriter
56
+ include Bolognese::Writers::RisWriter
57
+ include Bolognese::Writers::SchemaOrgWriter
58
+ include Bolognese::Writers::TurtleWriter
59
+
60
+ attr_reader :id, :from, :raw, :metadata, :doc, :provider, :schema_version, :license, :citation,
17
61
  :additional_type, :alternate_name, :url, :version, :keywords, :editor,
18
62
  :page_start, :page_end, :date_modified, :language, :spatial_coverage,
19
63
  :content_size, :funder, :journal, :bibtex_type, :date_created, :has_part,
@@ -28,26 +72,259 @@ module Bolognese
28
72
  :related_identifier, :reverse, :citeproc_type, :ris_type, :volume, :issue,
29
73
  :name_detector
30
74
 
75
+ def initialize(input: nil, from: nil, regenerate: false)
76
+ id = normalize_id(input)
77
+
78
+ if id.present?
79
+ @from = from || find_from_format(id: id)
80
+
81
+ # generate name for method to call dynamically
82
+ string = send("get_" + @from, id: id)
83
+ else
84
+ ext = File.extname(input)
85
+ if %w(.bib .ris .xml .json).include?(ext)
86
+ string = IO.read(input)
87
+ @from = from || find_from_format(string: string, ext: ext)
88
+ else
89
+ $stderr.puts "File type #{ext} not supported"
90
+ exit 1
91
+ end
92
+ end
93
+
94
+ # generate name for method to call dynamically
95
+ @metadata = @from.present? ? send("read_" + @from, string: string) : {}
96
+ @raw = string
97
+ @should_passthru = (@from == "datacite") && !regenerate
98
+ end
99
+
100
+ def exists?
101
+ metadata.fetch("id", nil).present?
102
+ end
103
+
104
+ def valid?
105
+ errors.nil?
106
+ end
107
+
108
+ def errors
109
+ metadata.fetch("errors", nil)
110
+ end
111
+
112
+ # def errors
113
+ # doc && doc.errors.map { |error| error.to_s }.unwrap
114
+ # end
115
+
116
+ def id
117
+ metadata.fetch("id", nil)
118
+ end
119
+
120
+ def type
121
+ metadata.fetch("type", nil)
122
+ end
123
+
124
+ def additional_type
125
+ metadata.fetch("additional_type", nil)
126
+ end
127
+
128
+ def citeproc_type
129
+ metadata.fetch("citeproc_type", nil)
130
+ end
131
+
132
+ def bibtex_type
133
+ metadata.fetch("bibtex_type", nil)
134
+ end
135
+
136
+ def ris_type
137
+ metadata.fetch("ris_type", nil)
138
+ end
139
+
140
+ def resource_type_general
141
+ metadata.fetch("resource_type_general", nil)
142
+ end
143
+
144
+ def doi
145
+ metadata.fetch("doi", nil)
146
+ end
147
+
148
+ def url
149
+ metadata.fetch("url", nil)
150
+ end
151
+
152
+ def title
153
+ metadata.fetch("title", nil)
154
+ end
155
+
156
+ def alternate_name
157
+ metadata.fetch("alternate_name", nil)
158
+ end
159
+
160
+ def author
161
+ metadata.fetch("author", nil)
162
+ end
163
+
164
+ def editor
165
+ metadata.fetch("editor", nil)
166
+ end
167
+
168
+ def funder
169
+ metadata.fetch("funder", nil)
170
+ end
171
+
172
+ def publisher
173
+ metadata.fetch("publisher", nil)
174
+ end
175
+
176
+ def provider
177
+ metadata.fetch("provider", nil)
178
+ end
179
+
180
+ def date_created
181
+ metadata.fetch("date_created", nil)
182
+ end
183
+
184
+ def date_accepted
185
+ metadata.fetch("date_accepted", nil)
186
+ end
187
+
188
+ def date_available
189
+ metadata.fetch("date_available", nil)
190
+ end
191
+
192
+ def date_copyrighted
193
+ metadata.fetch("date_copyrighted", nil)
194
+ end
195
+
196
+ def date_collected
197
+ metadata.fetch("date_collected", nil)
198
+ end
199
+
200
+ def date_submitted
201
+ metadata.fetch("date_submitted", nil)
202
+ end
203
+
204
+ def date_valid
205
+ metadata.fetch("date_valid", nil)
206
+ end
207
+
208
+ def date_published
209
+ metadata.fetch("date_published", nil)
210
+ end
211
+
212
+ def date_modified
213
+ metadata.fetch("date_modified", nil)
214
+ end
215
+
216
+ def volume
217
+ metadata.fetch("volume", nil)
218
+ end
219
+
220
+ def pagination
221
+ metadata.fetch("pagination", nil)
222
+ end
223
+
224
+ def description
225
+ metadata.fetch("description", nil)
226
+ end
227
+
228
+ def license
229
+ metadata.fetch("license", nil)
230
+ end
231
+
232
+ def version
233
+ metadata.fetch("version", nil)
234
+ end
235
+
236
+ def keywords
237
+ metadata.fetch("keywords", nil)
238
+ end
239
+
240
+ def language
241
+ metadata.fetch("language", nil)
242
+ end
243
+
244
+ def content_size
245
+ metadata.fetch("content_size", nil)
246
+ end
247
+
248
+ def schema_version
249
+ metadata.fetch("schema_version", nil)
250
+ end
251
+
252
+ def is_identical_to
253
+ metadata.fetch("is_identical_to", nil)
254
+ end
255
+
256
+ def is_part_of
257
+ metadata.fetch("is_part_of", nil)
258
+ end
259
+
260
+ def has_part
261
+ metadata.fetch("has_part", nil)
262
+ end
263
+
264
+ def is_previous_version_of
265
+ metadata.fetch("is_previous_of", nil)
266
+ end
267
+
268
+ def is_new_version_of
269
+ metadata.fetch("is_new_version_of", nil)
270
+ end
271
+
272
+ def is_variant_form_of
273
+ metadata.fetch("is_variant_form_of", nil)
274
+ end
275
+
276
+ def is_original_form_of
277
+ metadata.fetch("is_original_form_of", nil)
278
+ end
279
+
280
+ def references
281
+ metadata.fetch("references", nil)
282
+ end
283
+
284
+ def is_referenced_by
285
+ metadata.fetch("is_referenced_by", nil)
286
+ end
287
+
288
+ def is_supplement_to
289
+ metadata.fetch("is_supplement_to", nil)
290
+ end
291
+
292
+ def is_supplemented_by
293
+ metadata.fetch("is_supplemented_by", nil)
294
+ end
295
+
296
+ def reviews
297
+ metadata.fetch("reviews", nil)
298
+ end
299
+
300
+ def is_reviewed_by
301
+ metadata.fetch("is_reviewed_by", nil)
302
+ end
303
+
304
+ def related_identifier_hsh(relation_type)
305
+ Array.wrap(send(relation_type)).map { |r| r.merge("relationType" => relation_type.camelize) }
306
+ end
307
+
308
+ def related_identifier
309
+ relation_types = %w(is_part_of has_part references is_referenced_by is_supplement_to is_supplemented_by)
310
+ relation_types.reduce([]) { |sum, r| sum += related_identifier_hsh(r) }
311
+ end
312
+
31
313
  # recognize given name. Can be loaded once as ::NameDetector, e.g. in a Rails initializer
32
314
  def name_detector
33
315
  @name_detector ||= defined?(::NameDetector) ? ::NameDetector : GenderDetector.new
34
316
  end
35
317
 
36
318
  def publication_year
37
- date_published && date_published[0..3]
38
- end
39
-
40
- def descriptions
41
- Array.wrap(description)
319
+ date_published.present? ? date_published[0..3].to_i.presence : nil
42
320
  end
43
321
 
44
- def pagination
45
- [page_start, page_end].compact.join("-").presence
322
+ def container_title
323
+ is_part_of.to_h.fetch("name", nil)
46
324
  end
47
325
 
48
- def reverse
49
- { "citation" => Array.wrap(is_referenced_by).map { |r| { "@id" => r["id"] }}.unwrap,
50
- "isBasedOn" => Array.wrap(is_supplement_to).map { |r| { "@id" => r["id"] }}.unwrap }.compact
326
+ def descriptions
327
+ Array.wrap(description)
51
328
  end
52
329
 
53
330
  def name
@@ -58,177 +335,13 @@ module Bolognese
58
335
  end
59
336
  end
60
337
 
61
- def schema_hsh
62
- {
63
- "@context" => id.present? ? "http://schema.org" : nil,
64
- "@type" => type,
65
- "@id" => id,
66
- "url" => url,
67
- "additionalType" => additional_type,
68
- "name" => name,
69
- "alternateName" => alternate_name,
70
- "author" => to_schema_org(author),
71
- "editor" => editor,
72
- "description" => Array.wrap(description).map { |d| d["text"] }.unwrap,
73
- "license" => license.present? ? license["id"] : nil,
74
- "version" => version,
75
- "keywords" => keywords,
76
- "inLanguage" => language,
77
- "contentSize" => content_size,
78
- "dateCreated" => date_created,
79
- "datePublished" => date_published,
80
- "dateModified" => date_modified,
81
- "pageStart" => page_start,
82
- "pageEnd" => page_end,
83
- "spatialCoverage" => spatial_coverage,
84
- "sameAs" => same_as,
85
- "isPartOf" => is_part_of,
86
- "hasPart" => has_part,
87
- "predecessor_of" => is_previous_version_of,
88
- "successor_of" => is_new_version_of,
89
- "citation" => Array.wrap(references).map { |r| r.except("relationType").merge("@type" => "CreativeWork") }.unwrap,
90
- "@reverse" => reverse.presence,
91
- "schemaVersion" => schema_version,
92
- "publisher" => publisher.present? ? { "@type" => "Organization", "name" => publisher } : nil,
93
- "funder" => funder,
94
- "provider" => provider.present? ? { "@type" => "Organization", "name" => provider } : nil
95
- }.compact.presence
96
- end
97
-
98
- def schema_org
99
- JSON.pretty_generate schema_hsh
338
+ def reverse
339
+ { "citation" => Array.wrap(is_referenced_by).map { |r| { "@id" => r["id"] }}.unwrap,
340
+ "isBasedOn" => Array.wrap(is_supplement_to).map { |r| { "@id" => r["id"] }}.unwrap }.compact
100
341
  end
101
342
 
102
343
  def graph
103
344
  RDF::Graph.new << JSON::LD::API.toRdf(schema_hsh)
104
345
  end
105
-
106
- def turtle
107
- graph.dump(:ttl, prefixes: { schema: "http://schema.org/" })
108
- end
109
-
110
- def rdf_xml
111
- graph.dump(:rdfxml, prefixes: { schema: "http://schema.org/" })
112
- end
113
-
114
- def datacite_json
115
- hsh = {
116
- "id" => id,
117
- "doi" => doi,
118
- "creator" => author,
119
- "title" => title,
120
- "publisher" => publisher,
121
- "publication-year" => publication_year,
122
- "resource-type-general" => resource_type_general,
123
- "resource-type" => additional_type,
124
- "subject" => keywords.present? ? keywords.split(", ") : nil,
125
- "contributor" => contributor,
126
- "date-accepted" => date_accepted,
127
- "date-available" => date_available,
128
- "date-copyrighted" => date_copyrighted,
129
- "date-collected" => date_collected,
130
- "date-created" => date_created,
131
- "date-published" => date_published,
132
- "date-modified" => date_modified,
133
- "date-submitted" => date_submitted,
134
- "date-valid" => date_valid,
135
- "language" => language,
136
- "alternate-identifier" => alternate_name,
137
- "related_identifier" => related_identifier,
138
- "size" => content_size,
139
- "format" => format,
140
- "version" => version,
141
- "rights" => license,
142
- "description" => description,
143
- "geo-location" => spatial_coverage,
144
- "funding-reference" => funder,
145
- "schemaVersion" => schema_version,
146
- "provider" => provider
147
- }.compact
148
- JSON.pretty_generate hsh.presence
149
- end
150
-
151
- def citeproc
152
- hsh = {
153
- "type" => citeproc_type,
154
- "id" => id,
155
- "categories" => keywords.present? ? keywords.split(", ") : nil,
156
- "language" => language,
157
- "author" => to_citeproc(author),
158
- "editor" => to_citeproc(editor),
159
- "issued" => get_date_parts(date_published),
160
- "submitted" => get_date_parts(date_submitted),
161
- "abstract" => description.is_a?(Hash) ? description.fetch("text", nil) : description,
162
- "container-title" => journal,
163
- "DOI" => doi,
164
- "issue" => issue,
165
- "page" => pagination,
166
- "publisher" => publisher,
167
- "title" => title,
168
- "URL" => url,
169
- "version" => version,
170
- "volume" => volume
171
- }.compact
172
- JSON.pretty_generate hsh.presence
173
- end
174
-
175
- def codemeta
176
- hsh = {
177
- "@context" => id.present? ? "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld" : nil,
178
- "@type" => type,
179
- "@id" => id,
180
- "identifier" => id,
181
- "codeRepository" => url,
182
- "title" => title,
183
- "agents" => author,
184
- "description" => description.present? ? description["text"] : nil,
185
- "version" => version,
186
- "tags" => keywords.to_s.split(", ").presence,
187
- "dateCreated" => date_created,
188
- "datePublished" => date_published,
189
- "dateModified" => date_modified,
190
- "publisher" => publisher
191
- }.compact
192
- JSON.pretty_generate hsh.presence
193
- end
194
-
195
- def bibtex
196
- bib = {
197
- bibtex_type: bibtex_type.present? ? bibtex_type.to_sym : "misc",
198
- bibtex_key: id,
199
- doi: doi,
200
- url: url,
201
- author: authors_as_string(author),
202
- keywords: keywords,
203
- language: language,
204
- title: title,
205
- journal: journal,
206
- pages: pagination,
207
- publisher: publisher,
208
- year: publication_year
209
- }.compact
210
- BibTeX::Entry.new(bib).to_s
211
- end
212
-
213
- def ris
214
- {
215
- "TY" => ris_type,
216
- "T1" => title,
217
- "T2" => container_title,
218
- "AU" => to_ris(author),
219
- "DO" => doi,
220
- "UR" => url,
221
- "AB" => description.present? ? description["text"] : nil,
222
- "KW" => keywords.to_s.split(", ").presence,
223
- "PY" => publication_year,
224
- "PB" => publisher,
225
- "AN" => alternate_name.present? ? alternate_name["name"] : nil,
226
- "LA" => language,
227
- "VL" => volume,
228
- "IS" => issue,
229
- "SP" => pagination,
230
- "ER" => ""
231
- }.compact.map { |k, v| v.is_a?(Array) ? v.map { |vi| "#{k} - #{vi}" }.join("\r\n") : "#{k} - #{v}" }.join("\r\n")
232
- end
233
346
  end
234
347
  end