bolognese 0.4.3 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/build.yml +9 -0
  3. data/.github/workflows/changelog.yml +36 -0
  4. data/.github/workflows/ci.yml +22 -0
  5. data/.github/workflows/pull-request.yml +9 -0
  6. data/.github/workflows/release.yml +32 -0
  7. data/.gitignore +4 -0
  8. data/.rubocop.yml +658 -0
  9. data/CHANGELOG.md +1864 -0
  10. data/CITATION +17 -0
  11. data/Gemfile +1 -1
  12. data/Gemfile.lock +250 -98
  13. data/README.md +963 -21
  14. data/Rakefile +1 -0
  15. data/bin/bolognese +5 -1
  16. data/bolognese.gemspec +33 -21
  17. data/lib/bolognese/array.rb +13 -0
  18. data/lib/bolognese/author_utils.rb +147 -33
  19. data/lib/bolognese/citeproc_extensions.rb +48 -0
  20. data/lib/bolognese/cli.rb +28 -21
  21. data/lib/bolognese/datacite_utils.rb +292 -104
  22. data/lib/bolognese/doi_utils.rb +44 -20
  23. data/lib/bolognese/metadata.rb +249 -23
  24. data/lib/bolognese/metadata_utils.rb +228 -0
  25. data/lib/bolognese/pubmed.rb +2 -0
  26. data/lib/bolognese/readers/bibtex_reader.rb +100 -0
  27. data/lib/bolognese/readers/citeproc_reader.rb +125 -0
  28. data/lib/bolognese/readers/codemeta_reader.rb +108 -0
  29. data/lib/bolognese/readers/crosscite_reader.rb +17 -0
  30. data/lib/bolognese/readers/crossref_reader.rb +413 -0
  31. data/lib/bolognese/readers/datacite_json_reader.rb +17 -0
  32. data/lib/bolognese/readers/datacite_reader.rb +341 -0
  33. data/lib/bolognese/readers/npm_reader.rb +115 -0
  34. data/lib/bolognese/readers/ris_reader.rb +114 -0
  35. data/lib/bolognese/readers/schema_org_reader.rb +264 -0
  36. data/lib/bolognese/string.rb +3 -1
  37. data/lib/bolognese/utils.rb +1463 -25
  38. data/lib/bolognese/version.rb +1 -1
  39. data/lib/bolognese/whitelist_scrubber.rb +47 -0
  40. data/lib/bolognese/writers/bibtex_writer.rb +32 -0
  41. data/lib/bolognese/writers/citation_writer.rb +14 -0
  42. data/lib/bolognese/writers/citeproc_writer.rb +11 -0
  43. data/lib/bolognese/writers/codemeta_writer.rb +29 -0
  44. data/lib/bolognese/writers/crosscite_writer.rb +11 -0
  45. data/lib/bolognese/writers/crossref_writer.rb +11 -0
  46. data/lib/bolognese/writers/csv_writer.rb +24 -0
  47. data/lib/bolognese/writers/datacite_json_writer.rb +13 -0
  48. data/lib/bolognese/writers/datacite_writer.rb +12 -0
  49. data/lib/bolognese/writers/jats_writer.rb +137 -0
  50. data/lib/bolognese/writers/rdf_xml_writer.rb +11 -0
  51. data/lib/bolognese/writers/ris_writer.rb +29 -0
  52. data/lib/bolognese/writers/schema_org_writer.rb +55 -0
  53. data/lib/bolognese/writers/turtle_writer.rb +11 -0
  54. data/lib/bolognese.rb +19 -5
  55. data/package.json +12 -0
  56. data/resources/2008/09/xsd.xsl +997 -0
  57. data/resources/datacite-contributorType-v4.xsd +35 -0
  58. data/resources/datacite-dateType-v4.xsd +25 -0
  59. data/resources/datacite-descriptionType-v4.xsd +19 -0
  60. data/resources/datacite-funderIdentifierType-v4.xsd +15 -0
  61. data/resources/datacite-nameType-v4.xsd +10 -0
  62. data/resources/datacite-relatedIdentifierType-v4.xsd +34 -0
  63. data/resources/datacite-relationType-v4.xsd +49 -0
  64. data/resources/datacite-resourceType-v4.xsd +28 -0
  65. data/resources/datacite-titleType-v4.xsd +14 -0
  66. data/resources/kernel-2.1/include/datacite-contributorType-v1.1.xsd +22 -0
  67. data/resources/kernel-2.1/include/datacite-contributorType-v2.xsd +3 -0
  68. data/resources/kernel-2.1/include/datacite-dateType-v1.1.xsd +31 -0
  69. data/resources/kernel-2.1/include/datacite-dateType-v2.xsd +3 -0
  70. data/resources/kernel-2.1/include/datacite-descriptionType-v1.1.xsd +14 -0
  71. data/resources/kernel-2.1/include/datacite-descriptionType-v2.xsd +3 -0
  72. data/resources/kernel-2.1/include/datacite-relatedIdentifierType-v1.1.xsd +24 -0
  73. data/resources/kernel-2.1/include/datacite-relatedIdentifierType-v2.xsd +3 -0
  74. data/resources/kernel-2.1/include/datacite-relationType-v1.1.xsd +29 -0
  75. data/resources/kernel-2.1/include/datacite-relationType-v2.xsd +3 -0
  76. data/resources/kernel-2.1/include/datacite-resourceType-v1.1.xsd +22 -0
  77. data/resources/kernel-2.1/include/datacite-resourceType-v2.xsd +3 -0
  78. data/resources/kernel-2.1/include/datacite-titleType-v1.1.xsd +11 -0
  79. data/resources/kernel-2.1/include/datacite-titleType-v2.xsd +3 -0
  80. data/resources/kernel-2.1/metadata.xsd +315 -0
  81. data/resources/kernel-2.2/include/datacite-contributorType-v2.xsd +29 -0
  82. data/resources/kernel-2.2/include/datacite-dateType-v2.xsd +21 -0
  83. data/resources/kernel-2.2/include/datacite-descriptionType-v2.xsd +15 -0
  84. data/resources/kernel-2.2/include/datacite-relatedIdentifierType-v2.xsd +25 -0
  85. data/resources/kernel-2.2/include/datacite-relationType-v2.xsd +29 -0
  86. data/resources/kernel-2.2/include/datacite-resourceType-v2.xsd +23 -0
  87. data/resources/kernel-2.2/include/datacite-titleType-v2.xsd +10 -0
  88. data/resources/kernel-2.2/metadata.xsd +316 -0
  89. data/resources/kernel-3/include/datacite-contributorType-v3.1.xsd +35 -0
  90. data/resources/kernel-3/include/datacite-dateType-v3.xsd +21 -0
  91. data/resources/kernel-3/include/datacite-descriptionType-v3.xsd +17 -0
  92. data/resources/kernel-3/include/datacite-relatedIdentifierType-v3.1.xsd +30 -0
  93. data/resources/kernel-3/include/datacite-relationType-v3.1.xsd +38 -0
  94. data/resources/kernel-3/include/datacite-resourceType-v3.xsd +26 -0
  95. data/resources/kernel-3/include/datacite-titleType-v3.xsd +12 -0
  96. data/resources/kernel-3/include/xml.xsd +286 -0
  97. data/resources/kernel-3/metadata.xsd +380 -0
  98. data/resources/kernel-3.0/include/datacite-contributorType-v3.xsd +33 -0
  99. data/resources/kernel-3.0/include/datacite-dateType-v3.xsd +21 -0
  100. data/resources/kernel-3.0/include/datacite-descriptionType-v3.xsd +17 -0
  101. data/resources/kernel-3.0/include/datacite-relatedIdentifierType-v3.xsd +27 -0
  102. data/resources/kernel-3.0/include/datacite-relationType-v3.xsd +33 -0
  103. data/resources/kernel-3.0/include/datacite-resourceType-v3.xsd +26 -0
  104. data/resources/kernel-3.0/include/datacite-titleType-v3.xsd +12 -0
  105. data/resources/kernel-3.0/include/xml.xsd +286 -0
  106. data/resources/kernel-3.0/metadata.xsd +377 -0
  107. data/resources/kernel-3.1/include/datacite-contributorType-v3.1.xsd +35 -0
  108. data/resources/kernel-3.1/include/datacite-dateType-v3.xsd +21 -0
  109. data/resources/kernel-3.1/include/datacite-descriptionType-v3.xsd +17 -0
  110. data/resources/kernel-3.1/include/datacite-relatedIdentifierType-v3.1.xsd +30 -0
  111. data/resources/kernel-3.1/include/datacite-relationType-v3.1.xsd +38 -0
  112. data/resources/kernel-3.1/include/datacite-resourceType-v3.xsd +26 -0
  113. data/resources/kernel-3.1/include/datacite-titleType-v3.xsd +12 -0
  114. data/resources/kernel-3.1/include/xml.xsd +286 -0
  115. data/resources/kernel-3.1/metadata.xsd +380 -0
  116. data/resources/kernel-4/include/datacite-contributorType-v4.xsd +37 -0
  117. data/resources/kernel-4/include/datacite-dateType-v4.xsd +27 -0
  118. data/resources/kernel-4/include/datacite-descriptionType-v4.xsd +19 -0
  119. data/resources/kernel-4/include/datacite-funderIdentifierType-v4.xsd +16 -0
  120. data/resources/kernel-4/include/datacite-nameType-v4.xsd +10 -0
  121. data/resources/kernel-4/include/datacite-numberType-v4.xsd +12 -0
  122. data/resources/kernel-4/include/datacite-relatedIdentifierType-v4.xsd +39 -0
  123. data/resources/kernel-4/include/datacite-relationType-v4.xsd +59 -0
  124. data/resources/kernel-4/include/datacite-resourceType-v4.xsd +52 -0
  125. data/resources/kernel-4/include/datacite-titleType-v4.xsd +14 -0
  126. data/resources/kernel-4/include/xml.xsd +286 -0
  127. data/resources/kernel-4/metadata.xsd +715 -0
  128. data/resources/kernel-4.0/include/datacite-contributorType-v4.xsd +1 -1
  129. data/resources/kernel-4.0/include/datacite-dateType-v4.xsd +1 -1
  130. data/resources/kernel-4.0/include/datacite-descriptionType-v4.xsd +1 -1
  131. data/resources/kernel-4.0/include/datacite-funderIdentifierType-v4.xsd +1 -1
  132. data/resources/kernel-4.0/include/datacite-relatedIdentifierType-v4.xsd +1 -1
  133. data/resources/kernel-4.0/include/datacite-relationType-v4.xsd +1 -1
  134. data/resources/kernel-4.0/include/datacite-resourceType-v4.xsd +1 -1
  135. data/resources/kernel-4.0/include/datacite-titleType-v4.xsd +1 -1
  136. data/resources/kernel-4.0/include/xml.xsd +286 -0
  137. data/resources/kernel-4.0/metadata.xsd +2 -2
  138. data/resources/kernel-4.1/include/datacite-contributorType-v4.xsd +35 -0
  139. data/resources/kernel-4.1/include/datacite-dateType-v4.1.xsd +23 -0
  140. data/resources/kernel-4.1/include/datacite-descriptionType-v4.xsd +19 -0
  141. data/resources/kernel-4.1/include/datacite-funderIdentifierType-v4.xsd +15 -0
  142. data/resources/kernel-4.1/include/datacite-nameType-v4.1.xsd +10 -0
  143. data/resources/kernel-4.1/include/datacite-relatedIdentifierType-v4.xsd +32 -0
  144. data/resources/kernel-4.1/include/datacite-relationType-v4.1.xsd +46 -0
  145. data/resources/kernel-4.1/include/datacite-resourceType-v4.1.xsd +28 -0
  146. data/resources/kernel-4.1/include/datacite-titleType-v4.xsd +14 -0
  147. data/resources/kernel-4.1/include/xml.xsd +286 -0
  148. data/resources/kernel-4.1/metadata.xsd +483 -0
  149. data/resources/kernel-4.2/include/datacite-contributorType-v4.xsd +35 -0
  150. data/resources/kernel-4.2/include/datacite-dateType-v4.xsd +25 -0
  151. data/resources/kernel-4.2/include/datacite-descriptionType-v4.xsd +19 -0
  152. data/resources/kernel-4.2/include/datacite-funderIdentifierType-v4.xsd +15 -0
  153. data/resources/kernel-4.2/include/datacite-nameType-v4.xsd +10 -0
  154. data/resources/kernel-4.2/include/datacite-relatedIdentifierType-v4.xsd +34 -0
  155. data/resources/kernel-4.2/include/datacite-relationType-v4.xsd +49 -0
  156. data/resources/kernel-4.2/include/datacite-resourceType-v4.xsd +28 -0
  157. data/resources/kernel-4.2/include/datacite-titleType-v4.xsd +14 -0
  158. data/resources/kernel-4.2/include/xml.xsd +286 -0
  159. data/resources/kernel-4.2/metadata.xsd +479 -0
  160. data/resources/kernel-4.3/include/datacite-contributorType-v4.xsd +35 -0
  161. data/resources/kernel-4.3/include/datacite-dateType-v4.xsd +25 -0
  162. data/resources/kernel-4.3/include/datacite-descriptionType-v4.xsd +19 -0
  163. data/resources/kernel-4.3/include/datacite-funderIdentifierType-v4.xsd +16 -0
  164. data/resources/kernel-4.3/include/datacite-nameType-v4.xsd +10 -0
  165. data/resources/kernel-4.3/include/datacite-relatedIdentifierType-v4.xsd +34 -0
  166. data/resources/kernel-4.3/include/datacite-relationType-v4.xsd +49 -0
  167. data/resources/kernel-4.3/include/datacite-resourceType-v4.xsd +28 -0
  168. data/resources/kernel-4.3/include/datacite-titleType-v4.xsd +14 -0
  169. data/resources/kernel-4.3/include/xml.xsd +286 -0
  170. data/resources/kernel-4.3/metadata.xsd +515 -0
  171. data/resources/kernel-4.4/include/datacite-contributorType-v4.xsd +35 -0
  172. data/resources/kernel-4.4/include/datacite-dateType-v4.xsd +25 -0
  173. data/resources/kernel-4.4/include/datacite-descriptionType-v4.xsd +19 -0
  174. data/resources/kernel-4.4/include/datacite-funderIdentifierType-v4.xsd +16 -0
  175. data/resources/kernel-4.4/include/datacite-nameType-v4.xsd +10 -0
  176. data/resources/kernel-4.4/include/datacite-numberType-v4.xsd +12 -0
  177. data/resources/kernel-4.4/include/datacite-relatedIdentifierType-v4.xsd +34 -0
  178. data/resources/kernel-4.4/include/datacite-relationType-v4.xsd +51 -0
  179. data/resources/kernel-4.4/include/datacite-resourceType-v4.xsd +43 -0
  180. data/resources/kernel-4.4/include/datacite-titleType-v4.xsd +14 -0
  181. data/resources/kernel-4.4/include/xml.xsd +286 -0
  182. data/resources/kernel-4.4/metadata.xsd +707 -0
  183. data/resources/kernel-4.5/include/datacite-contributorType-v4.xsd +35 -0
  184. data/resources/kernel-4.5/include/datacite-dateType-v4.xsd +25 -0
  185. data/resources/kernel-4.5/include/datacite-descriptionType-v4.xsd +19 -0
  186. data/resources/kernel-4.5/include/datacite-funderIdentifierType-v4.xsd +16 -0
  187. data/resources/kernel-4.5/include/datacite-nameType-v4.xsd +10 -0
  188. data/resources/kernel-4.5/include/datacite-numberType-v4.xsd +12 -0
  189. data/resources/kernel-4.5/include/datacite-relatedIdentifierType-v4.xsd +34 -0
  190. data/resources/kernel-4.5/include/datacite-relationType-v4.xsd +53 -0
  191. data/resources/kernel-4.5/include/datacite-resourceType-v4.xsd +45 -0
  192. data/resources/kernel-4.5/include/datacite-titleType-v4.xsd +14 -0
  193. data/resources/kernel-4.5/include/xml.xsd +286 -0
  194. data/resources/kernel-4.5/metadata.xsd +711 -0
  195. data/resources/kernel-4.6/include/datacite-contributorType-v4.xsd +37 -0
  196. data/resources/kernel-4.6/include/datacite-dateType-v4.xsd +27 -0
  197. data/resources/kernel-4.6/include/datacite-descriptionType-v4.xsd +19 -0
  198. data/resources/kernel-4.6/include/datacite-funderIdentifierType-v4.xsd +16 -0
  199. data/resources/kernel-4.6/include/datacite-nameType-v4.xsd +10 -0
  200. data/resources/kernel-4.6/include/datacite-numberType-v4.xsd +12 -0
  201. data/resources/kernel-4.6/include/datacite-relatedIdentifierType-v4.xsd +37 -0
  202. data/resources/kernel-4.6/include/datacite-relationType-v4.xsd +57 -0
  203. data/resources/kernel-4.6/include/datacite-resourceType-v4.xsd +49 -0
  204. data/resources/kernel-4.6/include/datacite-titleType-v4.xsd +14 -0
  205. data/resources/kernel-4.6/include/xml.xsd +286 -0
  206. data/resources/kernel-4.6/metadata.xsd +712 -0
  207. data/resources/kernel-4.7/include/datacite-contributorType-v4.xsd +37 -0
  208. data/resources/kernel-4.7/include/datacite-dateType-v4.xsd +27 -0
  209. data/resources/kernel-4.7/include/datacite-descriptionType-v4.xsd +19 -0
  210. data/resources/kernel-4.7/include/datacite-funderIdentifierType-v4.xsd +16 -0
  211. data/resources/kernel-4.7/include/datacite-nameType-v4.xsd +10 -0
  212. data/resources/kernel-4.7/include/datacite-numberType-v4.xsd +12 -0
  213. data/resources/kernel-4.7/include/datacite-relatedIdentifierType-v4.xsd +39 -0
  214. data/resources/kernel-4.7/include/datacite-relationType-v4.xsd +59 -0
  215. data/resources/kernel-4.7/include/datacite-resourceType-v4.xsd +52 -0
  216. data/resources/kernel-4.7/include/datacite-titleType-v4.xsd +14 -0
  217. data/resources/kernel-4.7/include/xml.xsd +286 -0
  218. data/resources/kernel-4.7/metadata.xsd +715 -0
  219. data/resources/oecd/dfg-mappings.json +1866 -0
  220. data/resources/oecd/for-mappings.json +1101 -0
  221. data/resources/oecd/fos-mappings.json +198 -0
  222. data/resources/schema_org/jsonldcontext.json +7477 -0
  223. data/resources/spdx/licenses.json +5297 -0
  224. data/resources/xml.xsd +286 -0
  225. metadata +466 -179
  226. data/.travis.yml +0 -23
  227. data/lib/bolognese/crossref.rb +0 -233
  228. data/lib/bolognese/datacite.rb +0 -176
  229. data/lib/bolognese/date_utils.rb +0 -48
  230. data/lib/bolognese/github.rb +0 -106
  231. data/lib/bolognese/orcid.rb +0 -24
  232. data/lib/bolognese/schema_org.rb +0 -170
  233. data/spec/cli_spec.rb +0 -56
  234. data/spec/crossref_spec.rb +0 -190
  235. data/spec/datacite_spec.rb +0 -93
  236. data/spec/datacite_utils_spec.rb +0 -159
  237. data/spec/doi_utils_spec.rb +0 -89
  238. data/spec/fixtures/crossref.xml +0 -742
  239. data/spec/fixtures/datacite.xml +0 -40
  240. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/read/crossref/as_crossref.yml +0 -760
  241. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/read/crossref/as_datacite.yml +0 -1476
  242. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/read/crossref/as_schema_org.yml +0 -1476
  243. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/read/datacite/as_datacite.yml +0 -214
  244. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/read/datacite/as_schema_org.yml +0 -384
  245. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/read/schema_org/as_datacite.yml +0 -653
  246. data/spec/fixtures/vcr_cassettes/Bolognese_CLI/read/schema_org/as_schema_org.yml +0 -653
  247. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/doi_registration_agency/crossref.yml +0 -971
  248. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/doi_registration_agency/datacite.yml +0 -971
  249. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/doi_registration_agency/medra.yml +0 -971
  250. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/doi_registration_agency/not_found.yml +0 -971
  251. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/DOI_with_ORCID_ID.yml +0 -506
  252. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/DOI_with_SICI_DOI.yml +0 -214
  253. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/DOI_with_data_citation.yml +0 -901
  254. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/date_in_future.yml +0 -305
  255. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/journal_article.yml +0 -1080
  256. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/not_found_error.yml +0 -183
  257. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/posted_content.yml +0 -389
  258. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_datacite_xml/DOI_with_ORCID_ID.yml +0 -506
  259. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_datacite_xml/DOI_with_data_citation.yml +0 -901
  260. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_datacite_xml/with_ORCID_ID.yml +0 -366
  261. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_datacite_xml/with_data_citation.yml +0 -719
  262. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_datacite_xml/with_editor.yml +0 -930
  263. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata_as_string/DOI_with_data_citation.yml +0 -719
  264. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/normalize_doi/SICI_doi.yml +0 -930
  265. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/normalize_doi/doi.yml +0 -930
  266. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/normalize_doi/doi_from_url_without_doi_proxy.yml +0 -930
  267. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/normalize_doi/doi_prefix_too_long.yml +0 -930
  268. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/normalize_doi/doi_prefix_with_string.yml +0 -930
  269. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/normalize_doi/doi_with_protocol.yml +0 -930
  270. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/normalize_doi/dx_doi_org_url.yml +0 -930
  271. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/normalize_doi/https_url.yml +0 -930
  272. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/normalize_doi/not_valid_doi_prefix.yml +0 -930
  273. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/normalize_ids/doi.yml +0 -930
  274. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/normalize_ids/url.yml +0 -930
  275. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/normalize_url/doi.yml +0 -930
  276. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/normalize_url/url.yml +0 -930
  277. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/parse_attribute/array.yml +0 -930
  278. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/parse_attribute/hash.yml +0 -930
  279. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/parse_attribute/nil.yml +0 -930
  280. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/parse_attribute/string.yml +0 -930
  281. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/parse_attributes/array.yml +0 -930
  282. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/parse_attributes/hash.yml +0 -930
  283. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/parse_attributes/nil.yml +0 -930
  284. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/parse_attributes/string.yml +0 -930
  285. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/validate_url/DOI.yml +0 -930
  286. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/validate_url/URL.yml +0 -930
  287. data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/validate_url/string.yml +0 -930
  288. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/BlogPosting.yml +0 -477
  289. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Dataset.yml +0 -1925
  290. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Date.yml +0 -458
  291. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata_as_string/Dataset.yml +0 -173
  292. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_alternate_identifiers/insert.yml +0 -173
  293. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_contributors/insert.yml +0 -173
  294. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_contributors/none.yml +0 -173
  295. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_creators/insert.yml +0 -173
  296. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_dates/insert.yml +0 -173
  297. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_descriptions/insert.yml +0 -155
  298. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_identifier/doi.yml +0 -173
  299. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_person/creator.yml +0 -173
  300. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_person/creator_given_and_family_name.yml +0 -173
  301. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_person/creator_only_name.yml +0 -173
  302. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_publication_year/insert.yml +0 -173
  303. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_publisher/insert.yml +0 -173
  304. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_related_identifiers/get_related_identifier_type.yml +0 -173
  305. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_related_identifiers/get_related_identifier_type_DOI.yml +0 -173
  306. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_related_identifiers/get_related_identifier_type_URL.yml +0 -173
  307. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_related_identifiers/insert.yml +0 -173
  308. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_related_identifiers/rel_identifiers.yml +0 -173
  309. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_resource_type/insert.yml +0 -173
  310. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_rights_list/insert.yml +0 -173
  311. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_subjects/insert.yml +0 -173
  312. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_titles/doi.yml +0 -173
  313. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_titles/insert.yml +0 -173
  314. data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_version/insert.yml +0 -173
  315. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_PID_provider/crossref.yml +0 -44
  316. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_PID_provider/crossref_doi_not_url.yml +0 -44
  317. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_PID_provider/datacite.yml +0 -44
  318. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_PID_provider/datacite_doi_http.yml +0 -44
  319. data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_PID_provider/orcid.yml +0 -44
  320. data/spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata/BlogPosting.yml +0 -632
  321. data/spec/fixtures/vcr_cassettes/Bolognese_SchemaOrg/get_metadata/not_found_error.yml +0 -93
  322. data/spec/metadata_spec.rb +0 -41
  323. data/spec/orcid_spec.rb +0 -23
  324. data/spec/schema_org_spec.rb +0 -33
  325. data/spec/spec_helper.rb +0 -88
  326. data/spec/utils_spec.rb +0 -107
