bolognese 0.2.2 → 2.7.0
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.
- checksums.yaml +5 -5
- data/.github/workflows/build.yml +9 -0
- data/.github/workflows/changelog.yml +36 -0
- data/.github/workflows/ci.yml +22 -0
- data/.github/workflows/pull-request.yml +9 -0
- data/.github/workflows/release.yml +32 -0
- data/.gitignore +4 -0
- data/.rubocop.yml +658 -0
- data/CHANGELOG.md +1864 -0
- data/CITATION +17 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +251 -99
- data/README.md +1026 -2
- data/Rakefile +1 -0
- data/bin/bolognese +5 -1
- data/bolognese.gemspec +33 -21
- data/lib/bolognese/array.rb +13 -0
- data/lib/bolognese/author_utils.rb +115 -39
- data/lib/bolognese/citeproc_extensions.rb +48 -0
- data/lib/bolognese/cli.rb +28 -15
- data/lib/bolognese/datacite_utils.rb +418 -0
- data/lib/bolognese/doi_utils.rb +45 -23
- data/lib/bolognese/metadata.rb +250 -18
- data/lib/bolognese/metadata_utils.rb +228 -0
- data/lib/bolognese/pubmed.rb +2 -0
- data/lib/bolognese/readers/bibtex_reader.rb +100 -0
- data/lib/bolognese/readers/citeproc_reader.rb +125 -0
- data/lib/bolognese/readers/codemeta_reader.rb +108 -0
- data/lib/bolognese/readers/crosscite_reader.rb +17 -0
- data/lib/bolognese/readers/crossref_reader.rb +413 -0
- data/lib/bolognese/readers/datacite_json_reader.rb +17 -0
- data/lib/bolognese/readers/datacite_reader.rb +338 -0
- data/lib/bolognese/readers/npm_reader.rb +115 -0
- data/lib/bolognese/readers/ris_reader.rb +114 -0
- data/lib/bolognese/readers/schema_org_reader.rb +264 -0
- data/lib/bolognese/string.rb +3 -1
- data/lib/bolognese/utils.rb +1403 -12
- data/lib/bolognese/version.rb +1 -1
- data/lib/bolognese/whitelist_scrubber.rb +47 -0
- data/lib/bolognese/writers/bibtex_writer.rb +32 -0
- data/lib/bolognese/writers/citation_writer.rb +14 -0
- data/lib/bolognese/writers/citeproc_writer.rb +11 -0
- data/lib/bolognese/writers/codemeta_writer.rb +29 -0
- data/lib/bolognese/writers/crosscite_writer.rb +11 -0
- data/lib/bolognese/writers/crossref_writer.rb +11 -0
- data/lib/bolognese/writers/csv_writer.rb +24 -0
- data/lib/bolognese/writers/datacite_json_writer.rb +13 -0
- data/lib/bolognese/writers/datacite_writer.rb +12 -0
- data/lib/bolognese/writers/jats_writer.rb +138 -0
- data/lib/bolognese/writers/rdf_xml_writer.rb +11 -0
- data/lib/bolognese/writers/ris_writer.rb +29 -0
- data/lib/bolognese/writers/schema_org_writer.rb +55 -0
- data/lib/bolognese/writers/turtle_writer.rb +11 -0
- data/lib/bolognese.rb +19 -4
- data/package.json +12 -0
- data/resources/2008/09/xsd.xsl +997 -0
- data/resources/datacite-contributorType-v4.xsd +35 -0
- data/resources/datacite-dateType-v4.xsd +25 -0
- data/resources/datacite-descriptionType-v4.xsd +19 -0
- data/resources/datacite-funderIdentifierType-v4.xsd +15 -0
- data/resources/datacite-nameType-v4.xsd +10 -0
- data/resources/datacite-relatedIdentifierType-v4.xsd +34 -0
- data/resources/datacite-relationType-v4.xsd +49 -0
- data/resources/datacite-resourceType-v4.xsd +28 -0
- data/resources/datacite-titleType-v4.xsd +14 -0
- data/resources/kernel-2.1/include/datacite-contributorType-v1.1.xsd +22 -0
- data/resources/kernel-2.1/include/datacite-contributorType-v2.xsd +3 -0
- data/resources/kernel-2.1/include/datacite-dateType-v1.1.xsd +31 -0
- data/resources/kernel-2.1/include/datacite-dateType-v2.xsd +3 -0
- data/resources/kernel-2.1/include/datacite-descriptionType-v1.1.xsd +14 -0
- data/resources/kernel-2.1/include/datacite-descriptionType-v2.xsd +3 -0
- data/resources/kernel-2.1/include/datacite-relatedIdentifierType-v1.1.xsd +24 -0
- data/resources/kernel-2.1/include/datacite-relatedIdentifierType-v2.xsd +3 -0
- data/resources/kernel-2.1/include/datacite-relationType-v1.1.xsd +29 -0
- data/resources/kernel-2.1/include/datacite-relationType-v2.xsd +3 -0
- data/resources/kernel-2.1/include/datacite-resourceType-v1.1.xsd +22 -0
- data/resources/kernel-2.1/include/datacite-resourceType-v2.xsd +3 -0
- data/resources/kernel-2.1/include/datacite-titleType-v1.1.xsd +11 -0
- data/resources/kernel-2.1/include/datacite-titleType-v2.xsd +3 -0
- data/resources/kernel-2.1/metadata.xsd +315 -0
- data/resources/kernel-2.2/include/datacite-contributorType-v2.xsd +29 -0
- data/resources/kernel-2.2/include/datacite-dateType-v2.xsd +21 -0
- data/resources/kernel-2.2/include/datacite-descriptionType-v2.xsd +15 -0
- data/resources/kernel-2.2/include/datacite-relatedIdentifierType-v2.xsd +25 -0
- data/resources/kernel-2.2/include/datacite-relationType-v2.xsd +29 -0
- data/resources/kernel-2.2/include/datacite-resourceType-v2.xsd +23 -0
- data/resources/kernel-2.2/include/datacite-titleType-v2.xsd +10 -0
- data/resources/kernel-2.2/metadata.xsd +316 -0
- data/resources/kernel-3/include/datacite-contributorType-v3.1.xsd +35 -0
- data/resources/kernel-3/include/datacite-dateType-v3.xsd +21 -0
- data/resources/kernel-3/include/datacite-descriptionType-v3.xsd +17 -0
- data/resources/kernel-3/include/datacite-relatedIdentifierType-v3.1.xsd +30 -0
- data/resources/kernel-3/include/datacite-relationType-v3.1.xsd +38 -0
- data/resources/kernel-3/include/datacite-resourceType-v3.xsd +26 -0
- data/resources/kernel-3/include/datacite-titleType-v3.xsd +12 -0
- data/resources/kernel-3/include/xml.xsd +286 -0
- data/resources/kernel-3/metadata.xsd +380 -0
- data/resources/kernel-3.0/include/datacite-contributorType-v3.xsd +33 -0
- data/resources/kernel-3.0/include/datacite-dateType-v3.xsd +21 -0
- data/resources/kernel-3.0/include/datacite-descriptionType-v3.xsd +17 -0
- data/resources/kernel-3.0/include/datacite-relatedIdentifierType-v3.xsd +27 -0
- data/resources/kernel-3.0/include/datacite-relationType-v3.xsd +33 -0
- data/resources/kernel-3.0/include/datacite-resourceType-v3.xsd +26 -0
- data/resources/kernel-3.0/include/datacite-titleType-v3.xsd +12 -0
- data/resources/kernel-3.0/include/xml.xsd +286 -0
- data/resources/kernel-3.0/metadata.xsd +377 -0
- data/resources/kernel-3.1/include/datacite-contributorType-v3.1.xsd +35 -0
- data/resources/kernel-3.1/include/datacite-dateType-v3.xsd +21 -0
- data/resources/kernel-3.1/include/datacite-descriptionType-v3.xsd +17 -0
- data/resources/kernel-3.1/include/datacite-relatedIdentifierType-v3.1.xsd +30 -0
- data/resources/kernel-3.1/include/datacite-relationType-v3.1.xsd +38 -0
- data/resources/kernel-3.1/include/datacite-resourceType-v3.xsd +26 -0
- data/resources/kernel-3.1/include/datacite-titleType-v3.xsd +12 -0
- data/resources/kernel-3.1/include/xml.xsd +286 -0
- data/resources/kernel-3.1/metadata.xsd +380 -0
- data/resources/kernel-4/include/datacite-contributorType-v4.xsd +37 -0
- data/resources/kernel-4/include/datacite-dateType-v4.xsd +27 -0
- data/resources/kernel-4/include/datacite-descriptionType-v4.xsd +19 -0
- data/resources/kernel-4/include/datacite-funderIdentifierType-v4.xsd +16 -0
- data/resources/kernel-4/include/datacite-nameType-v4.xsd +10 -0
- data/resources/kernel-4/include/datacite-numberType-v4.xsd +12 -0
- data/resources/kernel-4/include/datacite-relatedIdentifierType-v4.xsd +39 -0
- data/resources/kernel-4/include/datacite-relationType-v4.xsd +59 -0
- data/resources/kernel-4/include/datacite-resourceType-v4.xsd +52 -0
- data/resources/kernel-4/include/datacite-titleType-v4.xsd +14 -0
- data/resources/kernel-4/include/xml.xsd +286 -0
- data/resources/kernel-4/metadata.xsd +715 -0
- data/resources/kernel-4.0/include/datacite-contributorType-v4.xsd +35 -0
- data/resources/kernel-4.0/include/datacite-dateType-v4.xsd +21 -0
- data/resources/kernel-4.0/include/datacite-descriptionType-v4.xsd +19 -0
- data/resources/kernel-4.0/include/datacite-funderIdentifierType-v4.xsd +15 -0
- data/resources/kernel-4.0/include/datacite-relatedIdentifierType-v4.xsd +32 -0
- data/resources/kernel-4.0/include/datacite-relationType-v4.xsd +39 -0
- data/resources/kernel-4.0/include/datacite-resourceType-v4.xsd +26 -0
- data/resources/kernel-4.0/include/datacite-titleType-v4.xsd +14 -0
- data/resources/kernel-4.0/include/xml.xsd +286 -0
- data/resources/kernel-4.0/metadata.xsd +470 -0
- data/resources/kernel-4.1/include/datacite-contributorType-v4.xsd +35 -0
- data/resources/kernel-4.1/include/datacite-dateType-v4.1.xsd +23 -0
- data/resources/kernel-4.1/include/datacite-descriptionType-v4.xsd +19 -0
- data/resources/kernel-4.1/include/datacite-funderIdentifierType-v4.xsd +15 -0
- data/resources/kernel-4.1/include/datacite-nameType-v4.1.xsd +10 -0
- data/resources/kernel-4.1/include/datacite-relatedIdentifierType-v4.xsd +32 -0
- data/resources/kernel-4.1/include/datacite-relationType-v4.1.xsd +46 -0
- data/resources/kernel-4.1/include/datacite-resourceType-v4.1.xsd +28 -0
- data/resources/kernel-4.1/include/datacite-titleType-v4.xsd +14 -0
- data/resources/kernel-4.1/include/xml.xsd +286 -0
- data/resources/kernel-4.1/metadata.xsd +483 -0
- data/resources/kernel-4.2/include/datacite-contributorType-v4.xsd +35 -0
- data/resources/kernel-4.2/include/datacite-dateType-v4.xsd +25 -0
- data/resources/kernel-4.2/include/datacite-descriptionType-v4.xsd +19 -0
- data/resources/kernel-4.2/include/datacite-funderIdentifierType-v4.xsd +15 -0
- data/resources/kernel-4.2/include/datacite-nameType-v4.xsd +10 -0
- data/resources/kernel-4.2/include/datacite-relatedIdentifierType-v4.xsd +34 -0
- data/resources/kernel-4.2/include/datacite-relationType-v4.xsd +49 -0
- data/resources/kernel-4.2/include/datacite-resourceType-v4.xsd +28 -0
- data/resources/kernel-4.2/include/datacite-titleType-v4.xsd +14 -0
- data/resources/kernel-4.2/include/xml.xsd +286 -0
- data/resources/kernel-4.2/metadata.xsd +479 -0
- data/resources/kernel-4.3/include/datacite-contributorType-v4.xsd +35 -0
- data/resources/kernel-4.3/include/datacite-dateType-v4.xsd +25 -0
- data/resources/kernel-4.3/include/datacite-descriptionType-v4.xsd +19 -0
- data/resources/kernel-4.3/include/datacite-funderIdentifierType-v4.xsd +16 -0
- data/resources/kernel-4.3/include/datacite-nameType-v4.xsd +10 -0
- data/resources/kernel-4.3/include/datacite-relatedIdentifierType-v4.xsd +34 -0
- data/resources/kernel-4.3/include/datacite-relationType-v4.xsd +49 -0
- data/resources/kernel-4.3/include/datacite-resourceType-v4.xsd +28 -0
- data/resources/kernel-4.3/include/datacite-titleType-v4.xsd +14 -0
- data/resources/kernel-4.3/include/xml.xsd +286 -0
- data/resources/kernel-4.3/metadata.xsd +515 -0
- data/resources/kernel-4.4/include/datacite-contributorType-v4.xsd +35 -0
- data/resources/kernel-4.4/include/datacite-dateType-v4.xsd +25 -0
- data/resources/kernel-4.4/include/datacite-descriptionType-v4.xsd +19 -0
- data/resources/kernel-4.4/include/datacite-funderIdentifierType-v4.xsd +16 -0
- data/resources/kernel-4.4/include/datacite-nameType-v4.xsd +10 -0
- data/resources/kernel-4.4/include/datacite-numberType-v4.xsd +12 -0
- data/resources/kernel-4.4/include/datacite-relatedIdentifierType-v4.xsd +34 -0
- data/resources/kernel-4.4/include/datacite-relationType-v4.xsd +51 -0
- data/resources/kernel-4.4/include/datacite-resourceType-v4.xsd +43 -0
- data/resources/kernel-4.4/include/datacite-titleType-v4.xsd +14 -0
- data/resources/kernel-4.4/include/xml.xsd +286 -0
- data/resources/kernel-4.4/metadata.xsd +707 -0
- data/resources/kernel-4.5/include/datacite-contributorType-v4.xsd +35 -0
- data/resources/kernel-4.5/include/datacite-dateType-v4.xsd +25 -0
- data/resources/kernel-4.5/include/datacite-descriptionType-v4.xsd +19 -0
- data/resources/kernel-4.5/include/datacite-funderIdentifierType-v4.xsd +16 -0
- data/resources/kernel-4.5/include/datacite-nameType-v4.xsd +10 -0
- data/resources/kernel-4.5/include/datacite-numberType-v4.xsd +12 -0
- data/resources/kernel-4.5/include/datacite-relatedIdentifierType-v4.xsd +34 -0
- data/resources/kernel-4.5/include/datacite-relationType-v4.xsd +53 -0
- data/resources/kernel-4.5/include/datacite-resourceType-v4.xsd +45 -0
- data/resources/kernel-4.5/include/datacite-titleType-v4.xsd +14 -0
- data/resources/kernel-4.5/include/xml.xsd +286 -0
- data/resources/kernel-4.5/metadata.xsd +711 -0
- data/resources/kernel-4.6/include/datacite-contributorType-v4.xsd +37 -0
- data/resources/kernel-4.6/include/datacite-dateType-v4.xsd +27 -0
- data/resources/kernel-4.6/include/datacite-descriptionType-v4.xsd +19 -0
- data/resources/kernel-4.6/include/datacite-funderIdentifierType-v4.xsd +16 -0
- data/resources/kernel-4.6/include/datacite-nameType-v4.xsd +10 -0
- data/resources/kernel-4.6/include/datacite-numberType-v4.xsd +12 -0
- data/resources/kernel-4.6/include/datacite-relatedIdentifierType-v4.xsd +37 -0
- data/resources/kernel-4.6/include/datacite-relationType-v4.xsd +57 -0
- data/resources/kernel-4.6/include/datacite-resourceType-v4.xsd +49 -0
- data/resources/kernel-4.6/include/datacite-titleType-v4.xsd +14 -0
- data/resources/kernel-4.6/include/xml.xsd +286 -0
- data/resources/kernel-4.6/metadata.xsd +712 -0
- data/resources/kernel-4.7/include/datacite-contributorType-v4.xsd +37 -0
- data/resources/kernel-4.7/include/datacite-dateType-v4.xsd +27 -0
- data/resources/kernel-4.7/include/datacite-descriptionType-v4.xsd +19 -0
- data/resources/kernel-4.7/include/datacite-funderIdentifierType-v4.xsd +16 -0
- data/resources/kernel-4.7/include/datacite-nameType-v4.xsd +10 -0
- data/resources/kernel-4.7/include/datacite-numberType-v4.xsd +12 -0
- data/resources/kernel-4.7/include/datacite-relatedIdentifierType-v4.xsd +39 -0
- data/resources/kernel-4.7/include/datacite-relationType-v4.xsd +59 -0
- data/resources/kernel-4.7/include/datacite-resourceType-v4.xsd +52 -0
- data/resources/kernel-4.7/include/datacite-titleType-v4.xsd +14 -0
- data/resources/kernel-4.7/include/xml.xsd +286 -0
- data/resources/kernel-4.7/metadata.xsd +715 -0
- data/resources/oecd/dfg-mappings.json +1866 -0
- data/resources/oecd/for-mappings.json +1101 -0
- data/resources/oecd/fos-mappings.json +198 -0
- data/resources/schema_org/jsonldcontext.json +7477 -0
- data/resources/spdx/licenses.json +5297 -0
- data/resources/xml.xsd +286 -0
- metadata +478 -150
- data/.travis.yml +0 -23
- data/lib/bolognese/crossref.rb +0 -202
- data/lib/bolognese/datacite.rb +0 -157
- data/lib/bolognese/date_utils.rb +0 -48
- data/lib/bolognese/github.rb +0 -106
- data/lib/bolognese/orcid.rb +0 -24
- data/lib/bolognese/pid_utils.rb +0 -23
- data/spec/cli_spec.rb +0 -37
- data/spec/crossref_spec.rb +0 -113
- data/spec/datacite_spec.rb +0 -49
- data/spec/doi_spec.rb +0 -89
- data/spec/fixtures/crossref.xml +0 -742
- data/spec/fixtures/datacite.xml +0 -40
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/read/crossref/as_crossref.yml +0 -760
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/read/crossref/as_schema_org.yml +0 -1476
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/read/datacite/as_datacite.yml +0 -214
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/read/datacite/as_schema_org.yml +0 -384
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/doi_registration_agency/crossref.yml +0 -44
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/doi_registration_agency/datacite.yml +0 -44
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/doi_registration_agency/medra.yml +0 -44
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/doi_registration_agency/not_found.yml +0 -44
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/DOI_test.yml +0 -843
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/DOI_with_SICI_DOI.yml +0 -277
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/DOI_with_data_citation.yml +0 -15755
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/date_in_future.yml +0 -2691
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/journal_article.yml +0 -1857
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/not_found_error.yml +0 -93
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_metadata/posted_content.yml +0 -5715
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/BlogPosting.yml +0 -307
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/get_metadata/Dataset.yml +0 -343
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_PID_provider/crossref.yml +0 -44
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_PID_provider/crossref_doi_not_url.yml +0 -44
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_PID_provider/datacite.yml +0 -44
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_PID_provider/datacite_doi_http.yml +0 -44
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/find_PID_provider/orcid.yml +0 -44
- data/spec/metadata_spec.rb +0 -35
- data/spec/orcid_spec.rb +0 -23
- data/spec/spec_helper.rb +0 -88
- /data/{LICENSE → LICENSE.md} +0 -0
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
|
data/lib/bolognese/crossref.rb
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
require_relative 'doi_utils'
|
|
2
|
-
require_relative 'utils'
|
|
3
|
-
|
|
4
|
-
module Bolognese
|
|
5
|
-
class Crossref < Metadata
|
|
6
|
-
include Bolognese::DoiUtils
|
|
7
|
-
include Bolognese::Utils
|
|
8
|
-
|
|
9
|
-
# CrossRef types from https://api.crossref.org/types
|
|
10
|
-
CROSSREF_TYPE_TRANSLATIONS = {
|
|
11
|
-
"Proceedings" => nil,
|
|
12
|
-
"ReferenceBook" => nil,
|
|
13
|
-
"JournalIssue" => nil,
|
|
14
|
-
"ProceedingsArticle" => nil,
|
|
15
|
-
"Other" => nil,
|
|
16
|
-
"Dissertation" => "Thesis",
|
|
17
|
-
"Dataset" => "Dataset",
|
|
18
|
-
"EditedBook" => "Book",
|
|
19
|
-
"JournalArticle" => "ScholarlyArticle",
|
|
20
|
-
"Journal" => nil,
|
|
21
|
-
"Report" => nil,
|
|
22
|
-
"BookSeries" => nil,
|
|
23
|
-
"ReportSeries" => nil,
|
|
24
|
-
"BookTrack" => nil,
|
|
25
|
-
"Standard" => nil,
|
|
26
|
-
"BookSection" => nil,
|
|
27
|
-
"BookPart" => nil,
|
|
28
|
-
"Book" => "Book",
|
|
29
|
-
"BookChapter" => "Chapter",
|
|
30
|
-
"StandardSeries" => nil,
|
|
31
|
-
"Monograph" => "Book",
|
|
32
|
-
"Component" => nil,
|
|
33
|
-
"ReferenceEntry" => nil,
|
|
34
|
-
"JournalVolume" => nil,
|
|
35
|
-
"BookSet" => nil,
|
|
36
|
-
"PostedContent" => nil
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
attr_reader = :id, :metadata, :schema_org
|
|
40
|
-
|
|
41
|
-
def initialize(doi)
|
|
42
|
-
@id = normalize_doi(doi)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def raw
|
|
46
|
-
response = Maremma.get(@id, accept: "application/vnd.crossref.unixref+xml", host: true, raw: true)
|
|
47
|
-
@raw ||= response.body.fetch("data", nil)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def metadata
|
|
51
|
-
@metadata ||= raw.present? ? Maremma.from_xml(raw).fetch("doi_records", {}).fetch("doi_record", {}) : {}
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def exists?
|
|
55
|
-
metadata.present?
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def journal_metadata
|
|
59
|
-
metadata.dig("crossref", "journal", "journal_metadata").presence || {}
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def bibliographic_metadata
|
|
63
|
-
if metadata.dig("crossref", "journal", "journal_article").present?
|
|
64
|
-
metadata.dig("crossref", "journal", "journal_article")
|
|
65
|
-
else
|
|
66
|
-
k = metadata.dig("crossref").keys.last
|
|
67
|
-
metadata.dig("crossref", k).presence || {}
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def program_metadata
|
|
72
|
-
bibliographic_metadata.dig("program") ||
|
|
73
|
-
bibliographic_metadata.dig("crossmark", "custom_metadata", "program") || {}
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def additional_type
|
|
77
|
-
if metadata.dig("crossref", "journal").present?
|
|
78
|
-
metadata.dig("crossref", "journal").keys.last.camelize
|
|
79
|
-
else
|
|
80
|
-
metadata.dig("crossref").keys.last.camelize
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def type
|
|
85
|
-
CROSSREF_TYPE_TRANSLATIONS[additional_type] || "CreativeWork"
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def name
|
|
89
|
-
parse_attribute(bibliographic_metadata.dig("titles", "title"))
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def alternate_name
|
|
93
|
-
if bibliographic_metadata.fetch("publisher_item", nil).present?
|
|
94
|
-
parse_attribute(bibliographic_metadata.dig("publisher_item", "item_number"))
|
|
95
|
-
else
|
|
96
|
-
parse_attribute(bibliographic_metadata.fetch("item_number", nil))
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def description
|
|
101
|
-
bibliographic_metadata.fetch("abstract", {}).values.first
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def license
|
|
105
|
-
access_indicator = Array.wrap(program_metadata).find { |m| m["name"] == "AccessIndicators" }
|
|
106
|
-
if access_indicator.present?
|
|
107
|
-
parse_attribute(access_indicator["license_ref"])
|
|
108
|
-
else
|
|
109
|
-
nil
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def author
|
|
114
|
-
person = bibliographic_metadata.dig("contributors", "person_name")
|
|
115
|
-
Array(person).select { |a| a["contributor_role"] == "author" }.map do |a|
|
|
116
|
-
{ "@type" => "Person",
|
|
117
|
-
"@id" => a["ORCID"],
|
|
118
|
-
"givenName" => a["given_name"],
|
|
119
|
-
"familyName" => a["surname"] }.compact
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def editor
|
|
124
|
-
person = bibliographic_metadata.dig("contributors", "person_name")
|
|
125
|
-
Array(person).select { |a| a["contributor_role"] == "editor" }.map do |a|
|
|
126
|
-
{ "@type" => "Person",
|
|
127
|
-
"@id" => a["ORCID"],
|
|
128
|
-
"givenName" => a["given_name"],
|
|
129
|
-
"familyName" => a["surname"] }.compact
|
|
130
|
-
end.presence
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def date_published
|
|
134
|
-
pub_date = bibliographic_metadata.fetch("publication_date", nil) ||
|
|
135
|
-
bibliographic_metadata.fetch("acceptance_date", nil)
|
|
136
|
-
if pub_date.present?
|
|
137
|
-
get_date_from_parts(pub_date["year"], pub_date["month"], pub_date["day"])
|
|
138
|
-
else
|
|
139
|
-
nil
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
def date_modified
|
|
144
|
-
Time.parse(metadata.fetch("timestamp", "")).utc.iso8601
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
def page_start
|
|
148
|
-
bibliographic_metadata.dig("pages", "first_page")
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
def page_end
|
|
152
|
-
bibliographic_metadata.dig("pages", "last_page")
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
def is_part_of
|
|
156
|
-
if journal_metadata.present?
|
|
157
|
-
{ "@type" => "Periodical",
|
|
158
|
-
"name" => journal_metadata["full_title"],
|
|
159
|
-
"issn" => parse_attribute(journal_metadata.fetch("issn", nil)) }.compact
|
|
160
|
-
else
|
|
161
|
-
nil
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
def citation
|
|
166
|
-
citations = bibliographic_metadata.dig("citation_list", "citation")
|
|
167
|
-
Array(citations).map do |c|
|
|
168
|
-
{ "@type" => "CreativeWork",
|
|
169
|
-
"@id" => normalize_doi(c["doi"]),
|
|
170
|
-
"position" => c["key"],
|
|
171
|
-
"name" => c["article_title"],
|
|
172
|
-
"datePublished" => c["cYear"] }.compact
|
|
173
|
-
end.presence
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
def provider
|
|
177
|
-
{ "@type" => "Organization",
|
|
178
|
-
"name" => "Crossref" }
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
def as_schema_org
|
|
182
|
-
{ "@context" => "http://schema.org",
|
|
183
|
-
"@type" => type,
|
|
184
|
-
"@id" => id,
|
|
185
|
-
"additionalType" => additional_type,
|
|
186
|
-
"name" => name,
|
|
187
|
-
"alternateName" => alternate_name,
|
|
188
|
-
"author" => author,
|
|
189
|
-
"editor" => editor,
|
|
190
|
-
"description" => description,
|
|
191
|
-
"license" => license,
|
|
192
|
-
"datePublished" => date_published,
|
|
193
|
-
"dateModified" => date_modified,
|
|
194
|
-
"pageStart" => page_start,
|
|
195
|
-
"pageEnd" => page_end,
|
|
196
|
-
"isPartOf" => is_part_of,
|
|
197
|
-
"citation" => citation,
|
|
198
|
-
"provider" => provider
|
|
199
|
-
}.compact
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
end
|
data/lib/bolognese/datacite.rb
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
require_relative 'doi_utils'
|
|
2
|
-
require_relative 'utils'
|
|
3
|
-
|
|
4
|
-
module Bolognese
|
|
5
|
-
class Datacite < Metadata
|
|
6
|
-
include Bolognese::DoiUtils
|
|
7
|
-
include Bolognese::Utils
|
|
8
|
-
|
|
9
|
-
DATACITE_TYPE_TRANSLATIONS = {
|
|
10
|
-
"Audiovisual" => "VideoObject",
|
|
11
|
-
"Collection" => "Collection",
|
|
12
|
-
"Dataset" => "Dataset",
|
|
13
|
-
"Event" => "Event",
|
|
14
|
-
"Image" => "ImageObject",
|
|
15
|
-
"InteractiveResource" => nil,
|
|
16
|
-
"Model" => nil,
|
|
17
|
-
"PhysicalObject" => nil,
|
|
18
|
-
"Service" => "Service",
|
|
19
|
-
"Software" => "SoftwareSourceCode",
|
|
20
|
-
"Sound" => "AudioObject",
|
|
21
|
-
"Text" => "ScholarlyArticle",
|
|
22
|
-
"Workflow" => nil,
|
|
23
|
-
"Other" => "CreativeWork"
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
attr_reader = :id, :metadata, :schema_org
|
|
27
|
-
|
|
28
|
-
def initialize(doi)
|
|
29
|
-
@id = normalize_doi(doi)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def raw
|
|
33
|
-
response = Maremma.get(id, accept: "application/vnd.datacite.datacite+xml", raw: true)
|
|
34
|
-
@raw = response.body.fetch("data", nil)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def metadata
|
|
38
|
-
@metadata ||= raw.present? ? Maremma.from_xml(raw).fetch("resource", {}) : {}
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def exists?
|
|
42
|
-
metadata.present?
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def type
|
|
46
|
-
k = metadata.dig("resourceType", "resourceTypeGeneral")
|
|
47
|
-
DATACITE_TYPE_TRANSLATIONS[k.to_s.dasherize] || "CreativeWork"
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def additional_type
|
|
51
|
-
metadata.fetch("resourceType", {}).fetch("text", nil) ||
|
|
52
|
-
metadata.fetch("resourceType", {}).fetch("resourceTypeGeneral", nil)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def name
|
|
56
|
-
metadata.dig("titles", "title")
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def alternate_name
|
|
60
|
-
metadata.dig("alternateIdentifiers", "alternateIdentifier", "text")
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def description
|
|
64
|
-
metadata.dig("descriptions", "description", "text")
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def license
|
|
68
|
-
metadata.dig("rightsList", "rights", "rightsURI")
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def keywords
|
|
72
|
-
Array(metadata.dig("subjects", "subject")).join(", ")
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def author
|
|
76
|
-
authors = metadata.dig("creators", "creator")
|
|
77
|
-
authors = [authors] if authors.is_a?(Hash)
|
|
78
|
-
get_authors(authors)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def version
|
|
82
|
-
metadata.fetch("version", nil)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def dates
|
|
86
|
-
Array(metadata.dig("dates", "date"))
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def date_created
|
|
90
|
-
created = dates.find { |d| d["dateType"] == "Created" } || {}
|
|
91
|
-
created.fetch("text", nil)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def date_published
|
|
95
|
-
published = dates.find { |d| d["dateType"] == "Issued" } || {}
|
|
96
|
-
published.fetch("text", nil) || metadata.fetch("publicationYear")
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def date_modified
|
|
100
|
-
modified = dates.find { |d| d["dateType"] == "Updated" } || {}
|
|
101
|
-
modified.fetch("text", nil)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def related_identifiers(relation_type)
|
|
105
|
-
Array(metadata.dig("relatedIdentifiers", "relatedIdentifier"))
|
|
106
|
-
.select { |r| relation_type.split(" ").include?(r["relationType"]) && %w(DOI URL).include?(r["relatedIdentifierType"]) }
|
|
107
|
-
.map do |work|
|
|
108
|
-
work_id = work["relatedIdentifierType"] == "DOI" ? normalize_doi(work["text"]) : work["text"]
|
|
109
|
-
{ "@type" => "CreativeWork",
|
|
110
|
-
"@id" => work_id }
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def is_part_of
|
|
115
|
-
related_identifiers("IsPartOf").first
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def has_part
|
|
119
|
-
related_identifiers("HasPart").presence
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def citation
|
|
123
|
-
related_identifiers("Cites IsCitedBy Supplements IsSupplementTo References IsReferencedBy").presence
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def publisher
|
|
127
|
-
metadata.fetch("publisher")
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def provider
|
|
131
|
-
{ "@type" => "Organization",
|
|
132
|
-
"name" => "DataCite" }
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
def as_schema_org
|
|
136
|
-
{ "@context" => "http://schema.org",
|
|
137
|
-
"@type" => type,
|
|
138
|
-
"@id" => id,
|
|
139
|
-
"name" => name,
|
|
140
|
-
"alternateName" => alternate_name,
|
|
141
|
-
"author" => author,
|
|
142
|
-
"description" => description,
|
|
143
|
-
"license" => license,
|
|
144
|
-
"version" => version,
|
|
145
|
-
"keywords" => keywords,
|
|
146
|
-
"dateCreated" => date_created,
|
|
147
|
-
"datePublished" => date_published,
|
|
148
|
-
"dateModified" => date_modified,
|
|
149
|
-
"isPartOf" => is_part_of,
|
|
150
|
-
"hasPart" => has_part,
|
|
151
|
-
"citation" => citation,
|
|
152
|
-
"publisher" => publisher,
|
|
153
|
-
"provider" => provider
|
|
154
|
-
}.compact
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end
|
data/lib/bolognese/date_utils.rb
DELETED
|
@@ -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
|
data/lib/bolognese/github.rb
DELETED
|
@@ -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
|
data/lib/bolognese/orcid.rb
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module Bolognese
|
|
2
|
-
class Orcid < Metadata
|
|
3
|
-
include Bolognese::PidUtils
|
|
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
|
data/lib/bolognese/pid_utils.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module Bolognese
|
|
2
|
-
module PidUtils
|
|
3
|
-
def normalize_orcid(orcid)
|
|
4
|
-
orcid = validate_orcid(orcid)
|
|
5
|
-
return nil unless orcid.present?
|
|
6
|
-
|
|
7
|
-
# turn ORCID ID into URL
|
|
8
|
-
"http://orcid.org/" + Addressable::URI.encode(orcid)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def orcid_from_url(url)
|
|
12
|
-
Array(/\Ahttp:\/\/orcid\.org\/(.+)/.match(url)).last
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def orcid_as_url(orcid)
|
|
16
|
-
"http://orcid.org/#{orcid}" if orcid.present?
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def validate_orcid(orcid)
|
|
20
|
-
Array(/\A(?:http:\/\/orcid\.org\/)?(\d{4}-\d{4}-\d{4}-\d{3}[0-9X]+)\z/.match(orcid)).last
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
data/spec/cli_spec.rb
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'bolognese/cli'
|
|
3
|
-
|
|
4
|
-
describe Bolognese::CLI do
|
|
5
|
-
let(:subject) do
|
|
6
|
-
described_class.new
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
describe "read", vcr: true do
|
|
10
|
-
context "crossref" do
|
|
11
|
-
let(:id) { "10.7554/eLife.01567" }
|
|
12
|
-
it 'as schema_org' do
|
|
13
|
-
subject.options = { as: "schema_org" }
|
|
14
|
-
expect { subject.read id }.to output(/additionalType/).to_stdout
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'as crossref' do
|
|
18
|
-
subject.options = { as: "crossref" }
|
|
19
|
-
expect { subject.read id }.to output(/journal_metadata/).to_stdout
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
context "datacite" do
|
|
24
|
-
let(:id) { "10.5061/dryad.8515" }
|
|
25
|
-
|
|
26
|
-
it 'as schema_org' do
|
|
27
|
-
subject.options = { as: "schema_org" }
|
|
28
|
-
expect { subject.read id }.to output(/Phylogeny, Malaria, Parasites, Taxonomy, Mitochondrial genome, Africa, Plasmodium/).to_stdout
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it 'as datacite' do
|
|
32
|
-
subject.options = { as: "datacite" }
|
|
33
|
-
expect { subject.read id }.to output(/http:\/\/datacite.org\/schema\/kernel-3/).to_stdout
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|