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/Rakefile
CHANGED
data/bin/bolognese
CHANGED
data/bolognese.gemspec
CHANGED
|
@@ -8,33 +8,45 @@ Gem::Specification.new do |s|
|
|
|
8
8
|
s.homepage = "https://github.com/datacite/bolognese"
|
|
9
9
|
s.summary = "Ruby client library for conversion of DOI Metadata"
|
|
10
10
|
s.date = Date.today
|
|
11
|
-
s.description = "
|
|
11
|
+
s.description = "Ruby gem and command-line utility for conversion of DOI metadata from and to different metadata formats, including schema.org."
|
|
12
12
|
s.require_paths = ["lib"]
|
|
13
13
|
s.version = Bolognese::VERSION
|
|
14
14
|
s.extra_rdoc_files = ["README.md"]
|
|
15
15
|
s.license = 'MIT'
|
|
16
|
+
s.required_ruby_version = ['>= 3.2', '< 4.1']
|
|
16
17
|
|
|
17
|
-
#
|
|
18
|
-
s.add_dependency 'maremma', '~>
|
|
19
|
-
s.add_dependency 'nokogiri', '~> 1.
|
|
20
|
-
s.add_dependency '
|
|
21
|
-
s.add_dependency '
|
|
22
|
-
s.add_dependency '
|
|
23
|
-
s.add_dependency '
|
|
24
|
-
s.add_dependency '
|
|
25
|
-
s.add_dependency '
|
|
26
|
-
s.
|
|
27
|
-
s.
|
|
28
|
-
s.
|
|
29
|
-
s.
|
|
30
|
-
s.
|
|
31
|
-
s.
|
|
32
|
-
s.
|
|
33
|
-
s.
|
|
34
|
-
s.
|
|
18
|
+
# Declare dependencies here, rather than in the Gemfile
|
|
19
|
+
s.add_dependency 'maremma', '~> 6.0'
|
|
20
|
+
s.add_dependency 'nokogiri', '~> 1.19', '>= 1.19.1'
|
|
21
|
+
s.add_dependency 'loofah', '~> 2.25'
|
|
22
|
+
s.add_dependency 'builder', '~> 3.3'
|
|
23
|
+
s.add_dependency 'activesupport', "~> 8.1", ">= 8.1.2"
|
|
24
|
+
s.add_dependency 'bibtex-ruby', '~> 6.2'
|
|
25
|
+
s.add_dependency 'thor', '~> 1.5'
|
|
26
|
+
s.add_dependency 'namae', '~> 1.2'
|
|
27
|
+
s.add_dependency 'edtf', '~> 3.2'
|
|
28
|
+
s.add_dependency 'citeproc-ruby', '~> 2.1', '>= 2.1.8'
|
|
29
|
+
s.add_dependency 'csl-styles', '~> 2.0', '>= 2.0.2'
|
|
30
|
+
s.add_dependency 'iso8601', '~> 0.13.0'
|
|
31
|
+
s.add_dependency 'json-ld-preloaded', '~> 3.3', '>= 3.3.2'
|
|
32
|
+
s.add_dependency 'jsonlint', '~> 0.4.0'
|
|
33
|
+
s.add_dependency 'oj', '~> 3.16', '>= 3.16.15'
|
|
34
|
+
s.add_dependency 'rdf-turtle', '~> 3.3', '>= 3.3.1'
|
|
35
|
+
s.add_dependency 'rdf-rdfxml', '~> 3.3'
|
|
36
|
+
s.add_dependency 'gender_detector', '~> 2.1'
|
|
37
|
+
s.add_dependency 'concurrent-ruby', '~> 1.3', '>= 1.3.6'
|
|
38
|
+
s.add_dependency 'csv', '~> 3.3', '>= 3.3.5'
|
|
39
|
+
s.add_development_dependency 'bundler', '>= 2.0'
|
|
40
|
+
s.add_development_dependency 'irb'
|
|
41
|
+
s.add_development_dependency 'rspec', '~> 3.13', '>= 3.13.2'
|
|
42
|
+
s.add_development_dependency 'rake', '~> 13.3', '>= 13.3.1'
|
|
43
|
+
s.add_development_dependency 'rack-test', '~> 2.2'
|
|
44
|
+
s.add_development_dependency 'vcr', '~> 6.4'
|
|
45
|
+
s.add_development_dependency 'webmock', '~> 3.26', '>= 3.26.1'
|
|
46
|
+
s.add_development_dependency 'simplecov', '0.22.0'
|
|
47
|
+
s.add_development_dependency 'byebug'
|
|
35
48
|
|
|
36
49
|
s.require_paths = ["lib"]
|
|
37
|
-
s.files
|
|
38
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
50
|
+
s.files = `git ls-files`.split($/).reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
39
51
|
s.executables = ["bolognese"]
|
|
40
52
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# turn array into hash or nil, depending on array size.
|
|
4
|
+
# Reverses Array.wrap, but uses self to allow chaining with Array.wrap
|
|
5
|
+
class Array
|
|
6
|
+
def unwrap
|
|
7
|
+
case self.length
|
|
8
|
+
when 0 then nil
|
|
9
|
+
when 1 then self.first
|
|
10
|
+
else self
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -1,61 +1,137 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'namae'
|
|
2
4
|
|
|
3
5
|
module Bolognese
|
|
4
6
|
module AuthorUtils
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
author =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
7
|
+
|
|
8
|
+
IDENTIFIER_SCHEME_URIS = {
|
|
9
|
+
"ORCID" => "https://orcid.org/"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
def get_one_author(author)
|
|
13
|
+
# author is a string
|
|
14
|
+
author = { "creatorName" => author } if author.is_a?(String)
|
|
15
|
+
|
|
16
|
+
# malformed XML
|
|
17
|
+
return nil if author.fetch("creatorName", nil).is_a?(Array)
|
|
18
|
+
|
|
19
|
+
name = parse_attributes(author.fetch("creatorName", nil)) ||
|
|
20
|
+
parse_attributes(author.fetch("contributorName", nil))
|
|
21
|
+
given_name = parse_attributes(author.fetch("givenName", nil))
|
|
22
|
+
family_name = parse_attributes(author.fetch("familyName", nil))
|
|
23
|
+
name = cleanup_author(name)
|
|
24
|
+
contributor_type = parse_attributes(author.fetch("contributorType", nil))
|
|
25
|
+
|
|
26
|
+
name_type = parse_attributes(author.fetch("creatorName", nil), content: "nameType", first: true) || parse_attributes(author.fetch("contributorName", nil), content: "nameType", first: true)
|
|
27
|
+
|
|
28
|
+
name_identifiers = Array.wrap(author.fetch("nameIdentifier", nil)).map do |ni|
|
|
29
|
+
name_identifier = ni["__content__"].strip if ni["__content__"].present?
|
|
30
|
+
if ni["nameIdentifierScheme"] == "ORCID"
|
|
31
|
+
{
|
|
32
|
+
"nameIdentifier" => normalize_orcid(name_identifier),
|
|
33
|
+
"schemeUri" => "https://orcid.org",
|
|
34
|
+
"nameIdentifierScheme" => "ORCID" }.compact
|
|
35
|
+
elsif ni["nameIdentifierScheme"] == "ROR"
|
|
36
|
+
{
|
|
37
|
+
"nameIdentifier" => normalize_ror(name_identifier),
|
|
38
|
+
"schemeUri" => "https://ror.org",
|
|
39
|
+
"nameIdentifierScheme" => "ROR" }.compact
|
|
40
|
+
else
|
|
41
|
+
{
|
|
42
|
+
"nameIdentifier" => name_identifier,
|
|
43
|
+
"schemeUri" => ni.fetch("schemeURI", nil),
|
|
44
|
+
"nameIdentifierScheme" => ni["nameIdentifierScheme"] }.compact
|
|
45
|
+
end
|
|
46
|
+
end.presence
|
|
47
|
+
|
|
48
|
+
{ "nameType" => name_type,
|
|
49
|
+
"name" => name,
|
|
50
|
+
"givenName" => given_name,
|
|
51
|
+
"familyName" => family_name,
|
|
52
|
+
"nameIdentifiers" => name_identifiers,
|
|
53
|
+
"affiliation" => get_affiliations(author.fetch("affiliation", nil)),
|
|
54
|
+
"contributorType" => contributor_type }.compact
|
|
27
55
|
end
|
|
28
56
|
|
|
29
57
|
def cleanup_author(author)
|
|
30
|
-
|
|
31
|
-
author = author.gsub(/[[:space:]]([A-Z]\.)?(-?[A-Z]\.)$/, ', \1\2') unless author.include?(",")
|
|
58
|
+
return nil unless author.present?
|
|
32
59
|
|
|
33
60
|
# titleize strings
|
|
34
61
|
# remove non-standard space characters
|
|
35
|
-
author.
|
|
36
|
-
.gsub(/[[:space:]]/, ' ')
|
|
62
|
+
author.gsub(/[[:space:]]/, ' ')
|
|
37
63
|
end
|
|
38
64
|
|
|
39
65
|
def is_personal_name?(author)
|
|
40
|
-
return
|
|
66
|
+
return false if author.fetch("nameType", nil) == "Organizational"
|
|
67
|
+
return true if Array.wrap(author.fetch("nameIdentifiers", nil)).find { |a| a["nameIdentifierScheme"] == "ORCID" }.present? ||
|
|
68
|
+
author.fetch("familyName", "").present? ||
|
|
69
|
+
(author.fetch("name", "").include?(",") &&
|
|
70
|
+
author.fetch("name", "").exclude?(";")) ||
|
|
71
|
+
name_exists?(author.fetch("name", "").split(" ").first)
|
|
72
|
+
false
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# recognize given name if we have loaded ::NameDetector data, e.g. in a Rails initializer
|
|
76
|
+
def name_exists?(name)
|
|
77
|
+
return false unless name_detector.present?
|
|
41
78
|
|
|
42
|
-
|
|
43
|
-
#::NameDetector.name_exists?(author.split.first)
|
|
79
|
+
name_detector.name_exists?(name)
|
|
44
80
|
end
|
|
45
81
|
|
|
46
82
|
# parse array of author strings into CSL format
|
|
47
|
-
def get_authors(authors
|
|
48
|
-
Array(authors).map { |author| get_one_author(author
|
|
83
|
+
def get_authors(authors)
|
|
84
|
+
Array.wrap(authors).map { |author| get_one_author(author) }.compact
|
|
49
85
|
end
|
|
50
86
|
|
|
51
|
-
def
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
87
|
+
def authors_as_string(authors)
|
|
88
|
+
Array.wrap(authors).map do |a|
|
|
89
|
+
if a["familyName"].present?
|
|
90
|
+
[a["familyName"], a["givenName"]].join(", ")
|
|
91
|
+
elsif a["type"] == "Person"
|
|
92
|
+
a["name"]
|
|
93
|
+
elsif a["name"].present?
|
|
94
|
+
"{" + a["name"] + "}"
|
|
95
|
+
end
|
|
96
|
+
end.join(" and ").presence
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def get_affiliations(affiliations)
|
|
100
|
+
Array.wrap(affiliations).map do |a|
|
|
101
|
+
affiliation_identifier = nil
|
|
102
|
+
if a.is_a?(String)
|
|
103
|
+
name = a.squish
|
|
104
|
+
affiliation_identifier_scheme = nil
|
|
105
|
+
scheme_uri = nil
|
|
106
|
+
else
|
|
107
|
+
scheme_uri = a["schemeURI"]
|
|
108
|
+
if a["affiliationIdentifier"].present?
|
|
109
|
+
affiliation_identifier = a["affiliationIdentifier"]
|
|
110
|
+
if a["schemeURI"].present?
|
|
111
|
+
schemeURI = a["schemeURI"].end_with?("/") ? a["schemeURI"] : a["schemeURI"] + "/"
|
|
112
|
+
end
|
|
113
|
+
affiliation_identifier = !affiliation_identifier.to_s.start_with?("https://") && schemeURI.present? ? normalize_id(schemeURI + affiliation_identifier) : normalize_id(affiliation_identifier)
|
|
114
|
+
# The normalize_id(affiliation_identifier) method currently discards affiliation identifiers that don't start with a URL,
|
|
115
|
+
# for example: affiliation_identifier = "05bp8ka05".
|
|
116
|
+
# To address this issue, we are introducing the following change to handle such affiliation identifiers.
|
|
117
|
+
# when `normalize_id` method could not normalize, it returns nil, hence we have following condition
|
|
118
|
+
if affiliation_identifier.nil?
|
|
119
|
+
if a["affiliationIdentifierScheme"] == "ROR"
|
|
120
|
+
affiliation_identifier = normalize_ror(a["affiliationIdentifier"])
|
|
121
|
+
else
|
|
122
|
+
affiliation_identifier = a["affiliationIdentifier"]
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
name = a["__content__"].to_s.squish.presence
|
|
127
|
+
affiliation_identifier_scheme = a["affiliationIdentifierScheme"]
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
{ "name" => name,
|
|
131
|
+
"affiliationIdentifier" => affiliation_identifier,
|
|
132
|
+
"affiliationIdentifierScheme" => affiliation_identifier_scheme,
|
|
133
|
+
"schemeUri" => scheme_uri }.compact
|
|
134
|
+
end.presence
|
|
59
135
|
end
|
|
60
136
|
end
|
|
61
137
|
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Minimal patch for csl-ruby and citeproc-ruby compatibility
|
|
4
|
+
# Root cause: 'contributor' is not recognized as a names variable in citeproc gem
|
|
5
|
+
# https://github.com/inukshuk/citeproc/blob/121fa4a950b9bd71960e42d20db96bcea1165201/lib/citeproc/variable.rb#L20-L24
|
|
6
|
+
|
|
7
|
+
module CiteProc
|
|
8
|
+
class Variable
|
|
9
|
+
# Unfreeze, modify, and refreeze the fields to add 'contributor' and 'accepted-date'
|
|
10
|
+
if @fields
|
|
11
|
+
# Unfreeze the fields hash temporarily
|
|
12
|
+
fields_dup = @fields.dup
|
|
13
|
+
|
|
14
|
+
# Add contributor to names (make a new unfrozen array)
|
|
15
|
+
fields_dup[:names] = (@fields[:names] + [:contributor]).uniq
|
|
16
|
+
|
|
17
|
+
# Add accepted-date to dates (make a new unfrozen array)
|
|
18
|
+
fields_dup[:date] = (@fields[:date] + [:'accepted-date']).uniq
|
|
19
|
+
|
|
20
|
+
# Rebuild the types mapping - only use actual type keys, not aliases like :all, :any, etc.
|
|
21
|
+
types_hash = Hash[*[:date, :names, :number, :text].map { |k| fields_dup[k].map { |n| [n, k] } }.flatten]
|
|
22
|
+
|
|
23
|
+
# Update the class instance variables
|
|
24
|
+
@fields = fields_dup
|
|
25
|
+
@types = Hash.new { |h,k| h.fetch(k.to_sym, nil) }.merge(types_hash).freeze
|
|
26
|
+
|
|
27
|
+
# Rebuild @factories from the new @types
|
|
28
|
+
# This maps each field name to its Variable subclass (Names, Date, Text, Number)
|
|
29
|
+
@factories = Hash.new { |h,k| h.fetch(k.to_s.intern, CiteProc::Variable) }.merge(
|
|
30
|
+
Hash[*@types.map { |field_name, type|
|
|
31
|
+
[field_name, CiteProc.const_get(type.to_s.capitalize)]
|
|
32
|
+
}.flatten]
|
|
33
|
+
).freeze
|
|
34
|
+
|
|
35
|
+
# Recreate the aliases
|
|
36
|
+
@fields[:name] = @fields[:names]
|
|
37
|
+
@fields[:dates] = @fields[:date]
|
|
38
|
+
@fields[:numbers] = @fields[:number]
|
|
39
|
+
|
|
40
|
+
# Recreate :all and :any
|
|
41
|
+
@fields[:all] = @fields[:any] =
|
|
42
|
+
[:date, :names, :text, :number].reduce([]) { |s,a| s.concat(@fields[a]) }.sort
|
|
43
|
+
|
|
44
|
+
# Refreeze fields
|
|
45
|
+
@fields.freeze
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/bolognese/cli.rb
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
require "thor"
|
|
4
5
|
|
|
6
|
+
require_relative 'doi_utils'
|
|
7
|
+
require_relative 'utils'
|
|
8
|
+
|
|
5
9
|
module Bolognese
|
|
6
10
|
class CLI < Thor
|
|
11
|
+
include Bolognese::DoiUtils
|
|
12
|
+
include Bolognese::Utils
|
|
13
|
+
|
|
7
14
|
def self.exit_on_failure?
|
|
8
15
|
true
|
|
9
16
|
end
|
|
@@ -16,23 +23,29 @@ module Bolognese
|
|
|
16
23
|
puts Bolognese::VERSION
|
|
17
24
|
end
|
|
18
25
|
|
|
19
|
-
desc "
|
|
20
|
-
method_option :
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
desc "", "convert metadata"
|
|
27
|
+
method_option :from, aliases: "-f"
|
|
28
|
+
method_option :to, aliases: "-t", default: "schema_org"
|
|
29
|
+
method_option :regenerate, :type => :boolean, :force => false
|
|
30
|
+
method_option :style, aliases: "-s", default: "apa"
|
|
31
|
+
method_option :locale, aliases: "-l", default: "en-US"
|
|
32
|
+
method_option :show_errors, :type => :boolean, :force => false
|
|
33
|
+
def convert(input)
|
|
34
|
+
metadata = Metadata.new(input: input,
|
|
35
|
+
from: options[:from],
|
|
36
|
+
regenerate: options[:regenerate],
|
|
37
|
+
style: options[:style],
|
|
38
|
+
locale: options[:locale],
|
|
39
|
+
show_errors: options[:show_errors])
|
|
40
|
+
to = options[:to] || "schema_org"
|
|
41
|
+
|
|
42
|
+
if options[:show_errors] && !metadata.valid?
|
|
43
|
+
$stderr.puts metadata.errors
|
|
33
44
|
else
|
|
34
|
-
puts
|
|
45
|
+
puts metadata.send(to)
|
|
35
46
|
end
|
|
36
47
|
end
|
|
48
|
+
|
|
49
|
+
default_task :convert
|
|
37
50
|
end
|
|
38
51
|
end
|