briard 2.4.1 → 2.6.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 +4 -4
- data/.github/workflows/codeql-analysis.yml +72 -0
- data/.github/workflows/rubocop.yml +50 -0
- data/.rubocop.yml +144 -620
- data/.rubocop_todo.yml +76 -0
- data/CHANGELOG.md +22 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +43 -6
- data/Rakefile +1 -1
- data/{bolognese.gemspec → briard.gemspec} +46 -38
- data/lib/briard/array.rb +2 -2
- data/lib/briard/author_utils.rb +79 -71
- data/lib/briard/cli.rb +12 -13
- data/lib/briard/crossref_utils.rb +73 -61
- data/lib/briard/datacite_utils.rb +132 -106
- data/lib/briard/doi_utils.rb +10 -10
- data/lib/briard/metadata.rb +96 -106
- data/lib/briard/metadata_utils.rb +87 -78
- data/lib/briard/readers/bibtex_reader.rb +65 -65
- data/lib/briard/readers/cff_reader.rb +88 -70
- data/lib/briard/readers/citeproc_reader.rb +90 -84
- data/lib/briard/readers/codemeta_reader.rb +68 -50
- data/lib/briard/readers/crosscite_reader.rb +2 -2
- data/lib/briard/readers/crossref_reader.rb +249 -210
- data/lib/briard/readers/datacite_json_reader.rb +3 -3
- data/lib/briard/readers/datacite_reader.rb +225 -189
- data/lib/briard/readers/npm_reader.rb +49 -42
- data/lib/briard/readers/ris_reader.rb +82 -80
- data/lib/briard/readers/schema_org_reader.rb +182 -159
- data/lib/briard/string.rb +1 -1
- data/lib/briard/utils.rb +4 -4
- data/lib/briard/version.rb +3 -1
- data/lib/briard/whitelist_scrubber.rb +11 -4
- data/lib/briard/writers/bibtex_writer.rb +14 -8
- data/lib/briard/writers/cff_writer.rb +33 -26
- data/lib/briard/writers/codemeta_writer.rb +19 -15
- data/lib/briard/writers/csv_writer.rb +6 -4
- data/lib/briard/writers/datacite_json_writer.rb +8 -2
- data/lib/briard/writers/jats_writer.rb +33 -28
- data/lib/briard/writers/rdf_xml_writer.rb +1 -1
- data/lib/briard/writers/ris_writer.rb +30 -18
- data/lib/briard/writers/turtle_writer.rb +1 -1
- data/lib/briard.rb +6 -6
- data/rubocop.sarif +0 -0
- data/spec/array_spec.rb +5 -5
- data/spec/author_utils_spec.rb +151 -132
- data/spec/datacite_utils_spec.rb +135 -83
- data/spec/doi_utils_spec.rb +168 -164
- data/spec/find_from_format_spec.rb +69 -69
- data/spec/fixtures/vcr_cassettes/Briard_Metadata/sanitize/onlies_keep_specific_tags.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Briard_Metadata/sanitize/removes_a_tags.yml +65 -0
- data/spec/metadata_spec.rb +91 -90
- data/spec/readers/bibtex_reader_spec.rb +43 -38
- data/spec/readers/cff_reader_spec.rb +165 -153
- data/spec/readers/citeproc_reader_spec.rb +45 -40
- data/spec/readers/codemeta_reader_spec.rb +128 -115
- data/spec/readers/crosscite_reader_spec.rb +34 -24
- data/spec/readers/crossref_reader_spec.rb +1098 -939
- data/spec/readers/datacite_json_reader_spec.rb +53 -40
- data/spec/readers/datacite_reader_spec.rb +1541 -1337
- data/spec/readers/npm_reader_spec.rb +48 -43
- data/spec/readers/ris_reader_spec.rb +53 -47
- data/spec/readers/schema_org_reader_spec.rb +329 -267
- data/spec/spec_helper.rb +6 -5
- data/spec/utils_spec.rb +371 -347
- data/spec/writers/bibtex_writer_spec.rb +143 -143
- data/spec/writers/cff_writer_spec.rb +96 -90
- data/spec/writers/citation_writer_spec.rb +34 -33
- data/spec/writers/citeproc_writer_spec.rb +226 -224
- data/spec/writers/codemeta_writer_spec.rb +18 -16
- data/spec/writers/crosscite_writer_spec.rb +91 -73
- data/spec/writers/crossref_writer_spec.rb +99 -91
- data/spec/writers/csv_writer_spec.rb +70 -70
- data/spec/writers/datacite_json_writer_spec.rb +78 -68
- data/spec/writers/datacite_writer_spec.rb +417 -322
- data/spec/writers/jats_writer_spec.rb +177 -161
- data/spec/writers/rdf_xml_writer_spec.rb +68 -63
- data/spec/writers/ris_writer_spec.rb +162 -162
- data/spec/writers/turtle_writer_spec.rb +47 -47
- metadata +250 -160
- data/.github/workflows/release.yml +0 -47
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Briard::Metadata, vcr: true do
|
6
|
-
context
|
6
|
+
context 'write metadata as codemeta' do
|
7
7
|
# it "SoftwareSourceCode DataCite JSON" do
|
8
8
|
# input = fixture_path + "datacite_software.json"
|
9
9
|
# subject = Briard::Metadata.new(input: input, from: "datacite_json")
|
@@ -19,27 +19,29 @@ describe Briard::Metadata, vcr: true do
|
|
19
19
|
# expect(json["publisher"]).to eq("KNB Data Repository")
|
20
20
|
# end
|
21
21
|
|
22
|
-
it
|
23
|
-
input =
|
24
|
-
subject =
|
22
|
+
it 'SoftwareSourceCode DataCite' do
|
23
|
+
input = 'https://doi.org/10.5063/f1m61h5x'
|
24
|
+
subject = described_class.new(input: input, from: 'datacite')
|
25
25
|
expect(subject.valid?).to be true
|
26
26
|
json = JSON.parse(subject.codemeta)
|
27
|
-
expect(json[
|
28
|
-
expect(json[
|
29
|
-
expect(json[
|
30
|
-
expect(json[
|
31
|
-
|
32
|
-
|
33
|
-
expect(json[
|
27
|
+
expect(json['@context']).to eq('https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld')
|
28
|
+
expect(json['@id']).to eq('https://doi.org/10.5063/f1m61h5x')
|
29
|
+
expect(json['@type']).to eq('SoftwareSourceCode')
|
30
|
+
expect(json['authors']).to eq([{
|
31
|
+
'name' => 'Jones, Matthew B.; Slaughter, Peter; Nahf, Rob; Boettiger, Carl ; Jones, Chris; Read, Jordan; Walker, Lauren; Hart, Edmund; Chamberlain, Scott', 'nameIdentifiers' => [], 'affiliation' => []
|
32
|
+
}])
|
33
|
+
expect(json['name']).to eq('dataone: R interface to the DataONE network of data repositories')
|
34
|
+
expect(json['datePublished']).to eq('2016')
|
35
|
+
expect(json['publisher']).to eq('KNB Data Repository')
|
34
36
|
end
|
35
37
|
|
36
|
-
it
|
37
|
-
input =
|
38
|
-
subject =
|
38
|
+
it 'SoftwareSourceCode DataCite check codemeta v2' do
|
39
|
+
input = 'https://doi.org/10.5063/f1m61h5x'
|
40
|
+
subject = described_class.new(input: input, from: 'datacite')
|
39
41
|
expect(subject.valid?).to be true
|
40
42
|
json = JSON.parse(subject.codemeta)
|
41
|
-
expect(json[
|
42
|
-
expect(json[
|
43
|
+
expect(json['agents'].nil?).to be(true)
|
44
|
+
expect(json['title'].nil?).to be(true)
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
@@ -3,31 +3,37 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Briard::Metadata, vcr: true do
|
6
|
-
context
|
7
|
-
it
|
8
|
-
input =
|
9
|
-
subject =
|
6
|
+
context 'write metadata as crosscite' do
|
7
|
+
it 'with data citation' do
|
8
|
+
input = '10.7554/eLife.01567'
|
9
|
+
subject = described_class.new(input: input, from: 'crossref')
|
10
10
|
crosscite = JSON.parse(subject.crosscite)
|
11
|
-
expect(crosscite.fetch(
|
12
|
-
expect(crosscite.fetch(
|
13
|
-
|
14
|
-
expect(crosscite.fetch(
|
15
|
-
expect(crosscite.fetch(
|
16
|
-
expect(crosscite.fetch(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
expect(crosscite.fetch('url')).to eq('https://elifesciences.org/articles/01567')
|
12
|
+
expect(crosscite.fetch('types')).to eq('bibtex' => 'article', 'citeproc' => 'article-journal',
|
13
|
+
'resourceType' => 'JournalArticle', 'resourceTypeGeneral' => 'JournalArticle', 'ris' => 'JOUR', 'schemaOrg' => 'ScholarlyArticle')
|
14
|
+
expect(crosscite.fetch('titles')).to eq([{ 'title' => 'Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth' }])
|
15
|
+
expect(crosscite.fetch('related_identifiers').length).to eq(28)
|
16
|
+
expect(crosscite.fetch('related_identifiers').first).to eq('relatedIdentifier' => '2050-084X',
|
17
|
+
'relatedIdentifierType' => 'ISSN', 'relationType' => 'IsPartOf', 'resourceTypeGeneral' => 'Collection')
|
18
|
+
expect(crosscite.fetch('related_identifiers').last).to eq(
|
19
|
+
'relatedIdentifier' => '10.1038/ncb2764', 'relatedIdentifierType' => 'DOI', 'relationType' => 'References'
|
20
|
+
)
|
21
|
+
expect(crosscite.fetch('rights_list')).to eq([{ 'rights' => 'Creative Commons Attribution 3.0 Unported',
|
22
|
+
'rightsIdentifier' => 'cc-by-3.0',
|
23
|
+
'rightsIdentifierScheme' => 'SPDX',
|
24
|
+
'rightsUri' => 'https://creativecommons.org/licenses/by/3.0/legalcode',
|
25
|
+
'schemeUri' => 'https://spdx.org/licenses/' }])
|
22
26
|
end
|
23
27
|
|
24
|
-
it
|
25
|
-
input =
|
26
|
-
subject =
|
28
|
+
it 'with ORCID ID' do
|
29
|
+
input = 'https://doi.org/10.1155/2012/291294'
|
30
|
+
subject = described_class.new(input: input, from: 'crossref')
|
27
31
|
crosscite = JSON.parse(subject.crosscite)
|
28
|
-
expect(crosscite.fetch(
|
29
|
-
|
30
|
-
expect(crosscite.fetch(
|
32
|
+
expect(crosscite.fetch('types')).to eq('bibtex' => 'article', 'citeproc' => 'article-journal',
|
33
|
+
'resourceType' => 'JournalArticle', 'resourceTypeGeneral' => 'JournalArticle', 'ris' => 'JOUR', 'schemaOrg' => 'ScholarlyArticle')
|
34
|
+
expect(crosscite.fetch('creators').count).to eq(7)
|
35
|
+
expect(crosscite.fetch('creators')[2]).to eq('nameType' => 'Personal',
|
36
|
+
'nameIdentifiers' => [{ 'nameIdentifier' => 'https://orcid.org/0000-0003-2043-4925', 'nameIdentifierScheme' => 'ORCID', 'schemeUri' => 'https://orcid.org' }], 'name' => 'Hernandez, Beatriz', 'givenName' => 'Beatriz', 'familyName' => 'Hernandez', 'affiliation' => [{ 'name' => 'War Related Illness and Injury Study Center (WRIISC) and Mental Illness Research Education and Clinical Center (MIRECC), Department of Veterans Affairs, Palo Alto, CA 94304, USA' }, { 'name' => 'Department of Psychiatry and Behavioral Sciences, Stanford University School of Medicine, Stanford, CA 94304, USA' }])
|
31
37
|
end
|
32
38
|
|
33
39
|
# it "with editor" do
|
@@ -37,75 +43,87 @@ describe Briard::Metadata, vcr: true do
|
|
37
43
|
# expect(crosscite["editor"]).to eq("contributorType"=>"Editor", "contributorName"=>"Janbon, Guilhem", "givenName"=>"Guilhem", "familyName"=>"Janbon")
|
38
44
|
# end
|
39
45
|
|
40
|
-
it
|
41
|
-
input = fixture_path
|
42
|
-
subject =
|
46
|
+
it 'Crossref DOI' do
|
47
|
+
input = "#{fixture_path}crossref.bib"
|
48
|
+
subject = described_class.new(input: input, from: 'bibtex')
|
43
49
|
crosscite = JSON.parse(subject.crosscite)
|
44
|
-
expect(crosscite.fetch(
|
45
|
-
|
46
|
-
expect(crosscite.
|
47
|
-
expect(crosscite.
|
48
|
-
|
50
|
+
expect(crosscite.fetch('types')).to eq('bibtex' => 'article', 'citeproc' => 'article-journal',
|
51
|
+
'resourceTypeGeneral' => 'JournalArticle', 'resourceType' => 'JournalArticle', 'ris' => 'JOUR', 'schemaOrg' => 'ScholarlyArticle')
|
52
|
+
expect(crosscite.fetch('titles')).to eq([{ 'title' => 'Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth' }])
|
53
|
+
expect(crosscite.dig('descriptions', 0,
|
54
|
+
'description')).to start_with('Among various advantages, their small size makes model organisms preferred subjects of investigation.')
|
55
|
+
expect(crosscite.fetch('creators').count).to eq(5)
|
56
|
+
expect(crosscite.fetch('creators').first).to eq('nameType' => 'Personal',
|
57
|
+
'name' => 'Sankar, Martial', 'givenName' => 'Martial', 'familyName' => 'Sankar')
|
49
58
|
end
|
50
59
|
|
51
|
-
it
|
52
|
-
input = fixture_path
|
53
|
-
subject =
|
60
|
+
it 'BlogPosting Citeproc JSON' do
|
61
|
+
input = "#{fixture_path}citeproc.json"
|
62
|
+
subject = described_class.new(input: input, from: 'citeproc')
|
54
63
|
expect(subject.valid?).to be true
|
55
64
|
crosscite = JSON.parse(subject.crosscite)
|
56
|
-
expect(crosscite[
|
57
|
-
|
58
|
-
expect(crosscite.
|
59
|
-
expect(crosscite.
|
65
|
+
expect(crosscite['types']).to eq('bibtex' => 'article', 'citeproc' => 'post-weblog',
|
66
|
+
'resourceTypeGeneral' => 'Text', 'ris' => 'GEN', 'schemaOrg' => 'BlogPosting')
|
67
|
+
expect(crosscite.fetch('titles')).to eq([{ 'title' => 'Eating your own Dog Food' }])
|
68
|
+
expect(crosscite.dig('descriptions', 0,
|
69
|
+
'description')).to start_with('Eating your own dog food')
|
70
|
+
expect(crosscite.fetch('creators')).to eq([{ 'familyName' => 'Fenner', 'givenName' => 'Martin',
|
71
|
+
'name' => 'Fenner, Martin' }])
|
60
72
|
end
|
61
73
|
|
62
|
-
it
|
63
|
-
input = fixture_path
|
64
|
-
subject =
|
74
|
+
it 'rdataone' do
|
75
|
+
input = "#{fixture_path}codemeta.json"
|
76
|
+
subject = described_class.new(input: input, from: 'codemeta')
|
65
77
|
crosscite = JSON.parse(subject.crosscite)
|
66
|
-
expect(crosscite[
|
67
|
-
expect(crosscite[
|
68
|
-
expect(crosscite[
|
69
|
-
|
78
|
+
expect(crosscite['titles']).to eq([{ 'title' => 'R Interface to the DataONE REST API' }])
|
79
|
+
expect(crosscite['creators'].length).to eq(3)
|
80
|
+
expect(crosscite['creators'].last).to eq('nameType' => 'Organizational',
|
81
|
+
'name' => 'University Of California, Santa Barbara', 'nameIdentifiers' => [], 'affiliation' => [])
|
82
|
+
expect(crosscite['version']).to eq('2.0.0')
|
70
83
|
end
|
71
84
|
|
72
|
-
it
|
73
|
-
input = fixture_path
|
74
|
-
subject =
|
85
|
+
it 'rdataone codemeta v2' do
|
86
|
+
input = "#{fixture_path}codemeta_v2.json"
|
87
|
+
subject = described_class.new(input: input, from: 'codemeta')
|
75
88
|
crosscite = JSON.parse(subject.crosscite)
|
76
|
-
expect(crosscite[
|
77
|
-
expect(crosscite[
|
78
|
-
expect(crosscite[
|
79
|
-
|
89
|
+
expect(crosscite['titles']).to eq([{ 'title' => 'R Interface to the DataONE REST API' }])
|
90
|
+
expect(crosscite['creators'].length).to eq(3)
|
91
|
+
expect(crosscite['creators'].last).to eq('nameType' => 'Organizational',
|
92
|
+
'name' => 'University Of California, Santa Barbara', 'nameIdentifiers' => [], 'affiliation' => [])
|
93
|
+
expect(crosscite['version']).to eq('2.0.0')
|
80
94
|
end
|
81
95
|
|
82
|
-
it
|
83
|
-
input =
|
84
|
-
subject =
|
96
|
+
it 'datacite database attributes' do
|
97
|
+
input = 'https://doi.org/10.5061/DRYAD.8515'
|
98
|
+
subject = described_class.new(input: input, from: 'datacite')
|
85
99
|
crosscite = JSON.parse(subject.crosscite)
|
86
|
-
expect(crosscite.fetch(
|
87
|
-
expect(crosscite.fetch(
|
88
|
-
expect(crosscite.fetch(
|
89
|
-
expect(crosscite.fetch(
|
90
|
-
|
91
|
-
expect(crosscite.fetch(
|
92
|
-
|
93
|
-
|
100
|
+
expect(crosscite.fetch('url')).to eq('http://datadryad.org/stash/dataset/doi:10.5061/dryad.8515')
|
101
|
+
expect(crosscite.fetch('titles')).to eq([{ 'title' => 'Data from: A new malaria agent in African hominids.' }])
|
102
|
+
expect(crosscite.fetch('creators').length).to eq(8)
|
103
|
+
expect(crosscite.fetch('creators').first).to eq('familyName' => 'Ollomo',
|
104
|
+
'givenName' => 'Benjamin', 'name' => 'Ollomo, Benjamin', 'nameType' => 'Personal', 'nameIdentifiers' => [], 'affiliation' => [{ 'affiliationIdentifier' => 'https://ror.org/01wyqb997', 'affiliationIdentifierScheme' => 'ROR', 'name' => 'Centre International de Recherches Médicales de Franceville' }])
|
105
|
+
expect(crosscite.fetch('dates')).to eq([
|
106
|
+
{ 'date' => '2011-02-01T17:22:41Z',
|
107
|
+
'dateType' => 'Available' }, { 'date' => '2011', 'dateType' => 'Issued' }
|
108
|
+
])
|
109
|
+
expect(crosscite.fetch('publication_year')).to eq('2011')
|
110
|
+
expect(crosscite.fetch('provider_id')).to eq('dryad')
|
111
|
+
expect(crosscite.fetch('client_id')).to eq('dryad.dryad')
|
94
112
|
end
|
95
113
|
|
96
|
-
it
|
97
|
-
input =
|
98
|
-
subject =
|
114
|
+
it 'maremma' do
|
115
|
+
input = 'https://github.com/datacite/maremma'
|
116
|
+
subject = described_class.new(input: input, from: 'codemeta')
|
99
117
|
crosscite = JSON.parse(subject.crosscite)
|
100
|
-
expect(crosscite.fetch(
|
101
|
-
expect(crosscite.fetch(
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
[{
|
107
|
-
|
108
|
-
|
118
|
+
expect(crosscite.fetch('titles')).to eq([{ 'title' => 'Maremma: a Ruby library for simplified network calls' }])
|
119
|
+
expect(crosscite.fetch('creators')).to eq([{ 'affiliation' => [{ 'name' => 'DataCite' }],
|
120
|
+
'familyName' => 'Fenner',
|
121
|
+
'givenName' => 'Martin',
|
122
|
+
'name' => 'Fenner, Martin',
|
123
|
+
'nameIdentifiers' =>
|
124
|
+
[{ 'nameIdentifier' => 'https://orcid.org/0000-0003-0077-4738',
|
125
|
+
'nameIdentifierScheme' => 'ORCID', 'schemeUri' => 'https://orcid.org' }],
|
126
|
+
'nameType' => 'Personal' }])
|
109
127
|
end
|
110
128
|
end
|
111
129
|
end
|
@@ -3,113 +3,121 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Briard::Metadata, vcr: true do
|
6
|
-
context
|
7
|
-
it
|
8
|
-
input = fixture_path
|
9
|
-
subject =
|
6
|
+
context 'write metadata as crossref' do
|
7
|
+
it 'journal article' do
|
8
|
+
input = "#{fixture_path}crossref.xml"
|
9
|
+
subject = described_class.new(input: input)
|
10
10
|
expect(subject.valid?).to be true
|
11
|
-
expect(subject.doi).to eq(
|
12
|
-
expect(subject.url).to eq(
|
13
|
-
crossref = Maremma.from_xml(subject.crossref).dig(
|
14
|
-
expect(crossref.dig(
|
15
|
-
expect(crossref.dig(
|
11
|
+
expect(subject.doi).to eq('10.7554/elife.01567')
|
12
|
+
expect(subject.url).to eq('https://elifesciences.org/articles/01567')
|
13
|
+
crossref = Maremma.from_xml(subject.crossref).dig('doi_batch', 'body', 'journal')
|
14
|
+
expect(crossref.dig('journal_metadata', 'full_title')).to eq('eLife')
|
15
|
+
expect(crossref.dig('journal_article', 'doi_data', 'doi')).to eq('10.7554/elife.01567')
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
19
|
-
subject =
|
18
|
+
it 'posted_content' do
|
19
|
+
subject = described_class.new(input: '10.1101/2020.12.01.406702')
|
20
20
|
expect(subject.valid?).to be true
|
21
|
-
expect(subject.doi).to eq(
|
22
|
-
expect(subject.url).to eq(
|
23
|
-
crossref = Maremma.from_xml(subject.crossref).dig(
|
24
|
-
expect(crossref.dig(
|
21
|
+
expect(subject.doi).to eq('10.1101/2020.12.01.406702')
|
22
|
+
expect(subject.url).to eq('http://biorxiv.org/lookup/doi/10.1101/2020.12.01.406702')
|
23
|
+
crossref = Maremma.from_xml(subject.crossref).dig('doi_batch', 'body', 'posted_content')
|
24
|
+
expect(crossref.dig('doi_data', 'doi')).to eq('10.1101/2020.12.01.406702')
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
28
|
-
input =
|
29
|
-
subject =
|
30
|
-
|
27
|
+
it 'journal article from datacite' do
|
28
|
+
input = '10.2312/geowissenschaften.1989.7.181'
|
29
|
+
subject = described_class.new(input: input, from: 'datacite')
|
30
|
+
|
31
31
|
expect(subject.valid?).to be true
|
32
|
-
expect(subject.doi).to eq(
|
33
|
-
expect(subject.url).to eq(
|
34
|
-
expect(subject.types[
|
35
|
-
expect(subject.types[
|
36
|
-
expect(subject.types[
|
37
|
-
expect(subject.types[
|
38
|
-
expect(subject.titles).to eq([{
|
39
|
-
expect(subject.publisher).to eq(
|
40
|
-
expect(subject.rights_list).to eq([{
|
32
|
+
expect(subject.doi).to eq('10.2312/geowissenschaften.1989.7.181')
|
33
|
+
expect(subject.url).to eq('https://www.tib.eu/suchen/id/awi:7058a56c5e43afd705af945d01536b9aaeeee491')
|
34
|
+
expect(subject.types['schemaOrg']).to eq('ScholarlyArticle')
|
35
|
+
expect(subject.types['resourceTypeGeneral']).to eq('JournalArticle')
|
36
|
+
expect(subject.types['ris']).to eq('JOUR')
|
37
|
+
expect(subject.types['citeproc']).to eq('article-journal')
|
38
|
+
expect(subject.titles).to eq([{ 'title' => 'An Overview of the Geology of Canadian Gold Occurrences' }])
|
39
|
+
expect(subject.publisher).to eq('VCH Verlagsgesellschaft mbH')
|
40
|
+
expect(subject.rights_list).to eq([{ 'rights' => 'VCH Verlagsgesellschaft mbH' }])
|
41
41
|
end
|
42
42
|
|
43
|
-
it
|
44
|
-
input =
|
45
|
-
subject =
|
46
|
-
|
43
|
+
it 'schema.org from front matter' do
|
44
|
+
input = 'https://blog.front-matter.io/posts/editorial-by-more-than-200-call-for-emergency-action-to-limit-global-temperature-increases-restore-biodiversity-and-protect-health'
|
45
|
+
subject = described_class.new(input: input, from: 'schema_org')
|
46
|
+
|
47
47
|
expect(subject.valid?).to be true
|
48
|
-
expect(subject.doi).to eq(
|
49
|
-
expect(subject.url).to eq(
|
50
|
-
expect(subject.types[
|
51
|
-
expect(subject.types[
|
52
|
-
expect(subject.types[
|
53
|
-
expect(subject.types[
|
54
|
-
expect(subject.titles).to eq([{
|
55
|
-
expect(subject.creators).to eq([{
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
[{
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
expect(subject.subjects).to eq([{
|
65
|
-
expect(subject.language).to eq(
|
66
|
-
expect(subject.rights_list).to eq([{
|
67
|
-
|
68
|
-
|
48
|
+
expect(subject.doi).to eq('10.53731/r9nqx6h-97aq74v-ag7bw')
|
49
|
+
expect(subject.url).to eq('https://blog.front-matter.io/posts/editorial-by-more-than-200-call-for-emergency-action-to-limit-global-temperature-increases-restore-biodiversity-and-protect-health')
|
50
|
+
expect(subject.types['schemaOrg']).to eq('Article')
|
51
|
+
expect(subject.types['resourceTypeGeneral']).to eq('Preprint')
|
52
|
+
expect(subject.types['ris']).to eq('GEN')
|
53
|
+
expect(subject.types['citeproc']).to eq('article-newspaper')
|
54
|
+
expect(subject.titles).to eq([{ 'title' => 'Editorial by more than 200 health journals: Call for emergency action to limit global temperature increases, restore biodiversity, and protect health' }])
|
55
|
+
expect(subject.creators).to eq([{ 'affiliation' => [],
|
56
|
+
'familyName' => 'Fenner',
|
57
|
+
'givenName' => 'Martin',
|
58
|
+
'name' => 'Fenner, Martin',
|
59
|
+
'nameIdentifiers' =>
|
60
|
+
[{ 'nameIdentifier' => 'https://orcid.org/0000-0003-1419-2405',
|
61
|
+
'nameIdentifierScheme' => 'ORCID',
|
62
|
+
'schemeUri' => 'https://orcid.org' }],
|
63
|
+
'nameType' => 'Personal' }])
|
64
|
+
expect(subject.subjects).to eq([{ 'subject' => 'news' }])
|
65
|
+
expect(subject.language).to eq('en')
|
66
|
+
expect(subject.rights_list).to eq([{
|
67
|
+
'rights' => 'Creative Commons Attribution 4.0 International', 'rightsUri' => 'https://creativecommons.org/licenses/by/4.0/legalcode', 'rightsIdentifier' => 'cc-by-4.0', 'rightsIdentifierScheme' => 'SPDX', 'schemeUri' => 'https://spdx.org/licenses/'
|
68
|
+
}])
|
69
|
+
crossref = Maremma.from_xml(subject.crossref).dig('doi_batch', 'body', 'posted_content')
|
70
|
+
expect(crossref.dig('titles',
|
71
|
+
'title')).to eq('Editorial by more than 200 health journals: Call for emergency action to limit global temperature increases, restore biodiversity, and protect health')
|
69
72
|
end
|
70
73
|
|
71
|
-
it
|
72
|
-
input =
|
73
|
-
subject =
|
74
|
+
it 'another schema.org from front-matter' do
|
75
|
+
input = 'https://blog.front-matter.io/posts/dryad-interview-jen-gibson'
|
76
|
+
subject = described_class.new(input: input, from: 'schema_org')
|
74
77
|
expect(subject.valid?).to be true
|
75
|
-
expect(subject.doi).to eq(
|
76
|
-
expect(subject.url).to eq(
|
77
|
-
expect(subject.types[
|
78
|
-
expect(subject.types[
|
79
|
-
expect(subject.types[
|
80
|
-
expect(subject.types[
|
81
|
-
expect(subject.titles).to eq([{
|
82
|
-
expect(subject.creators).to eq([{
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
[{
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
expect(subject.subjects).to eq([{
|
92
|
-
expect(subject.container).to eq(
|
93
|
-
|
94
|
-
expect(subject.
|
95
|
-
|
96
|
-
|
78
|
+
expect(subject.doi).to eq('10.53731/rceh7pn-tzg61kj-7zv63')
|
79
|
+
expect(subject.url).to eq('https://blog.front-matter.io/posts/dryad-interview-jen-gibson')
|
80
|
+
expect(subject.types['schemaOrg']).to eq('Article')
|
81
|
+
expect(subject.types['resourceTypeGeneral']).to eq('Preprint')
|
82
|
+
expect(subject.types['ris']).to eq('GEN')
|
83
|
+
expect(subject.types['citeproc']).to eq('article-newspaper')
|
84
|
+
expect(subject.titles).to eq([{ 'title' => 'Dryad: Interview with Jen Gibson' }])
|
85
|
+
expect(subject.creators).to eq([{ 'affiliation' => [],
|
86
|
+
'familyName' => 'Fenner',
|
87
|
+
'givenName' => 'Martin',
|
88
|
+
'name' => 'Fenner, Martin',
|
89
|
+
'nameIdentifiers' =>
|
90
|
+
[{ 'nameIdentifier' => 'https://orcid.org/0000-0003-1419-2405',
|
91
|
+
'nameIdentifierScheme' => 'ORCID',
|
92
|
+
'schemeUri' => 'https://orcid.org' }],
|
93
|
+
'nameType' => 'Personal' }])
|
94
|
+
expect(subject.subjects).to eq([{ 'subject' => 'interview' }])
|
95
|
+
expect(subject.container).to eq('identifier' => '2749-9952', 'identifierType' => 'ISSN',
|
96
|
+
'title' => 'Front Matter', 'type' => 'Blog')
|
97
|
+
expect(subject.language).to eq('en')
|
98
|
+
expect(subject.rights_list).to eq([{
|
99
|
+
'rights' => 'Creative Commons Attribution 4.0 International', 'rightsUri' => 'https://creativecommons.org/licenses/by/4.0/legalcode', 'rightsIdentifier' => 'cc-by-4.0', 'rightsIdentifierScheme' => 'SPDX', 'schemeUri' => 'https://spdx.org/licenses/'
|
100
|
+
}])
|
101
|
+
crossref = Maremma.from_xml(subject.crossref).dig('doi_batch', 'body', 'posted_content')
|
102
|
+
expect(crossref.dig('titles', 'title')).to eq('Dryad: Interview with Jen Gibson')
|
97
103
|
end
|
98
104
|
|
99
|
-
it
|
100
|
-
input = fixture_path
|
101
|
-
subject =
|
105
|
+
it 'embedded schema.org from front matter' do
|
106
|
+
input = "#{fixture_path}schema_org_front-matter.json"
|
107
|
+
subject = described_class.new(input: input, from: 'schema_org')
|
102
108
|
expect(subject.valid?).to be true
|
103
|
-
expect(subject.doi).to eq(
|
104
|
-
expect(subject.url).to eq(
|
105
|
-
expect(subject.types[
|
106
|
-
expect(subject.types[
|
107
|
-
expect(subject.types[
|
108
|
-
expect(subject.types[
|
109
|
-
expect(subject.container).to eq(
|
110
|
-
|
111
|
-
|
112
|
-
|
109
|
+
expect(subject.doi).to eq('10.53731/r9nqx6h-97aq74v-ag7bw')
|
110
|
+
expect(subject.url).to eq('https://blog.front-matter.io/posts/editorial-by-more-than-200-call-for-emergency-action-to-limit-global-temperature-increases-restore-biodiversity-and-protect-health')
|
111
|
+
expect(subject.types['schemaOrg']).to eq('BlogPosting')
|
112
|
+
expect(subject.types['resourceTypeGeneral']).to eq('Preprint')
|
113
|
+
expect(subject.types['ris']).to eq('GEN')
|
114
|
+
expect(subject.types['citeproc']).to eq('post-weblog')
|
115
|
+
expect(subject.container).to eq('identifier' => '2749-9952', 'identifierType' => 'ISSN',
|
116
|
+
'title' => 'Front Matter', 'type' => 'Blog')
|
117
|
+
expect(subject.titles).to eq([{ 'title' => 'Editorial by more than 200 health journals: Call for emergency action to limit global temperature increases, restore biodiversity, and protect health' }])
|
118
|
+
crossref = Maremma.from_xml(subject.crossref).dig('doi_batch', 'body', 'posted_content')
|
119
|
+
expect(crossref.dig('titles',
|
120
|
+
'title')).to eq('Editorial by more than 200 health journals: Call for emergency action to limit global temperature increases, restore biodiversity, and protect health')
|
113
121
|
end
|
114
122
|
end
|
115
123
|
end
|