data/.travis.yml DELETED
@@ -1,23 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.3
4
-
5
- before_install:
6
- - export TZ=Europe/Berlin
7
-
8
- install:
9
- - travis_retry bundle install
10
-
11
- script: bundle exec rspec
12
-
13
- notifications:
14
- email: false
15
-
16
- deploy:
17
- provider: rubygems
18
- api_key:
19
- secure: jNV7zS0e1cSV+oVCqRyolo16QHJFgba7vnFnbG1Nb4Xk3p/hQnE/WTvV0up7jXE9HVKDmMTPPVUfdtvyE/xsTlWNpjIaQ5NdAz+wf4fTkwN8in8AHvxL0V1Zj202cgn6Ikoy2Zwkg4eZTxo1PJ6niyyfMHd/XpaW7zRd7BBN3901DeR0qCsYTJaFF8cO5d/CeKBn0aCHv7vzqRvm+NsEgVmfNCgjQAvMfDZChrlYzUZlOpcmh01u2z0vZyRmsidmAehLRF6GcZpoL8CVBbyzHr6EVjOrI2XVikwj17j4hPLcEzB/gGyK6OUX4JuiSxdRYxAPApZY96SUbFFrfIDusHv1csgwznAlEF4VgerpHq8C5B+CylXHjreT17b5U2QBsr79z401a6m6aC+RM/RDu2lW1p93f/fAK/znBO3DyodlvmVYGN16PuA7g7pa8LYKwtZGSQmTlbAycwcbKHgvbdKmxYAFTOE6CWeginLM7bvOmF6IHcNGzBHK1I8xES0y1XQHFKYl4nT3cMEsA6aRRRQCIQwbr6FE8gyPZrs5P/W9vPM9p6cryXFaSJWbGbounr6lqQgtCmfDdqXPxAszTbcBu/yBukxeM3KvRVrsbtuIanuHn1ppvA31M4bUGTP9CfwKojE9bdo6m7nfHTpjNy7eqOPuUH33cQhIPMCvpZ4=
20
- gem: bolognese
21
- on:
22
- tags: true
23
- repo: datacite/bolognese
@@ -1,233 +0,0 @@
1
- module Bolognese
2
- class Crossref < Metadata
3
-
4
- # CrossRef types from https://api.crossref.org/types
5
- CR_TO_SO_TRANSLATIONS = {
6
- "Proceedings" => nil,
7
- "ReferenceBook" => nil,
8
- "JournalIssue" => nil,
9
- "ProceedingsArticle" => nil,
10
- "Other" => nil,
11
- "Dissertation" => "Thesis",
12
- "Dataset" => "Dataset",
13
- "EditedBook" => "Book",
14
- "JournalArticle" => "ScholarlyArticle",
15
- "Journal" => nil,
16
- "Report" => nil,
17
- "BookSeries" => nil,
18
- "ReportSeries" => nil,
19
- "BookTrack" => nil,
20
- "Standard" => nil,
21
- "BookSection" => nil,
22
- "BookPart" => nil,
23
- "Book" => "Book",
24
- "BookChapter" => "Chapter",
25
- "StandardSeries" => nil,
26
- "Monograph" => "Book",
27
- "Component" => nil,
28
- "ReferenceEntry" => nil,
29
- "JournalVolume" => nil,
30
- "BookSet" => nil,
31
- "PostedContent" => nil
32
- }
33
-
34
- attr_reader = :id, :raw, :metadata, :schema_org
35
-
36
- def initialize(id: nil, string: nil)
37
- id = normalize_doi(id) if id.present?
38
-
39
- if string.present?
40
- @raw = string
41
- elsif id.present?
42
- response = Maremma.get(id, accept: "application/vnd.crossref.unixref+xml", host: true, raw: true)
43
- @raw = response.body.fetch("data", nil)
44
- end
45
- end
46
-
47
- def metadata
48
- @metadata ||= raw.present? ? Maremma.from_xml(raw).fetch("doi_records", {}).fetch("doi_record", {}) : {}
49
- end
50
-
51
- def exists?
52
- metadata.present?
53
- end
54
-
55
- def doi
56
- bibliographic_metadata.dig("doi_data", "doi")
57
- end
58
-
59
- def id
60
- normalize_doi(doi)
61
- end
62
-
63
- def journal_metadata
64
- metadata.dig("crossref", "journal", "journal_metadata").presence || {}
65
- end
66
-
67
- def bibliographic_metadata
68
- if metadata.dig("crossref", "journal", "journal_article").present?
69
- metadata.dig("crossref", "journal", "journal_article")
70
- else
71
- k = metadata.fetch("crossref", {}).keys.last
72
- metadata.dig("crossref", k).presence || {}
73
- end
74
- end
75
-
76
- def program_metadata
77
- bibliographic_metadata.dig("program") ||
78
- bibliographic_metadata.dig("crossmark", "custom_metadata", "program") || {}
79
- end
80
-
81
- def additional_type
82
- if metadata.dig("crossref", "journal").present?
83
- metadata.dig("crossref", "journal").keys.last.camelize
84
- else
85
- metadata.dig("crossref").keys.last.camelize
86
- end
87
- end
88
-
89
- def type
90
- CR_TO_SO_TRANSLATIONS[additional_type] || "CreativeWork"
91
- end
92
-
93
- def name
94
- parse_attribute(bibliographic_metadata.dig("titles", "title"))
95
- end
96
-
97
- def alternate_name
98
- if bibliographic_metadata.fetch("publisher_item", nil).present?
99
- parse_attribute(bibliographic_metadata.dig("publisher_item", "item_number"))
100
- else
101
- parse_attribute(bibliographic_metadata.fetch("item_number", nil))
102
- end
103
- end
104
-
105
- def description
106
- des = bibliographic_metadata.fetch("abstract", {}).values.first
107
- if des.is_a?(Hash)
108
- des.to_xml
109
- elsif des.is_a?(String)
110
- des
111
- end
112
- end
113
-
114
- def license
115
- access_indicator = Array.wrap(program_metadata).find { |m| m["name"] == "AccessIndicators" }
116
- if access_indicator.present?
117
- parse_attribute(access_indicator["license_ref"])
118
- else
119
- nil
120
- end
121
- end
122
-
123
- def keywords
124
-
125
- end
126
-
127
- def author
128
- person = bibliographic_metadata.dig("contributors", "person_name")
129
- Array(person).select { |a| a["contributor_role"] == "author" }.map do |a|
130
- { "@type" => "Person",
131
- "@id" => parse_attribute(a["ORCID"]),
132
- "givenName" => a["given_name"],
133
- "familyName" => a["surname"] }.compact
134
- end
135
- end
136
-
137
- def editor
138
- person = bibliographic_metadata.dig("contributors", "person_name")
139
- Array(person).select { |a| a["contributor_role"] == "editor" }.map do |a|
140
- { "@type" => "Person",
141
- "@id" => parse_attribute(a["ORCID"]),
142
- "givenName" => a["given_name"],
143
- "familyName" => a["surname"] }.compact
144
- end.presence
145
- end
146
-
147
- def version
148
-
149
- end
150
-
151
- def date_created
152
-
153
- end
154
-
155
- def date_published
156
- pub_date = bibliographic_metadata.fetch("publication_date", nil) ||
157
- bibliographic_metadata.fetch("acceptance_date", nil)
158
- if pub_date.present?
159
- get_date_from_parts(pub_date["year"], pub_date["month"], pub_date["day"])
160
- else
161
- nil
162
- end
163
- end
164
-
165
- def date_modified
166
- Time.parse(metadata.fetch("timestamp", "")).utc.iso8601
167
- end
168
-
169
- def page_start
170
- bibliographic_metadata.dig("pages", "first_page")
171
- end
172
-
173
- def page_end
174
- bibliographic_metadata.dig("pages", "last_page")
175
- end
176
-
177
- def is_part_of
178
- if journal_metadata.present?
179
- { "@type" => "Periodical",
180
- "name" => journal_metadata["full_title"],
181
- "issn" => parse_attribute(journal_metadata.fetch("issn", nil)) }.compact
182
- else
183
- nil
184
- end
185
- end
186
-
187
- def container_title
188
- is_part_of.fetch("name", nil)
189
- end
190
-
191
- def has_part
192
-
193
- end
194
-
195
- def citation
196
- citations = bibliographic_metadata.dig("citation_list", "citation")
197
- Array.wrap(citations).map do |c|
198
- { "@type" => "CreativeWork",
199
- "@id" => normalize_url(c["doi"]),
200
- "position" => c["key"],
201
- "name" => c["article_title"],
202
- "datePublished" => c["cYear"] }.compact
203
- end.presence
204
- end
205
-
206
- def provider
207
- { "@type" => "Organization",
208
- "name" => "Crossref" }
209
- end
210
-
211
- def as_schema_org
212
- { "@context" => "http://schema.org",
213
- "@type" => type,
214
- "@id" => id,
215
- "additionalType" => additional_type,
216
- "name" => name,
217
- "alternateName" => alternate_name,
218
- "author" => author,
219
- "editor" => editor,
220
- "description" => description,
221
- "license" => license,
222
- "datePublished" => date_published,
223
- "dateModified" => date_modified,
224
- "pageStart" => page_start,
225
- "pageEnd" => page_end,
226
- "isPartOf" => is_part_of,
227
- "hasPart" => has_part,
228
- "citation" => citation,
229
- "provider" => provider
230
- }.compact
231
- end
232
- end
233
- end
@@ -1,176 +0,0 @@
1
- module Bolognese
2
- class Datacite < Metadata
3
-
4
- DC_TO_SO_TRANSLATIONS = {
5
- "Audiovisual" => "VideoObject",
6
- "Collection" => "Collection",
7
- "Dataset" => "Dataset",
8
- "Event" => "Event",
9
- "Image" => "ImageObject",
10
- "InteractiveResource" => nil,
11
- "Model" => nil,
12
- "PhysicalObject" => nil,
13
- "Service" => "Service",
14
- "Software" => "SoftwareSourceCode",
15
- "Sound" => "AudioObject",
16
- "Text" => "ScholarlyArticle",
17
- "Workflow" => nil,
18
- "Other" => "CreativeWork"
19
- }
20
-
21
- attr_reader = :id, :raw, :metadata, :schema_org
22
-
23
- def initialize(id: nil, string: nil)
24
- id = normalize_doi(id) if id.present?
25
-
26
- if string.present?
27
- @raw = string
28
- elsif id.present?
29
- response = Maremma.get(id, accept: "application/vnd.datacite.datacite+xml", raw: true)
30
- @raw = response.body.fetch("data", nil)
31
- end
32
- end
33
-
34
- def metadata
35
- @metadata ||= raw.present? ? Maremma.from_xml(raw).fetch("resource", {}) : {}
36
- end
37
-
38
- def exists?
39
- metadata.present?
40
- end
41
-
42
- def doi
43
- metadata.fetch("identifier", {}).fetch("text", nil)
44
- end
45
-
46
- def id
47
- normalize_doi(doi)
48
- end
49
-
50
- def type
51
- k = metadata.dig("resourceType", "resourceTypeGeneral")
52
- DC_TO_SO_TRANSLATIONS[k.to_s.dasherize] || "CreativeWork"
53
- end
54
-
55
- def additional_type
56
- metadata.fetch("resourceType", {}).fetch("text", nil) ||
57
- metadata.fetch("resourceType", {}).fetch("resourceTypeGeneral", nil)
58
- end
59
-
60
- def name
61
- metadata.dig("titles", "title")
62
- end
63
-
64
- def alternate_name
65
- metadata.dig("alternateIdentifiers", "alternateIdentifier", "text")
66
- end
67
-
68
- def description
69
- des = metadata.dig("descriptions", "description", "text")
70
- if des.is_a?(Hash)
71
- des.to_xml
72
- elsif des.is_a?(String)
73
- des.strip
74
- end
75
- end
76
-
77
- def license
78
- metadata.dig("rightsList", "rights", "rightsURI")
79
- end
80
-
81
- def keywords
82
- Array(metadata.dig("subjects", "subject")).join(", ")
83
- end
84
-
85
- def author
86
- authors = metadata.dig("creators", "creator")
87
- authors = [authors] if authors.is_a?(Hash)
88
- get_authors(authors)
89
- end
90
-
91
- def editor
92
-
93
- end
94
-
95
- def version
96
- metadata.fetch("version", nil)
97
- end
98
-
99
- def dates
100
- Array.wrap(metadata.dig("dates", "date"))
101
- end
102
-
103
- def date_created
104
- created = dates.find { |d| d["dateType"] == "Created" } || {}
105
- created.fetch("text", nil)
106
- end
107
-
108
- def date_published
109
- published = dates.find { |d| d["dateType"] == "Issued" } || {}
110
- published.fetch("text", nil) || metadata.fetch("publicationYear")
111
- end
112
-
113
- def date_modified
114
- modified = dates.find { |d| d["dateType"] == "Updated" } || {}
115
- modified.fetch("text", nil)
116
- end
117
-
118
- def related_identifiers(relation_type)
119
- Array(metadata.dig("relatedIdentifiers", "relatedIdentifier"))
120
- .select { |r| relation_type.split(" ").include?(r["relationType"]) && %w(DOI URL).include?(r["relatedIdentifierType"]) }
121
- .map do |work|
122
- work_id = work["relatedIdentifierType"] == "DOI" ? normalize_doi(work["text"]) : work["text"]
123
- { "@type" => "CreativeWork",
124
- "@id" => work_id }
125
- end
126
- end
127
-
128
- def is_part_of
129
- related_identifiers("IsPartOf").first
130
- end
131
-
132
- def has_part
133
- related_identifiers("HasPart").presence
134
- end
135
-
136
- def citation
137
- related_identifiers("Cites IsCitedBy Supplements IsSupplementTo References IsReferencedBy").presence
138
- end
139
-
140
- def publisher
141
- { "@type" => "Organization",
142
- "name" => metadata.fetch("publisher") }
143
- end
144
-
145
- def container_title
146
- publisher.fetch("name", nil)
147
- end
148
-
149
- def provider
150
- { "@type" => "Organization",
151
- "name" => "DataCite" }
152
- end
153
-
154
- def as_schema_org
155
- { "@context" => "http://schema.org",
156
- "@type" => type,
157
- "@id" => id,
158
- "name" => name,
159
- "alternateName" => alternate_name,
160
- "author" => author,
161
- "description" => description,
162
- "license" => license,
163
- "version" => version,
164
- "keywords" => keywords,
165
- "dateCreated" => date_created,
166
- "datePublished" => date_published,
167
- "dateModified" => date_modified,
168
- "isPartOf" => is_part_of,
169
- "hasPart" => has_part,
170
- "citation" => citation,
171
- "publisher" => publisher,
172
- "provider" => provider
173
- }.compact
174
- end
175
- end
176
- end
@@ -1,48 +0,0 @@
1
- module Bolognese
2
- module DateUtils
3
- def get_date_parts(iso8601_time)
4
- return { "date_parts" => [[]] } if iso8601_time.nil?
5
-
6
- year = iso8601_time[0..3].to_i
7
- month = iso8601_time[5..6].to_i
8
- day = iso8601_time[8..9].to_i
9
- { 'date-parts' => [[year, month, day].reject { |part| part == 0 }] }
10
- end
11
-
12
- def get_year_month(iso8601_time)
13
- return [] if iso8601_time.nil?
14
-
15
- year = iso8601_time[0..3]
16
- month = iso8601_time[5..6]
17
-
18
- [year.to_i, month.to_i].reject { |part| part == 0 }
19
- end
20
-
21
- def get_year_month_day(iso8601_time)
22
- return [] if iso8601_time.nil?
23
-
24
- year = iso8601_time[0..3]
25
- month = iso8601_time[5..6]
26
- day = iso8601_time[8..9]
27
-
28
- [year.to_i, month.to_i, day.to_i].reject { |part| part == 0 }
29
- end
30
-
31
- def get_date_parts_from_parts(year, month = nil, day = nil)
32
- { 'date-parts' => [[year.to_i, month.to_i, day.to_i].reject { |part| part == 0 }] }
33
- end
34
-
35
- def get_date_from_parts(year, month = nil, day = nil)
36
- [year.to_s.rjust(4, '0'), month.to_s.rjust(2, '0'), day.to_s.rjust(2, '0')].reject { |part| part == "00" }.join("-")
37
- end
38
-
39
- # parsing of incomplete iso8601 timestamps such as 2015-04 is broken
40
- # in standard library
41
- # return nil if invalid iso8601 timestamp
42
- def get_datetime_from_iso8601(iso8601_time)
43
- ISO8601::DateTime.new(iso8601_time).to_time.utc
44
- rescue
45
- nil
46
- end
47
- end
48
- end
@@ -1,106 +0,0 @@
1
- module Bolognese
2
- class Github < Metadata
3
- # def get_github_metadata(url, options = {})
4
- # return {} if url.blank?
5
-
6
- # github_hash = github_from_url(url)
7
- # repo_url = "https://api.github.com/repos/#{github_hash[:owner]}/#{github_hash[:repo]}"
8
- # response = Maremma.get(repo_url, options.merge(bearer: ENV['GITHUB_PERSONAL_ACCESS_TOKEN']))
9
-
10
- # return { error: 'Resource not found.', status: 404 } if response.body.fetch("errors", nil).present?
11
-
12
- # author = get_github_owner(github_hash[:owner])
13
-
14
- # language = response.body.fetch("data", {}).fetch('language', nil)
15
- # type = language.present? && language != "HTML" ? 'computer_program' : 'webpage'
16
-
17
- # { "author" => [get_one_author(author)],
18
- # "title" => response.body.fetch("data", {}).fetch('description', nil).presence || github_hash[:repo],
19
- # "container-title" => "Github",
20
- # "issued" => response.body.fetch("data", {}).fetch('created_at', nil).presence || "0000",
21
- # "URL" => url,
22
- # "type" => type }
23
- # end
24
-
25
- # def get_github_owner_metadata(url, options = {})
26
- # return {} if url.blank?
27
-
28
- # github_hash = github_from_url(url)
29
- # owner_url = "https://api.github.com/users/#{github_hash[:owner]}"
30
- # response = Maremma.get(owner_url, options.merge(bearer: ENV['GITHUB_PERSONAL_ACCESS_TOKEN']))
31
-
32
- # return { error: 'Resource not found.', status: 404 } if response.body.fetch("data", {}).fetch("message", nil) == "Not Found"
33
-
34
- # author = response.body.fetch("data", {}).fetch('name', nil).presence || github_hash[:owner]
35
- # title = "Github profile for #{author}"
36
-
37
- # { "author" => [get_one_author(author)],
38
- # "title" => title,
39
- # "container-title" => "Github",
40
- # "issued" => response.body.fetch("data", {}).fetch('created_at', nil).presence || "0000",
41
- # "URL" => url,
42
- # "type" => 'entry' }
43
- # end
44
-
45
- # def get_github_release_metadata(url, options = {})
46
- # return {} if url.blank?
47
-
48
- # github_hash = github_from_url(url)
49
- # release_url = "https://api.github.com/repos/#{github_hash[:owner]}/#{github_hash[:repo]}/releases/tags/#{github_hash[:release]}"
50
- # response = Maremma.get(release_url, options.merge(bearer: ENV['GITHUB_PERSONAL_ACCESS_TOKEN']))
51
-
52
- # return { error: 'Resource not found.', status: 404 } if response.body.fetch("data", {})["message"] == "Not Found"
53
-
54
- # author = get_github_owner(github_hash[:owner])
55
-
56
- # { "author" => [get_one_author(author)],
57
- # "title" => response.body.fetch("data", {}).fetch('name', nil),
58
- # "container-title" => "Github",
59
- # "issued" => response.body.fetch("data", {}).fetch('created_at', nil).presence || "0000",
60
- # "URL" => url,
61
- # "type" => 'computer_program' }
62
- # end
63
-
64
- # def get_github_owner(owner)
65
- # url = "https://api.github.com/users/#{owner}"
66
- # response = Maremma.get(url, bearer: ENV['GITHUB_PERSONAL_ACCESS_TOKEN'])
67
-
68
- # return nil if response.body.fetch("data", {}).fetch("message", nil) == "Not Found"
69
-
70
- # response.body.fetch("data", {}).fetch('name', nil).presence || owner
71
- # end
72
-
73
- # def github_from_url(url)
74
- # return {} unless /\Ahttps:\/\/github\.com\/(.+)(?:\/)?(.+)?(?:\/tree\/)?(.*)\z/.match(url)
75
- # words = URI.parse(url).path[1..-1].split('/')
76
-
77
- # { owner: words[0],
78
- # repo: words[1],
79
- # release: words[3] }.compact
80
- # end
81
-
82
- # def github_repo_from_url(url)
83
- # github_from_url(url).fetch(:repo, nil)
84
- # end
85
-
86
- # def github_release_from_url(url)
87
- # github_from_url(url).fetch(:release, nil)
88
- # end
89
-
90
- # def github_owner_from_url(url)
91
- # github_from_url(url).fetch(:owner, nil)
92
- # end
93
-
94
- # def github_as_owner_url(github_hash)
95
- # "https://github.com/#{github_hash[:owner]}" if github_hash[:owner].present?
96
- # end
97
-
98
- # def github_as_repo_url(github_hash)
99
- # "https://github.com/#{github_hash[:owner]}/#{github_hash[:repo]}" if github_hash[:repo].present?
100
- # end
101
-
102
- # def github_as_release_url(github_hash)
103
- # "https://github.com/#{github_hash[:owner]}/#{github_hash[:repo]}/tree/#{github_hash[:release]}" if github_hash[:release].present?
104
- # end
105
- end
106
- end
@@ -1,24 +0,0 @@
1
- module Bolognese
2
- class Orcid < Metadata
3
- include Bolognese::Utils
4
- # def get_orcid_metadata(orcid, options = {})
5
- # return {} if orcid.blank?
6
-
7
- # url = "https://pub.orcid.org/v2.0/#{orcid}/person"
8
- # response = Maremma.get(url, options.merge(accept: "json"))
9
-
10
- # name = response.body.fetch("data", {}).fetch("name", nil)
11
- # return { "errors" => 'Resource not found.' } unless name.present?
12
-
13
- # author = { "family" => name.fetch("family-name", {}).fetch("value", nil),
14
- # "given" => name.fetch("given-names", {}).fetch("value", nil) }
15
-
16
- # { "author" => [author],
17
- # "title" => "ORCID record for #{[author.fetch('given', nil), author.fetch('family', nil)].compact.join(' ')}",
18
- # "container-title" => "ORCID Registry",
19
- # "issued" => Time.now.year.to_s,
20
- # "URL" => orcid_as_url(orcid),
21
- # "type" => 'entry' }
22
- # end
23
- end
24
- end