briard 2.4.1 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,416 +3,511 @@
|
|
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 datacite xml' do
|
7
|
+
it 'with data citation' do
|
8
|
+
input = '10.7554/eLife.01567'
|
9
|
+
subject = described_class.new(input: input, from: 'crossref')
|
10
10
|
expect(subject.valid?).to be true
|
11
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
12
|
-
expect(datacite.dig(
|
13
|
-
expect(datacite.dig(
|
14
|
-
|
15
|
-
expect(datacite.dig(
|
16
|
-
expect(datacite.dig(
|
17
|
-
|
18
|
-
|
19
|
-
expect(datacite.dig(
|
11
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
12
|
+
expect(datacite.dig('resourceType', 'resourceTypeGeneral')).to eq('JournalArticle')
|
13
|
+
expect(datacite.dig('titles',
|
14
|
+
'title')).to eq('Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth')
|
15
|
+
expect(datacite.dig('relatedIdentifiers', 'relatedIdentifier').length).to eq(28)
|
16
|
+
expect(datacite.dig('relatedIdentifiers',
|
17
|
+
'relatedIdentifier').first).to eq('relatedIdentifierType' => 'ISSN', 'relationType' => 'IsPartOf',
|
18
|
+
'__content__' => '2050-084X', 'resourceTypeGeneral' => 'Collection')
|
19
|
+
expect(datacite.dig('relatedIdentifiers',
|
20
|
+
'relatedIdentifier')[1]).to eq('relatedIdentifierType' => 'DOI', 'relationType' => 'References',
|
21
|
+
'__content__' => '10.1038/nature02100')
|
22
|
+
expect(datacite.dig('rightsList',
|
23
|
+
'rights')).to eq('rightsURI' => 'https://creativecommons.org/licenses/by/3.0/legalcode',
|
24
|
+
'rightsIdentifier' => 'cc-by-3.0', 'rightsIdentifierScheme' => 'SPDX', 'schemeURI' => 'https://spdx.org/licenses/', '__content__' => 'Creative Commons Attribution 3.0 Unported')
|
25
|
+
expect(datacite.dig('fundingReferences', 'fundingReference').count).to eq(4)
|
26
|
+
expect(datacite.dig('fundingReferences',
|
27
|
+
'fundingReference').last).to eq('funderName' => 'University of Lausanne',
|
28
|
+
'funderIdentifier' => { 'funderIdentifierType' => 'Crossref Funder ID',
|
29
|
+
'__content__' => 'https://doi.org/10.13039/501100006390' })
|
20
30
|
end
|
21
31
|
|
22
|
-
it
|
23
|
-
input =
|
24
|
-
subject =
|
32
|
+
it 'with ORCID ID' do
|
33
|
+
input = 'https://doi.org/10.1155/2012/291294'
|
34
|
+
subject = described_class.new(input: input, from: 'crossref')
|
25
35
|
expect(subject.valid?).to be true
|
26
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
27
|
-
expect(datacite.dig(
|
28
|
-
expect(datacite.dig(
|
29
|
-
expect(datacite.dig(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
36
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
37
|
+
expect(datacite.dig('resourceType', 'resourceTypeGeneral')).to eq('JournalArticle')
|
38
|
+
expect(datacite.dig('creators', 'creator').count).to eq(7)
|
39
|
+
expect(datacite.dig('creators',
|
40
|
+
'creator')[2]).to eq('creatorName' => { '__content__' => 'Hernandez, Beatriz', 'nameType' => 'Personal' },
|
41
|
+
'familyName' => 'Hernandez',
|
42
|
+
'givenName' => 'Beatriz',
|
43
|
+
'affiliation' => [
|
44
|
+
'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', 'Department of Psychiatry and Behavioral Sciences, Stanford University School of Medicine, Stanford, CA 94304, USA'
|
45
|
+
],
|
46
|
+
'nameIdentifier' => { 'nameIdentifierScheme' => 'ORCID', 'schemeURI' => 'https://orcid.org',
|
47
|
+
'__content__' => 'https://orcid.org/0000-0003-2043-4925' })
|
34
48
|
end
|
35
49
|
|
36
|
-
it
|
37
|
-
input =
|
38
|
-
subject =
|
50
|
+
it 'with editor' do
|
51
|
+
input = 'https://doi.org/10.1371/journal.pone.0000030'
|
52
|
+
subject = described_class.new(input: input, from: 'crossref')
|
39
53
|
expect(subject.valid?).to be true
|
40
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
41
|
-
expect(datacite.dig(
|
54
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
55
|
+
expect(datacite.dig('contributors',
|
56
|
+
'contributor')).to eq(
|
57
|
+
'contributorName' => { '__content__' => 'Janbon, Guilhem',
|
58
|
+
'nameType' => 'Personal' }, 'contributorType' => 'Editor', 'familyName' => 'Janbon', 'givenName' => 'Guilhem'
|
59
|
+
)
|
42
60
|
end
|
43
61
|
|
44
|
-
it
|
45
|
-
input = fixture_path
|
46
|
-
subject =
|
62
|
+
it 'Crossref DOI' do
|
63
|
+
input = "#{fixture_path}crossref.bib"
|
64
|
+
subject = described_class.new(input: input, from: 'bibtex')
|
47
65
|
expect(subject.valid?).to be true
|
48
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
49
|
-
expect(datacite.dig(
|
50
|
-
expect(datacite.dig(
|
51
|
-
|
52
|
-
expect(datacite.dig(
|
53
|
-
|
54
|
-
|
66
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
67
|
+
expect(datacite.dig('resourceType', 'resourceTypeGeneral')).to eq('JournalArticle')
|
68
|
+
expect(datacite.dig('titles',
|
69
|
+
'title')).to eq('Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth')
|
70
|
+
expect(datacite.dig('descriptions',
|
71
|
+
'description').first).to eq('__content__' => 'eLife, 3',
|
72
|
+
'descriptionType' => 'SeriesInformation')
|
73
|
+
expect(datacite.dig('descriptions', 'description', 1,
|
74
|
+
'__content__')).to start_with('Among various advantages, their small size makes model organisms preferred subjects of investigation.')
|
75
|
+
expect(datacite.dig('creators', 'creator').count).to eq(5)
|
76
|
+
expect(datacite.dig('creators',
|
77
|
+
'creator').first).to eq(
|
78
|
+
'creatorName' => { '__content__' => 'Sankar, Martial',
|
79
|
+
'nameType' => 'Personal' }, 'familyName' => 'Sankar', 'givenName' => 'Martial'
|
80
|
+
)
|
55
81
|
end
|
56
82
|
|
57
|
-
it
|
58
|
-
input = fixture_path
|
59
|
-
subject =
|
83
|
+
it 'BlogPosting Citeproc JSON' do
|
84
|
+
input = "#{fixture_path}citeproc.json"
|
85
|
+
subject = described_class.new(input: input, from: 'citeproc')
|
60
86
|
expect(subject.valid?).to be true
|
61
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
62
|
-
expect(datacite.dig(
|
63
|
-
expect(datacite.dig(
|
64
|
-
expect(datacite.dig(
|
65
|
-
|
66
|
-
|
87
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
88
|
+
expect(datacite.dig('resourceType', 'resourceTypeGeneral')).to eq('Text')
|
89
|
+
expect(datacite.dig('titles', 'title')).to eq('Eating your own Dog Food')
|
90
|
+
expect(datacite.dig('descriptions',
|
91
|
+
'description').first).to eq('__content__' => 'DataCite Blog',
|
92
|
+
'descriptionType' => 'SeriesInformation')
|
93
|
+
expect(datacite.dig('descriptions', 'description', 1,
|
94
|
+
'__content__')).to start_with('Eating your own dog food')
|
95
|
+
expect(datacite.dig('creators',
|
96
|
+
'creator')).to eq('creatorName' => 'Fenner, Martin',
|
97
|
+
'familyName' => 'Fenner', 'givenName' => 'Martin')
|
67
98
|
end
|
68
99
|
|
69
|
-
it
|
70
|
-
input = fixture_path
|
71
|
-
subject =
|
100
|
+
it 'rdataone' do
|
101
|
+
input = "#{fixture_path}codemeta.json"
|
102
|
+
subject = described_class.new(input: input, from: 'codemeta')
|
72
103
|
expect(subject.valid?).to be true
|
73
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
74
|
-
expect(datacite.dig(
|
75
|
-
expect(datacite.dig(
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
104
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
105
|
+
expect(datacite.dig('titles', 'title')).to eq('R Interface to the DataONE REST API')
|
106
|
+
expect(datacite.dig('creators',
|
107
|
+
'creator')).to eq([{ 'affiliation' => 'NCEAS', 'creatorName' => { '__content__' => 'Jones, Matt', 'nameType' => 'Personal' },
|
108
|
+
'givenName' => 'Matt',
|
109
|
+
'familyName' => 'Jones',
|
110
|
+
'nameIdentifier' =>
|
111
|
+
{ 'nameIdentifierScheme' => 'ORCID',
|
112
|
+
'schemeURI' => 'https://orcid.org',
|
113
|
+
'__content__' => 'https://orcid.org/0000-0003-0077-4738' } },
|
114
|
+
{ 'affiliation' => 'NCEAS', 'creatorName' => { '__content__' => 'Slaughter, Peter', 'nameType' => 'Personal' },
|
115
|
+
'givenName' => 'Peter',
|
116
|
+
'familyName' => 'Slaughter',
|
117
|
+
'nameIdentifier' =>
|
118
|
+
{ 'nameIdentifierScheme' => 'ORCID',
|
119
|
+
'schemeURI' => 'https://orcid.org',
|
120
|
+
'__content__' => 'https://orcid.org/0000-0002-2192-403X' } },
|
121
|
+
{ 'creatorName' => {
|
122
|
+
'__content__' => 'University Of California, Santa Barbara', 'nameType' => 'Organizational'
|
123
|
+
} }])
|
124
|
+
expect(datacite.fetch('version')).to eq('2.0.0')
|
91
125
|
end
|
92
126
|
|
93
|
-
it
|
94
|
-
input = fixture_path
|
95
|
-
subject =
|
127
|
+
it 'rdataone and codemeta_v2' do
|
128
|
+
input = "#{fixture_path}codemeta_v2.json"
|
129
|
+
subject = described_class.new(input: input, from: 'codemeta')
|
96
130
|
expect(subject.valid?).to be true
|
97
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
98
|
-
expect(datacite.dig(
|
99
|
-
expect(datacite.dig(
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
131
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
132
|
+
expect(datacite.dig('titles', 'title')).to eq('R Interface to the DataONE REST API')
|
133
|
+
expect(datacite.dig('creators',
|
134
|
+
'creator')).to eq([{ 'affiliation' => 'NCEAS', 'creatorName' => { '__content__' => 'Jones, Matt', 'nameType' => 'Personal' },
|
135
|
+
'givenName' => 'Matt',
|
136
|
+
'familyName' => 'Jones',
|
137
|
+
'nameIdentifier' =>
|
138
|
+
{ 'nameIdentifierScheme' => 'ORCID',
|
139
|
+
'schemeURI' => 'https://orcid.org',
|
140
|
+
'__content__' => 'https://orcid.org/0000-0003-0077-4738' } },
|
141
|
+
{ 'affiliation' => 'NCEAS', 'creatorName' => { '__content__' => 'Slaughter, Peter', 'nameType' => 'Personal' },
|
142
|
+
'givenName' => 'Peter',
|
143
|
+
'familyName' => 'Slaughter',
|
144
|
+
'nameIdentifier' =>
|
145
|
+
{ 'nameIdentifierScheme' => 'ORCID',
|
146
|
+
'schemeURI' => 'https://orcid.org',
|
147
|
+
'__content__' => 'https://orcid.org/0000-0002-2192-403X' } },
|
148
|
+
{ 'creatorName' => {
|
149
|
+
'__content__' => 'University Of California, Santa Barbara', 'nameType' => 'Organizational'
|
150
|
+
} }])
|
151
|
+
expect(datacite.fetch('version')).to eq('2.0.0')
|
115
152
|
end
|
116
153
|
|
117
|
-
it
|
118
|
-
input =
|
119
|
-
subject =
|
154
|
+
it 'maremma' do
|
155
|
+
input = 'https://github.com/datacite/maremma'
|
156
|
+
subject = described_class.new(input: input, from: 'codemeta')
|
120
157
|
expect(subject.valid?).to be true
|
121
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
122
|
-
expect(datacite.dig(
|
123
|
-
|
158
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
159
|
+
expect(datacite.dig('titles',
|
160
|
+
'title')).to eq('Maremma: a Ruby library for simplified network calls')
|
161
|
+
expect(datacite.dig('creators',
|
162
|
+
'creator')).to eq('affiliation' => 'DataCite',
|
163
|
+
'creatorName' => { '__content__' => 'Fenner, Martin', 'nameType' => 'Personal' }, 'givenName' => 'Martin', 'familyName' => 'Fenner', 'nameIdentifier' => { '__content__' => 'https://orcid.org/0000-0003-0077-4738', 'nameIdentifierScheme' => 'ORCID', 'schemeURI' => 'https://orcid.org' })
|
124
164
|
end
|
125
165
|
|
126
|
-
it
|
127
|
-
input =
|
128
|
-
subject =
|
166
|
+
it 'with version' do
|
167
|
+
input = 'https://doi.org/10.5281/zenodo.28518'
|
168
|
+
subject = described_class.new(input: input, from: 'datacite', regenerate: true)
|
129
169
|
expect(subject.valid?).to be true
|
130
|
-
expect(subject.id).to eq(
|
131
|
-
expect(subject.identifiers).to eq([{
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
170
|
+
expect(subject.id).to eq('https://doi.org/10.5281/zenodo.28518')
|
171
|
+
expect(subject.identifiers).to eq([{ 'identifier' => 'https://zenodo.org/record/28518',
|
172
|
+
'identifierType' => 'URL' }])
|
173
|
+
expect(subject.types).to eq('bibtex' => 'misc',
|
174
|
+
'citeproc' => 'article',
|
175
|
+
'resourceTypeGeneral' => 'Software',
|
176
|
+
'ris' => 'COMP',
|
177
|
+
'schemaOrg' => 'SoftwareSourceCode')
|
137
178
|
expect(subject.creators.length).to eq(2)
|
138
|
-
expect(subject.creators.first).to eq(
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
expect(subject.titles).to eq([{
|
145
|
-
expect(subject.rights_list).to eq([{
|
146
|
-
|
147
|
-
expect(subject.
|
148
|
-
expect(subject.
|
149
|
-
expect(subject.
|
150
|
-
expect(subject.
|
151
|
-
expect(subject.
|
152
|
-
expect(subject.
|
179
|
+
expect(subject.creators.first).to eq('affiliation' => [{ 'name' => 'University of Washington' }],
|
180
|
+
'familyName' => 'Vanderplas',
|
181
|
+
'givenName' => 'Jake',
|
182
|
+
'name' => 'Vanderplas, Jake',
|
183
|
+
'nameIdentifiers' => [],
|
184
|
+
'nameType' => 'Personal')
|
185
|
+
expect(subject.titles).to eq([{ 'title' => 'Supersmoother: Minor Bug Fix Release' }])
|
186
|
+
expect(subject.rights_list).to eq([{ 'rights' => 'Open Access',
|
187
|
+
'rightsUri' => 'info:eu-repo/semantics/openAccess' }])
|
188
|
+
expect(subject.dates).to eq([{ 'date' => '2015-08-19', 'dateType' => 'Issued' }])
|
189
|
+
expect(subject.publication_year).to eq('2015')
|
190
|
+
expect(subject.version_info).to eq('v0.3.2')
|
191
|
+
expect(subject.publisher).to eq('Zenodo')
|
192
|
+
expect(subject.agency).to eq('datacite')
|
193
|
+
expect(subject.schema_version).to eq('http://datacite.org/schema/kernel-4')
|
194
|
+
expect(subject.datacite).to include('<version>v0.3.2</version>')
|
153
195
|
end
|
154
196
|
|
155
|
-
it
|
156
|
-
input =
|
157
|
-
subject =
|
197
|
+
it 'Text pass-thru' do
|
198
|
+
input = 'https://doi.org/10.23640/07243.5153971'
|
199
|
+
subject = described_class.new(input: input, from: 'datacite')
|
158
200
|
expect(subject.valid?).to be true
|
159
|
-
expect(subject.id).to eq(
|
160
|
-
expect(subject.types).to eq(
|
201
|
+
expect(subject.id).to eq('https://doi.org/10.23640/07243.5153971')
|
202
|
+
expect(subject.types).to eq('bibtex' => 'article', 'citeproc' => 'article-journal',
|
203
|
+
'resourceType' => 'Paper', 'resourceTypeGeneral' => 'Text', 'ris' => 'RPRT', 'schemaOrg' => 'ScholarlyArticle')
|
161
204
|
expect(subject.creators.length).to eq(20)
|
162
|
-
expect(subject.creators.first).to eq(
|
163
|
-
|
164
|
-
expect(subject.
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
expect(subject.
|
171
|
-
|
172
|
-
expect(subject.
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
expect(subject.
|
205
|
+
expect(subject.creators.first).to eq('nameType' => 'Personal', 'familyName' => 'Paglione',
|
206
|
+
'givenName' => 'Laura', 'nameIdentifiers' => [{ 'nameIdentifier' => 'https://orcid.org/0000-0003-3188-6273', 'nameIdentifierScheme' => 'ORCID', 'schemeUri' => 'https://orcid.org' }], 'name' => 'Paglione, Laura', 'affiliation' => [])
|
207
|
+
expect(subject.titles).to eq([{ 'title' => 'Recommendation of: ORCID Works Metadata Working Group' }])
|
208
|
+
expect(subject.rights_list).to eq([{ 'rights' => 'Creative Commons Zero v1.0 Universal',
|
209
|
+
'rightsIdentifier' => 'cc0-1.0',
|
210
|
+
'rightsIdentifierScheme' => 'SPDX',
|
211
|
+
'rightsUri' => 'https://creativecommons.org/publicdomain/zero/1.0/legalcode',
|
212
|
+
'schemeUri' => 'https://spdx.org/licenses/' }])
|
213
|
+
expect(subject.dates).to eq([{ 'date' => '2017-06-28', 'dateType' => 'Created' },
|
214
|
+
{ 'date' => '2017-06-28', 'dateType' => 'Updated' }, { 'date' => '2017', 'dateType' => 'Issued' }])
|
215
|
+
expect(subject.publication_year).to eq('2017')
|
216
|
+
expect(subject.publisher).to eq('Figshare')
|
217
|
+
expect(subject.subjects).to eq([{ 'subject' => 'information systems' },
|
218
|
+
{ 'schemeUri' => 'http://www.oecd.org/science/inno/38235147.pdf',
|
219
|
+
'subject' => 'FOS: Computer and information sciences',
|
220
|
+
'subjectScheme' => 'Fields of Science and Technology (FOS)' }])
|
221
|
+
expect(subject.agency).to eq('datacite')
|
222
|
+
expect(subject.schema_version).to eq('http://datacite.org/schema/kernel-3')
|
223
|
+
expect(subject.datacite).to end_with('</resource>')
|
179
224
|
end
|
180
225
|
|
181
|
-
it
|
182
|
-
input =
|
183
|
-
subject =
|
226
|
+
it 'Text pass-thru with doi in options' do
|
227
|
+
input = 'https://doi.org/10.23640/07243.5153971'
|
228
|
+
subject = described_class.new(input: input, from: 'datacite', doi: '10.5072/07243.5153971')
|
184
229
|
expect(subject.valid?).to be true
|
185
|
-
expect(subject.id).to eq(
|
186
|
-
expect(subject.types).to eq(
|
230
|
+
expect(subject.id).to eq('https://doi.org/10.5072/07243.5153971')
|
231
|
+
expect(subject.types).to eq('bibtex' => 'article', 'citeproc' => 'article-journal',
|
232
|
+
'resourceType' => 'Paper', 'resourceTypeGeneral' => 'Text', 'ris' => 'RPRT', 'schemaOrg' => 'ScholarlyArticle')
|
187
233
|
expect(subject.creators.length).to eq(20)
|
188
|
-
expect(subject.creators.first).to eq(
|
189
|
-
|
190
|
-
expect(subject.
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
expect(subject.
|
197
|
-
|
198
|
-
expect(subject.
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
expect(subject.
|
234
|
+
expect(subject.creators.first).to eq('nameType' => 'Personal', 'familyName' => 'Paglione',
|
235
|
+
'givenName' => 'Laura', 'name' => 'Paglione, Laura', 'nameIdentifiers' => [{ 'nameIdentifier' => 'https://orcid.org/0000-0003-3188-6273', 'nameIdentifierScheme' => 'ORCID', 'schemeUri' => 'https://orcid.org' }], 'affiliation' => [])
|
236
|
+
expect(subject.titles).to eq([{ 'title' => 'Recommendation of: ORCID Works Metadata Working Group' }])
|
237
|
+
expect(subject.rights_list).to eq([{ 'rights' => 'Creative Commons Zero v1.0 Universal',
|
238
|
+
'rightsIdentifier' => 'cc0-1.0',
|
239
|
+
'rightsIdentifierScheme' => 'SPDX',
|
240
|
+
'rightsUri' => 'https://creativecommons.org/publicdomain/zero/1.0/legalcode',
|
241
|
+
'schemeUri' => 'https://spdx.org/licenses/' }])
|
242
|
+
expect(subject.dates).to eq([{ 'date' => '2017-06-28', 'dateType' => 'Created' },
|
243
|
+
{ 'date' => '2017-06-28', 'dateType' => 'Updated' }, { 'date' => '2017', 'dateType' => 'Issued' }])
|
244
|
+
expect(subject.publication_year).to eq('2017')
|
245
|
+
expect(subject.publisher).to eq('Figshare')
|
246
|
+
expect(subject.subjects).to eq([{ 'subject' => 'information systems' },
|
247
|
+
{ 'schemeUri' => 'http://www.oecd.org/science/inno/38235147.pdf',
|
248
|
+
'subject' => 'FOS: Computer and information sciences',
|
249
|
+
'subjectScheme' => 'Fields of Science and Technology (FOS)' }])
|
250
|
+
expect(subject.agency).to eq('datacite')
|
251
|
+
expect(subject.schema_version).to eq('http://datacite.org/schema/kernel-3')
|
252
|
+
expect(subject.datacite).to end_with('</resource>')
|
205
253
|
end
|
206
254
|
|
207
|
-
it
|
208
|
-
input =
|
209
|
-
subject =
|
255
|
+
it 'Dataset in schema 4.0' do
|
256
|
+
input = 'https://doi.org/10.5061/DRYAD.8515'
|
257
|
+
subject = described_class.new(input: input, from: 'datacite', regenerate: true)
|
210
258
|
expect(subject.valid?).to be true
|
211
|
-
expect(subject.types).to eq(
|
259
|
+
expect(subject.types).to eq('bibtex' => 'misc', 'citeproc' => 'dataset',
|
260
|
+
'resourceType' => 'dataset', 'resourceTypeGeneral' => 'Dataset', 'ris' => 'DATA', 'schemaOrg' => 'Dataset')
|
212
261
|
expect(subject.creators.length).to eq(8)
|
213
|
-
expect(subject.creators.first).to eq(
|
214
|
-
|
215
|
-
expect(subject.
|
216
|
-
expect(subject.
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
expect(subject.
|
262
|
+
expect(subject.creators.first).to eq('nameType' => 'Personal', 'name' => 'Ollomo, Benjamin',
|
263
|
+
'givenName' => 'Benjamin', 'familyName' => 'Ollomo', 'nameIdentifiers' => [], 'affiliation' => [{ 'affiliationIdentifier' => 'https://ror.org/01wyqb997', 'affiliationIdentifierScheme' => 'ROR', 'name' => 'Centre International de Recherches Médicales de Franceville' }])
|
264
|
+
expect(subject.titles).to eq([{ 'title' => 'Data from: A new malaria agent in African hominids.' }])
|
265
|
+
expect(subject.id).to eq('https://doi.org/10.5061/dryad.8515')
|
266
|
+
expect(subject.rights_list).to eq([{ 'rights' => 'Creative Commons Zero v1.0 Universal',
|
267
|
+
'rightsIdentifier' => 'cc0-1.0',
|
268
|
+
'rightsIdentifierScheme' => 'SPDX',
|
269
|
+
'rightsUri' => 'https://creativecommons.org/publicdomain/zero/1.0/legalcode',
|
270
|
+
'schemeUri' => 'https://spdx.org/licenses/' }])
|
271
|
+
expect(subject.dates).to eq([{ 'date' => '2011-02-01T17:22:41Z', 'dateType' => 'Available' },
|
272
|
+
{ 'date' => '2011', 'dateType' => 'Issued' }])
|
273
|
+
expect(subject.publication_year).to eq('2011')
|
223
274
|
expect(subject.related_identifiers.length).to eq(1)
|
224
|
-
expect(subject.related_identifiers.last).to eq(
|
225
|
-
|
226
|
-
expect(subject.publisher).to eq(
|
227
|
-
expect(subject.agency).to eq(
|
228
|
-
expect(subject.schema_version).to eq(
|
275
|
+
expect(subject.related_identifiers.last).to eq('relatedIdentifier' => '10.1371/journal.ppat.1000446',
|
276
|
+
'relatedIdentifierType' => 'DOI', 'relationType' => 'IsCitedBy')
|
277
|
+
expect(subject.publisher).to eq('Dryad')
|
278
|
+
expect(subject.agency).to eq('datacite')
|
279
|
+
expect(subject.schema_version).to eq('http://datacite.org/schema/kernel-4')
|
229
280
|
|
230
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
231
|
-
expect(datacite.fetch(
|
281
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
282
|
+
expect(datacite.fetch('xsi:schemaLocation', '').split.first).to eq('http://datacite.org/schema/kernel-4')
|
232
283
|
end
|
233
284
|
|
234
|
-
it
|
235
|
-
input = fixture_path
|
236
|
-
doi =
|
237
|
-
subject =
|
285
|
+
it 'Affiliation' do
|
286
|
+
input = "#{fixture_path}datacite-example-geolocation-2.xml"
|
287
|
+
doi = '10.6071/Z7WC73'
|
288
|
+
subject = described_class.new(input: input, from: 'datacite', regenerate: true)
|
238
289
|
expect(subject.valid?).to be true
|
239
|
-
expect(subject.types).to eq(
|
290
|
+
expect(subject.types).to eq('bibtex' => 'misc', 'citeproc' => 'dataset',
|
291
|
+
'resourceType' => 'dataset', 'resourceTypeGeneral' => 'Dataset', 'ris' => 'DATA', 'schemaOrg' => 'Dataset')
|
240
292
|
expect(subject.creators.length).to eq(6)
|
241
|
-
expect(subject.creators.first).to eq(
|
242
|
-
|
243
|
-
expect(subject.
|
244
|
-
expect(subject.
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
expect(subject.
|
251
|
-
|
252
|
-
expect(subject.
|
253
|
-
expect(subject.
|
293
|
+
expect(subject.creators.first).to eq('affiliation' => [{ 'name' => 'UC Merced' }, { 'name' => 'NSF' }],
|
294
|
+
'familyName' => 'Bales', 'givenName' => 'Roger', 'name' => 'Bales, Roger', 'nameType' => 'Personal', 'nameIdentifiers' => [])
|
295
|
+
expect(subject.titles).to eq([{ 'title' => 'Southern Sierra Critical Zone Observatory (SSCZO), Providence Creek meteorological data, soil moisture and temperature, snow depth and air temperature' }])
|
296
|
+
expect(subject.id).to eq('https://doi.org/10.6071/z7wc73')
|
297
|
+
expect(subject.rights_list).to eq([{ 'rights' => 'Creative Commons Attribution 4.0 International',
|
298
|
+
'rightsIdentifier' => 'cc-by-4.0',
|
299
|
+
'rightsIdentifierScheme' => 'SPDX',
|
300
|
+
'rightsUri' => 'https://creativecommons.org/licenses/by/4.0/legalcode',
|
301
|
+
'schemeUri' => 'https://spdx.org/licenses/' }])
|
302
|
+
expect(subject.dates).to eq([{ 'date' => '2014-10-17', 'dateType' => 'Updated' },
|
303
|
+
{ 'date' => '2016-03-14T17:02:02Z', 'dateType' => 'Available' }, { 'date' => '2013', 'dateType' => 'Issued' }])
|
304
|
+
expect(subject.publication_year).to eq('2013')
|
305
|
+
expect(subject.publisher).to eq('UC Merced')
|
306
|
+
expect(subject.agency).to eq('datacite')
|
307
|
+
expect(subject.schema_version).to eq('http://datacite.org/schema/kernel-4')
|
254
308
|
|
255
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
256
|
-
expect(datacite.fetch(
|
257
|
-
expect(datacite.dig(
|
309
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
310
|
+
expect(datacite.fetch('xsi:schemaLocation', '').split.first).to eq('http://datacite.org/schema/kernel-4')
|
311
|
+
expect(datacite.dig('creators', 'creator', 0, 'affiliation')).to eq(['UC Merced', 'NSF'])
|
258
312
|
end
|
259
313
|
|
260
|
-
it
|
261
|
-
input =
|
262
|
-
subject =
|
314
|
+
it 'DOI not found' do
|
315
|
+
input = 'https://doi.org/10.4124/05F6C379-DD68-4CDB-880D-33D3E9576D52/1'
|
316
|
+
subject = described_class.new(input: input, from: 'datacite')
|
263
317
|
expect(subject.valid?).to be false
|
264
|
-
expect(subject.id).to eq(
|
265
|
-
expect(subject.doi).to eq(
|
266
|
-
expect(subject.agency).to eq(
|
267
|
-
expect(subject.state).to eq(
|
268
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
269
|
-
expect(datacite[
|
270
|
-
|
318
|
+
expect(subject.id).to eq('https://doi.org/10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1')
|
319
|
+
expect(subject.doi).to eq('10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1')
|
320
|
+
expect(subject.agency).to eq('datacite')
|
321
|
+
expect(subject.state).to eq('not_found')
|
322
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
323
|
+
expect(datacite['identifier']).to eq('identifierType' => 'DOI',
|
324
|
+
'__content__' => '10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1')
|
325
|
+
expect(datacite['xmlns']).to eq('http://datacite.org/schema/kernel-4')
|
271
326
|
end
|
272
327
|
|
273
|
-
it
|
328
|
+
it 'no input' do
|
274
329
|
input = nil
|
275
|
-
subject =
|
330
|
+
subject = described_class.new(input: input, from: 'datacite',
|
331
|
+
doi: '10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1')
|
276
332
|
expect(subject.valid?).to be false
|
277
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
278
|
-
expect(datacite[
|
279
|
-
|
333
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
334
|
+
expect(datacite['identifier']).to eq('identifierType' => 'DOI',
|
335
|
+
'__content__' => '10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1')
|
336
|
+
expect(datacite['xmlns']).to eq('http://datacite.org/schema/kernel-4')
|
280
337
|
end
|
281
338
|
end
|
282
339
|
|
283
|
-
context
|
284
|
-
it
|
285
|
-
input =
|
286
|
-
subject =
|
287
|
-
subject.doi =
|
288
|
-
subject.titles = [{
|
289
|
-
subject.types = {
|
340
|
+
context 'change metadata as datacite xml' do
|
341
|
+
it 'with data citation' do
|
342
|
+
input = '10.7554/eLife.01567'
|
343
|
+
subject = described_class.new(input: input, from: 'crossref')
|
344
|
+
subject.doi = '10.5061/DRYAD.8515'
|
345
|
+
subject.titles = [{ 'title' => 'Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth' }]
|
346
|
+
subject.types = { 'schemaOrg' => 'Dataset', 'resourceTypeGeneral' => 'Dataset' }
|
290
347
|
expect(subject.valid?).to be true
|
291
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
292
|
-
expect(datacite.dig(
|
293
|
-
expect(datacite.dig(
|
294
|
-
expect(datacite.dig(
|
295
|
-
|
296
|
-
expect(datacite.dig(
|
297
|
-
expect(datacite.dig(
|
298
|
-
|
299
|
-
|
300
|
-
expect(datacite.dig(
|
348
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
349
|
+
expect(datacite.dig('identifier', '__content__')).to eq('10.5061/DRYAD.8515')
|
350
|
+
expect(datacite.dig('resourceType', 'resourceTypeGeneral')).to eq('Dataset')
|
351
|
+
expect(datacite.dig('titles',
|
352
|
+
'title')).to eq('Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth')
|
353
|
+
expect(datacite.dig('relatedIdentifiers', 'relatedIdentifier').length).to eq(28)
|
354
|
+
expect(datacite.dig('relatedIdentifiers',
|
355
|
+
'relatedIdentifier').first).to eq('__content__' => '2050-084X', 'relatedIdentifierType' => 'ISSN',
|
356
|
+
'relationType' => 'IsPartOf', 'resourceTypeGeneral' => 'Collection')
|
357
|
+
expect(datacite.dig('relatedIdentifiers',
|
358
|
+
'relatedIdentifier')[1]).to eq('relatedIdentifierType' => 'DOI', 'relationType' => 'References',
|
359
|
+
'__content__' => '10.1038/nature02100')
|
360
|
+
expect(datacite.dig('rightsList',
|
361
|
+
'rights')).to eq('rightsURI' => 'https://creativecommons.org/licenses/by/3.0/legalcode',
|
362
|
+
'rightsIdentifier' => 'cc-by-3.0', 'rightsIdentifierScheme' => 'SPDX', 'schemeURI' => 'https://spdx.org/licenses/', '__content__' => 'Creative Commons Attribution 3.0 Unported')
|
363
|
+
expect(datacite.dig('fundingReferences', 'fundingReference').count).to eq(4)
|
364
|
+
expect(datacite.dig('fundingReferences',
|
365
|
+
'fundingReference').last).to eq('funderName' => 'University of Lausanne',
|
366
|
+
'funderIdentifier' => { 'funderIdentifierType' => 'Crossref Funder ID',
|
367
|
+
'__content__' => 'https://doi.org/10.13039/501100006390' })
|
301
368
|
end
|
302
369
|
|
303
|
-
it
|
304
|
-
input =
|
305
|
-
subject =
|
306
|
-
subject.descriptions = {
|
370
|
+
it 'change description' do
|
371
|
+
input = '10.7554/eLife.01567'
|
372
|
+
subject = described_class.new(input: input, from: 'crossref')
|
373
|
+
subject.descriptions = { 'description' => 'This is an abstract.' }
|
307
374
|
expect(subject.valid?).to be true
|
308
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
309
|
-
expect(datacite.dig(
|
375
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
376
|
+
expect(datacite.dig('descriptions',
|
377
|
+
'description')).to eq([
|
378
|
+
{ '__content__' => 'eLife, 3, e01567',
|
379
|
+
'descriptionType' => 'SeriesInformation' }, { '__content__' => 'This is an abstract.', 'descriptionType' => 'Abstract' }
|
380
|
+
])
|
310
381
|
end
|
311
382
|
|
312
|
-
it
|
383
|
+
it 'change description no input' do
|
313
384
|
input = nil
|
314
|
-
subject =
|
315
|
-
|
385
|
+
subject = described_class.new(input: input, from: 'datacite',
|
386
|
+
doi: '10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1')
|
387
|
+
subject.descriptions = 'This is an abstract.'
|
316
388
|
expect(subject.valid?).to be false
|
317
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
318
|
-
expect(datacite.dig(
|
389
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
390
|
+
expect(datacite.dig('descriptions',
|
391
|
+
'description')).to eq('descriptionType' => 'Abstract',
|
392
|
+
'__content__' => 'This is an abstract.')
|
319
393
|
end
|
320
394
|
|
321
|
-
it
|
395
|
+
it 'required metadata no input' do
|
322
396
|
input = nil
|
323
|
-
subject =
|
324
|
-
|
325
|
-
subject.
|
326
|
-
|
327
|
-
subject.
|
328
|
-
subject.
|
397
|
+
subject = described_class.new(input: input,
|
398
|
+
doi: '10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1')
|
399
|
+
subject.creators = [{ 'creatorName' => 'Fenner, Martin', 'givenName' => 'Martin',
|
400
|
+
'familyName' => 'Fenner' }]
|
401
|
+
subject.titles = [{ 'title' => 'Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth' }]
|
402
|
+
subject.types = { 'schemaOrg' => 'Dataset', 'resourceTypeGeneral' => 'Dataset' }
|
403
|
+
subject.publication_year = '2011'
|
404
|
+
subject.state = 'findable'
|
329
405
|
expect(subject.exists?).to be true
|
330
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
331
|
-
expect(datacite.dig(
|
332
|
-
|
333
|
-
expect(datacite.dig(
|
334
|
-
|
406
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
407
|
+
expect(datacite.dig('identifier',
|
408
|
+
'__content__')).to eq('10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1')
|
409
|
+
expect(datacite.dig('resourceType', 'resourceTypeGeneral')).to eq('Dataset')
|
410
|
+
expect(datacite.dig('titles',
|
411
|
+
'title')).to eq('Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth')
|
335
412
|
end
|
336
413
|
|
337
|
-
it
|
338
|
-
input =
|
339
|
-
subject =
|
340
|
-
subject.rights_list = [{
|
414
|
+
it 'change license' do
|
415
|
+
input = '10.7554/eLife.01567'
|
416
|
+
subject = described_class.new(input: input, from: 'crossref')
|
417
|
+
subject.rights_list = [{ 'rights_uri' => 'https://creativecommons.org/licenses/by-nc-sa/4.0',
|
418
|
+
'rights' => 'Creative Commons Attribution-NonCommercial-ShareAlike' }]
|
341
419
|
expect(subject.valid?).to be true
|
342
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
343
|
-
expect(datacite.dig(
|
420
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
421
|
+
expect(datacite.dig('rightsList',
|
422
|
+
'rights')).to eq('Creative Commons Attribution-NonCommercial-ShareAlike')
|
344
423
|
end
|
345
424
|
|
346
|
-
it
|
347
|
-
input =
|
348
|
-
subject =
|
349
|
-
subject.rights_list = [{
|
425
|
+
it 'change license url' do
|
426
|
+
input = '10.7554/eLife.01567'
|
427
|
+
subject = described_class.new(input: input, from: 'crossref')
|
428
|
+
subject.rights_list = [{ 'rightsUri' => 'https://creativecommons.org/licenses/by-nc-sa/4.0' }]
|
350
429
|
expect(subject.valid?).to be true
|
351
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
352
|
-
expect(datacite.dig(
|
430
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
431
|
+
expect(datacite.dig('rightsList', 'rights')).to eq('rightsURI' => 'https://creativecommons.org/licenses/by-nc-sa/4.0')
|
353
432
|
end
|
354
433
|
|
355
|
-
it
|
356
|
-
input =
|
357
|
-
subject =
|
358
|
-
subject.rights_list = [{
|
434
|
+
it 'change license name' do
|
435
|
+
input = '10.7554/eLife.01567'
|
436
|
+
subject = described_class.new(input: input, from: 'crossref')
|
437
|
+
subject.rights_list = [{ 'rights' => 'Creative Commons Attribution-NonCommercial-ShareAlike' }]
|
359
438
|
expect(subject.valid?).to be true
|
360
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
361
|
-
expect(datacite.dig(
|
439
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
440
|
+
expect(datacite.dig('rightsList',
|
441
|
+
'rights')).to eq('Creative Commons Attribution-NonCommercial-ShareAlike')
|
362
442
|
end
|
363
443
|
|
364
|
-
it
|
365
|
-
input =
|
366
|
-
subject =
|
444
|
+
it 'change state' do
|
445
|
+
input = '10.7554/eLife.01567'
|
446
|
+
subject = described_class.new(input: input, from: 'crossref')
|
367
447
|
expect(subject.valid?).to be true
|
368
|
-
expect(subject.state).to eq(
|
369
|
-
subject.state =
|
370
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
371
|
-
expect(datacite.dig(
|
372
|
-
expect(subject.state).to eq(
|
448
|
+
expect(subject.state).to eq('findable')
|
449
|
+
subject.state = 'registered'
|
450
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
451
|
+
expect(datacite.dig('identifier', '__content__')).to eq('10.7554/elife.01567')
|
452
|
+
expect(subject.state).to eq('registered')
|
373
453
|
end
|
374
454
|
|
375
|
-
it
|
376
|
-
input =
|
377
|
-
subject =
|
455
|
+
it 'change identifiers' do
|
456
|
+
input = '10.7554/eLife.01567'
|
457
|
+
subject = described_class.new(input: input, from: 'crossref')
|
378
458
|
expect(subject.valid?).to be true
|
379
|
-
expect(subject.identifiers).to eq([{
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
expect(
|
459
|
+
expect(subject.identifiers).to eq([{ 'identifier' => 'e01567',
|
460
|
+
'identifierType' => 'article_number' }])
|
461
|
+
subject.identifiers = [{ 'identifierType' => 'article_number', 'identifier' => 'abc' }]
|
462
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
463
|
+
expect(datacite.dig('identifier', '__content__')).to eq('10.7554/elife.01567')
|
464
|
+
expect(subject.identifiers).to eq([{ 'identifier' => 'abc',
|
465
|
+
'identifierType' => 'article_number' }])
|
384
466
|
end
|
385
467
|
|
386
|
-
it
|
387
|
-
input =
|
388
|
-
subject =
|
389
|
-
subject.doi =
|
390
|
-
subject.titles =
|
391
|
-
subject.types = {
|
392
|
-
expect(subject.doi).to eq(
|
468
|
+
it 'validates against schema' do
|
469
|
+
input = '10.7554/eLife.01567'
|
470
|
+
subject = described_class.new(input: input, from: 'crossref')
|
471
|
+
subject.doi = '123'
|
472
|
+
subject.titles = 'Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth'
|
473
|
+
subject.types = { 'schemaOrg' => 'Dataset', 'resourceTypeGeneral' => 'Dataset' }
|
474
|
+
expect(subject.doi).to eq('123')
|
393
475
|
expect(subject.valid?).to be true
|
394
476
|
end
|
395
477
|
|
396
|
-
it
|
397
|
-
input = fixture_path
|
398
|
-
subject =
|
478
|
+
it 'from schema_org gtex' do
|
479
|
+
input = "#{fixture_path}schema_org_gtex.json"
|
480
|
+
subject = described_class.new(input: input, from: 'schema_org')
|
399
481
|
expect(subject.valid?).to be true
|
400
|
-
datacite = Maremma.from_xml(subject.datacite).fetch(
|
401
|
-
expect(datacite.dig(
|
402
|
-
expect(datacite.dig(
|
403
|
-
expect(datacite.dig(
|
404
|
-
|
405
|
-
|
406
|
-
expect(datacite.dig(
|
407
|
-
expect(datacite.dig(
|
408
|
-
expect(datacite.dig(
|
409
|
-
|
410
|
-
expect(datacite
|
411
|
-
expect(datacite
|
412
|
-
expect(datacite.dig(
|
413
|
-
|
414
|
-
|
415
|
-
expect(datacite
|
482
|
+
datacite = Maremma.from_xml(subject.datacite).fetch('resource', {})
|
483
|
+
expect(datacite.dig('identifier', '__content__')).to eq('10.25491/d50j-3083')
|
484
|
+
expect(datacite.dig('creators', 'creator').count).to eq(1)
|
485
|
+
expect(datacite.dig('creators',
|
486
|
+
'creator')).to eq('creatorName' => { '__content__' => 'The GTEx Consortium',
|
487
|
+
'nameType' => 'Organizational' })
|
488
|
+
expect(datacite.dig('resourceType', 'resourceTypeGeneral')).to eq('Dataset')
|
489
|
+
expect(datacite.dig('resourceType', '__content__')).to eq('Gene expression matrices')
|
490
|
+
expect(datacite.dig('titles',
|
491
|
+
'title')).to eq('Fully processed, filtered and normalized gene expression matrices (in BED format) for each tissue, which were used as input into FastQTL for eQTL discovery')
|
492
|
+
expect(datacite['version']).to eq('v7')
|
493
|
+
expect(datacite['publisher']).to eq('GTEx')
|
494
|
+
expect(datacite.dig('descriptions',
|
495
|
+
'description')).to eq('__content__' => 'GTEx',
|
496
|
+
'descriptionType' => 'SeriesInformation')
|
497
|
+
expect(datacite['publicationYear']).to eq('2017')
|
498
|
+
expect(datacite.dig('dates', 'date')).to eq('__content__' => '2017', 'dateType' => 'Issued')
|
499
|
+
expect(datacite.dig('subjects',
|
500
|
+
'subject')).to eq(['gtex', 'annotation', 'phenotype', 'gene regulation',
|
501
|
+
'transcriptomics'])
|
502
|
+
expect(datacite.dig('alternateIdentifiers',
|
503
|
+
'alternateIdentifier')).to eq('__content__' => '687610993',
|
504
|
+
'alternateIdentifierType' => 'md5')
|
505
|
+
expect(datacite.dig('fundingReferences', 'fundingReference').count).to eq(7)
|
506
|
+
expect(datacite.dig('fundingReferences',
|
507
|
+
'fundingReference').last).to eq(
|
508
|
+
'funderIdentifier' => { '__content__' => 'https://doi.org/10.13039/100000065',
|
509
|
+
'funderIdentifierType' => 'Crossref Funder ID' }, 'funderName' => 'National Institute of Neurological Disorders and Stroke (NINDS)'
|
510
|
+
)
|
416
511
|
end
|
417
512
|
end
|
418
513
|
end
|