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,192 +3,208 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Briard::Metadata, vcr: true do
|
6
|
-
context
|
7
|
-
it
|
8
|
-
input =
|
9
|
-
subject =
|
10
|
-
jats = Maremma.from_xml(subject.jats).fetch(
|
11
|
-
expect(jats
|
12
|
-
expect(jats
|
13
|
-
expect(jats
|
14
|
-
expect(jats.dig(
|
15
|
-
expect(jats.dig(
|
16
|
-
|
17
|
-
expect(jats
|
18
|
-
expect(jats
|
6
|
+
context 'write metadata as jats xml' do
|
7
|
+
it 'with data citation' do
|
8
|
+
input = '10.7554/eLife.01567'
|
9
|
+
subject = described_class.new(input: input, from: 'crossref')
|
10
|
+
jats = Maremma.from_xml(subject.jats).fetch('element_citation', {})
|
11
|
+
expect(jats['publication_type']).to eq('journal')
|
12
|
+
expect(jats['article_title']).to eq('Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth')
|
13
|
+
expect(jats['source']).to eq('eLife')
|
14
|
+
expect(jats.dig('person_group', 'name').length).to eq(5)
|
15
|
+
expect(jats.dig('person_group',
|
16
|
+
'name').first).to eq('surname' => 'Sankar', 'given_names' => 'Martial')
|
17
|
+
expect(jats['year']).to eq('iso_8601_date' => '2014-02-11', '__content__' => '2014')
|
18
|
+
expect(jats['month']).to eq('02')
|
19
|
+
expect(jats['day']).to eq('11')
|
19
20
|
end
|
20
21
|
|
21
|
-
it
|
22
|
-
input =
|
23
|
-
subject =
|
24
|
-
jats = Maremma.from_xml(subject.jats).fetch(
|
25
|
-
expect(jats
|
26
|
-
expect(jats
|
27
|
-
expect(jats
|
28
|
-
expect(jats.dig(
|
29
|
-
expect(jats.dig(
|
30
|
-
|
22
|
+
it 'with ORCID ID' do
|
23
|
+
input = 'https://doi.org/10.1155/2012/291294'
|
24
|
+
subject = described_class.new(input: input, from: 'crossref')
|
25
|
+
jats = Maremma.from_xml(subject.jats).fetch('element_citation', {})
|
26
|
+
expect(jats['publication_type']).to eq('journal')
|
27
|
+
expect(jats['article_title']).to eq('Delineating a Retesting Zone Using Receiver Operating Characteristic Analysis on Serial QuantiFERON Tuberculosis Test Results in US Healthcare Workers')
|
28
|
+
expect(jats['source']).to eq('Pulmonary Medicine')
|
29
|
+
expect(jats.dig('person_group', 'name').length).to eq(7)
|
30
|
+
expect(jats.dig('person_group',
|
31
|
+
'name').first).to eq('surname' => 'Thanassi', 'given_names' => 'Wendy')
|
32
|
+
expect(jats['year']).to eq('iso_8601_date' => '2012', '__content__' => '2012')
|
31
33
|
end
|
32
34
|
|
33
|
-
it
|
34
|
-
input =
|
35
|
-
subject =
|
36
|
-
jats = Maremma.from_xml(subject.jats).fetch(
|
37
|
-
expect(jats
|
38
|
-
expect(jats
|
39
|
-
expect(jats
|
40
|
-
expect(jats.dig(
|
41
|
-
expect(jats.dig(
|
42
|
-
|
43
|
-
expect(jats.dig(
|
44
|
-
|
45
|
-
expect(jats
|
46
|
-
expect(jats
|
47
|
-
expect(jats
|
35
|
+
it 'with editor' do
|
36
|
+
input = 'https://doi.org/10.1371/journal.pone.0000030'
|
37
|
+
subject = described_class.new(input: input, from: 'crossref')
|
38
|
+
jats = Maremma.from_xml(subject.jats).fetch('element_citation', {})
|
39
|
+
expect(jats['publication_type']).to eq('journal')
|
40
|
+
expect(jats['article_title']).to eq('Triose Phosphate Isomerase Deficiency Is Caused by Altered Dimerization???Not Catalytic Inactivity???of the Mutant Enzymes')
|
41
|
+
expect(jats['source']).to eq('PLoS ONE')
|
42
|
+
expect(jats.dig('person_group', 0, 'name').length).to eq(5)
|
43
|
+
expect(jats.dig('person_group', 0,
|
44
|
+
'name').first).to eq('surname' => 'Ralser', 'given_names' => 'Markus')
|
45
|
+
expect(jats.dig('person_group', 1,
|
46
|
+
'name')).to eq('surname' => 'Janbon', 'given_names' => 'Guilhem')
|
47
|
+
expect(jats['year']).to eq('iso_8601_date' => '2006-12-20', '__content__' => '2006')
|
48
|
+
expect(jats['month']).to eq('12')
|
49
|
+
expect(jats['day']).to eq('20')
|
50
|
+
expect(jats['fpage']).to eq('e30')
|
51
|
+
expect(jats['pub_id']).to eq('pub_id_type' => 'doi',
|
52
|
+
'__content__' => '10.1371/journal.pone.0000030')
|
48
53
|
end
|
49
54
|
|
50
|
-
it
|
51
|
-
input =
|
52
|
-
subject =
|
53
|
-
jats = Maremma.from_xml(subject.jats).fetch(
|
54
|
-
expect(jats
|
55
|
-
expect(jats
|
56
|
-
expect(jats
|
57
|
-
expect(jats.dig(
|
58
|
-
expect(jats
|
59
|
-
expect(jats
|
60
|
-
expect(jats
|
61
|
-
expect(jats
|
55
|
+
it 'book chapter' do
|
56
|
+
input = 'https://doi.org/10.5005/jp/books/12414_3'
|
57
|
+
subject = described_class.new(input: input, from: 'crossref')
|
58
|
+
jats = Maremma.from_xml(subject.jats).fetch('element_citation', {})
|
59
|
+
expect(jats['publication_type']).to eq('chapter')
|
60
|
+
expect(jats['chapter_title']).to eq('Physical Examinations')
|
61
|
+
expect(jats['source']).to eq('Jaypee Brothers Medical Publishing')
|
62
|
+
expect(jats.dig('person_group', 'name')).to eq('surname' => 'Saha', 'given_names' => 'Ashis')
|
63
|
+
expect(jats['year']).to eq('iso_8601_date' => '2015', '__content__' => '2015')
|
64
|
+
expect(jats['fpage']).to eq('27')
|
65
|
+
expect(jats['lpage']).to eq('27')
|
66
|
+
expect(jats['pub_id']).to eq('pub_id_type' => 'doi',
|
67
|
+
'__content__' => '10.5005/jp/books/12414_3')
|
62
68
|
end
|
63
69
|
|
64
|
-
it
|
65
|
-
input = fixture_path
|
66
|
-
subject =
|
67
|
-
jats = Maremma.from_xml(subject.jats).fetch(
|
68
|
-
expect(jats
|
69
|
-
expect(jats
|
70
|
-
expect(jats
|
71
|
-
expect(jats.dig(
|
72
|
-
expect(jats.dig(
|
73
|
-
|
74
|
-
expect(jats
|
75
|
-
expect(jats.
|
70
|
+
it 'Crossref DOI' do
|
71
|
+
input = "#{fixture_path}crossref.bib"
|
72
|
+
subject = described_class.new(input: input, from: 'bibtex')
|
73
|
+
jats = Maremma.from_xml(subject.jats).fetch('element_citation', {})
|
74
|
+
expect(jats['publication_type']).to eq('journal')
|
75
|
+
expect(jats['article_title']).to eq('Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth')
|
76
|
+
expect(jats['source']).to eq('eLife')
|
77
|
+
expect(jats.dig('person_group', 'name').length).to eq(5)
|
78
|
+
expect(jats.dig('person_group',
|
79
|
+
'name').first).to eq('surname' => 'Sankar', 'given_names' => 'Martial')
|
80
|
+
expect(jats['year']).to eq('iso_8601_date' => '2014', '__content__' => '2014')
|
81
|
+
expect(jats['month'].nil?).to be(true)
|
82
|
+
expect(jats['pub_id']).to eq('pub_id_type' => 'doi', '__content__' => '10.7554/elife.01567')
|
76
83
|
end
|
77
84
|
|
78
|
-
it
|
79
|
-
input = fixture_path
|
80
|
-
subject =
|
81
|
-
jats = Maremma.from_xml(subject.jats).fetch(
|
82
|
-
expect(jats.
|
83
|
-
expect(jats
|
84
|
-
expect(jats
|
85
|
-
expect(jats.dig(
|
86
|
-
|
87
|
-
expect(jats
|
88
|
-
expect(jats
|
89
|
-
expect(jats
|
85
|
+
it 'BlogPosting Citeproc JSON' do
|
86
|
+
input = "#{fixture_path}citeproc.json"
|
87
|
+
subject = described_class.new(input: input, from: 'citeproc')
|
88
|
+
jats = Maremma.from_xml(subject.jats).fetch('element_citation', {})
|
89
|
+
expect(jats['publication_type'].nil?).to be(true)
|
90
|
+
expect(jats['source']).to eq('Eating your own Dog Food')
|
91
|
+
expect(jats['publisher_name']).to eq('DataCite')
|
92
|
+
expect(jats.dig('person_group',
|
93
|
+
'name')).to eq('surname' => 'Fenner', 'given_names' => 'Martin')
|
94
|
+
expect(jats['year']).to eq('iso_8601_date' => '2016-12-20', '__content__' => '2016')
|
95
|
+
expect(jats['month']).to eq('12')
|
96
|
+
expect(jats['day']).to eq('20')
|
97
|
+
expect(jats['pub_id']).to eq('pub_id_type' => 'doi', '__content__' => '10.5438/4k3m-nyvg')
|
90
98
|
end
|
91
99
|
|
92
|
-
it
|
93
|
-
input = fixture_path
|
94
|
-
subject =
|
95
|
-
jats = Maremma.from_xml(subject.jats).fetch(
|
96
|
-
expect(jats
|
97
|
-
expect(jats
|
98
|
-
expect(jats
|
99
|
-
expect(jats.dig(
|
100
|
-
expect(jats.dig(
|
101
|
-
|
102
|
-
expect(jats
|
103
|
-
expect(jats
|
104
|
-
expect(jats
|
105
|
-
expect(jats
|
100
|
+
it 'rdataone' do
|
101
|
+
input = "#{fixture_path}codemeta.json"
|
102
|
+
subject = described_class.new(input: input, from: 'codemeta')
|
103
|
+
jats = Maremma.from_xml(subject.jats).fetch('element_citation', {})
|
104
|
+
expect(jats['publication_type']).to eq('software')
|
105
|
+
expect(jats['source']).to eq('R Interface to the DataONE REST API')
|
106
|
+
expect(jats['publisher_name']).to eq('https://cran.r-project.org')
|
107
|
+
expect(jats.dig('person_group', 'name').length).to eq(3)
|
108
|
+
expect(jats.dig('person_group',
|
109
|
+
'name').first).to eq('surname' => 'Jones', 'given_names' => 'Matt')
|
110
|
+
expect(jats['year']).to eq('iso_8601_date' => '2016-05-27', '__content__' => '2016')
|
111
|
+
expect(jats['month']).to eq('05')
|
112
|
+
expect(jats['day']).to eq('27')
|
113
|
+
expect(jats['version']).to eq('2.0.0')
|
114
|
+
expect(jats['pub_id']).to eq('pub_id_type' => 'doi', '__content__' => '10.5063/f1m61h5x')
|
106
115
|
end
|
107
116
|
|
108
|
-
it
|
109
|
-
input =
|
110
|
-
subject =
|
111
|
-
jats = Maremma.from_xml(subject.jats).fetch(
|
112
|
-
expect(jats
|
113
|
-
expect(jats
|
114
|
-
expect(jats
|
115
|
-
expect(jats.dig(
|
116
|
-
|
117
|
-
expect(jats
|
118
|
-
expect(jats
|
119
|
-
expect(jats
|
117
|
+
it 'maremma' do
|
118
|
+
input = 'https://github.com/datacite/maremma'
|
119
|
+
subject = described_class.new(input: input, from: 'codemeta')
|
120
|
+
jats = Maremma.from_xml(subject.jats).fetch('element_citation', {})
|
121
|
+
expect(jats['publication_type']).to eq('software')
|
122
|
+
expect(jats['source']).to eq('Maremma: a Ruby library for simplified network calls')
|
123
|
+
expect(jats['publisher_name']).to eq('DataCite')
|
124
|
+
expect(jats.dig('person_group',
|
125
|
+
'name')).to eq('surname' => 'Fenner', 'given_names' => 'Martin')
|
126
|
+
expect(jats['year']).to eq('iso_8601_date' => '2017-02-24', '__content__' => '2017')
|
127
|
+
expect(jats['month']).to eq('02')
|
128
|
+
expect(jats['day']).to eq('24')
|
129
|
+
expect(jats['pub_id']).to eq('pub_id_type' => 'doi', '__content__' => '10.5438/qeg0-3gm3')
|
120
130
|
end
|
121
131
|
|
122
|
-
it
|
123
|
-
input =
|
124
|
-
subject =
|
125
|
-
jats = Maremma.from_xml(subject.jats).fetch(
|
126
|
-
expect(jats
|
127
|
-
expect(jats
|
128
|
-
expect(jats
|
129
|
-
expect(jats.dig(
|
130
|
-
expect(jats.dig(
|
131
|
-
|
132
|
-
expect(jats
|
132
|
+
it 'Text pass-thru' do
|
133
|
+
input = 'https://doi.org/10.23640/07243.5153971'
|
134
|
+
subject = described_class.new(input: input, from: 'datacite')
|
135
|
+
jats = Maremma.from_xml(subject.jats).fetch('element_citation', {})
|
136
|
+
expect(jats['publication_type']).to eq('journal')
|
137
|
+
expect(jats['article_title']).to eq('Recommendation of: ORCID Works Metadata Working Group')
|
138
|
+
expect(jats['source']).to eq('Figshare')
|
139
|
+
expect(jats.dig('person_group', 'name').length).to eq(20)
|
140
|
+
expect(jats.dig('person_group',
|
141
|
+
'name').first).to eq('surname' => 'Paglione', 'given_names' => 'Laura')
|
142
|
+
expect(jats['year']).to eq('iso_8601_date' => '2017', '__content__' => '2017')
|
143
|
+
expect(jats['pub_id']).to eq('pub_id_type' => 'doi',
|
144
|
+
'__content__' => '10.23640/07243.5153971')
|
133
145
|
end
|
134
146
|
|
135
|
-
it
|
136
|
-
input =
|
137
|
-
subject =
|
138
|
-
jats = Maremma.from_xml(subject.jats).fetch(
|
139
|
-
expect(jats
|
140
|
-
expect(jats
|
141
|
-
expect(jats
|
142
|
-
expect(jats.dig(
|
143
|
-
expect(jats.dig(
|
144
|
-
|
145
|
-
expect(jats
|
147
|
+
it 'Dataset in schema 4.0' do
|
148
|
+
input = 'https://doi.org/10.5061/DRYAD.8515'
|
149
|
+
subject = described_class.new(input: input, from: 'datacite', regenerate: true)
|
150
|
+
jats = Maremma.from_xml(subject.jats).fetch('element_citation', {})
|
151
|
+
expect(jats['publication_type']).to eq('data')
|
152
|
+
expect(jats['data_title']).to eq('Data from: A new malaria agent in African hominids.')
|
153
|
+
expect(jats['source']).to eq('Dryad')
|
154
|
+
expect(jats.dig('person_group', 'name').length).to eq(8)
|
155
|
+
expect(jats.dig('person_group',
|
156
|
+
'name').first).to eq('surname' => 'Ollomo', 'given_names' => 'Benjamin')
|
157
|
+
expect(jats['year']).to eq('iso_8601_date' => '2011', '__content__' => '2011')
|
158
|
+
expect(jats['pub_id']).to eq('pub_id_type' => 'doi', '__content__' => '10.5061/dryad.8515')
|
146
159
|
end
|
147
160
|
|
148
|
-
it
|
149
|
-
input =
|
150
|
-
subject =
|
151
|
-
jats = Maremma.from_xml(subject.jats).fetch(
|
152
|
-
expect(jats
|
153
|
-
expect(jats
|
154
|
-
expect(jats
|
155
|
-
expect(jats
|
156
|
-
expect(jats.dig(
|
157
|
-
|
158
|
-
expect(jats
|
159
|
-
expect(jats
|
160
|
-
expect(jats
|
161
|
+
it 'from schema_org' do
|
162
|
+
input = 'https://blog.front-matter.io/posts/eating-your-own-dog-food/'
|
163
|
+
subject = described_class.new(input: input, from: 'schema_org')
|
164
|
+
jats = Maremma.from_xml(subject.jats).fetch('element_citation', {})
|
165
|
+
expect(jats['publication_type']).to eq('journal')
|
166
|
+
expect(jats['article_title']).to eq('Eating your own Dog Food')
|
167
|
+
expect(jats['source']).to eq('Front Matter')
|
168
|
+
expect(jats['publisher_name']).to eq('Front Matter')
|
169
|
+
expect(jats.dig('person_group',
|
170
|
+
'name')).to eq('surname' => 'Fenner', 'given_names' => 'Martin')
|
171
|
+
expect(jats['year']).to eq('iso_8601_date' => '2016-12-20T00:00:00Z', '__content__' => '2016')
|
172
|
+
expect(jats['month']).to eq('12')
|
173
|
+
expect(jats['day']).to eq('20')
|
174
|
+
expect(jats['pub_id']).to eq('pub_id_type' => 'doi',
|
175
|
+
'__content__' => '10.53731/r79vxn1-97aq74v-ag58n')
|
161
176
|
end
|
162
177
|
|
163
|
-
it
|
164
|
-
input =
|
165
|
-
subject =
|
166
|
-
jats = Maremma.from_xml(subject.jats).fetch(
|
167
|
-
expect(jats.
|
168
|
-
expect(jats
|
169
|
-
expect(jats
|
170
|
-
expect(jats.dig(
|
171
|
-
expect(jats
|
172
|
-
expect(jats.
|
173
|
-
expect(jats.
|
174
|
-
expect(jats
|
178
|
+
it 'interactive resource without dates' do
|
179
|
+
input = 'https://doi.org/10.34747/g6yb-3412'
|
180
|
+
subject = described_class.new(input: input, from: 'datacite')
|
181
|
+
jats = Maremma.from_xml(subject.jats).fetch('element_citation', {})
|
182
|
+
expect(jats['publication_type'].nil?).to be(true)
|
183
|
+
expect(jats['source']).to eq('Exploring the "Many analysts, one dataset" project from COS')
|
184
|
+
expect(jats['publisher_name']).to eq('Gigantum, Inc.')
|
185
|
+
expect(jats.dig('person_group', 'name')).to eq('given_names' => 'Dav', 'surname' => 'Clark')
|
186
|
+
expect(jats['year']).to eq('__content__' => '2019', 'iso_8601_date' => '2019')
|
187
|
+
expect(jats['month'].nil?).to be(true)
|
188
|
+
expect(jats['day'].nil?).to be(true)
|
189
|
+
expect(jats['pub_id']).to eq('pub_id_type' => 'doi', '__content__' => '10.34747/g6yb-3412')
|
175
190
|
end
|
176
191
|
end
|
177
192
|
|
178
|
-
context
|
179
|
-
it
|
180
|
-
input =
|
181
|
-
subject =
|
182
|
-
jats = Maremma.from_xml(subject.jats).fetch(
|
183
|
-
expect(jats
|
184
|
-
expect(jats
|
185
|
-
expect(jats
|
186
|
-
expect(jats.dig(
|
187
|
-
expect(jats.dig(
|
188
|
-
|
189
|
-
expect(jats
|
190
|
-
expect(jats
|
191
|
-
expect(jats
|
193
|
+
context 'change metadata as datacite xml' do
|
194
|
+
it 'with data citation' do
|
195
|
+
input = '10.7554/eLife.01567'
|
196
|
+
subject = described_class.new(input: input, from: 'crossref')
|
197
|
+
jats = Maremma.from_xml(subject.jats).fetch('element_citation', {})
|
198
|
+
expect(jats['publication_type']).to eq('journal')
|
199
|
+
expect(jats['article_title']).to eq('Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth')
|
200
|
+
expect(jats['source']).to eq('eLife')
|
201
|
+
expect(jats.dig('person_group', 'name').length).to eq(5)
|
202
|
+
expect(jats.dig('person_group',
|
203
|
+
'name').first).to eq('surname' => 'Sankar', 'given_names' => 'Martial')
|
204
|
+
expect(jats['year']).to eq('iso_8601_date' => '2014-02-11', '__content__' => '2014')
|
205
|
+
expect(jats['month']).to eq('02')
|
206
|
+
expect(jats['day']).to eq('11')
|
207
|
+
expect(jats['pub_id']).to eq('pub_id_type' => 'doi', '__content__' => '10.7554/elife.01567')
|
192
208
|
end
|
193
209
|
end
|
194
210
|
end
|
@@ -3,84 +3,89 @@
|
|
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 rdf xml' do
|
7
|
+
it 'journal article' 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
|
-
rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch(
|
12
|
-
expect(rdf_xml.dig(
|
13
|
-
expect(rdf_xml.dig(
|
14
|
-
|
11
|
+
rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch('RDF', {})
|
12
|
+
expect(rdf_xml.dig('ScholarlyArticle', 'rdf:about')).to eq('https://doi.org/10.7554/elife.01567')
|
13
|
+
expect(rdf_xml.dig('ScholarlyArticle',
|
14
|
+
'name')).to eq('Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth')
|
15
|
+
expect(rdf_xml.dig('ScholarlyArticle', 'datePublished', '__content__')).to eq('2014-02-11')
|
15
16
|
end
|
16
|
-
|
17
|
-
it
|
18
|
-
input =
|
19
|
-
subject =
|
17
|
+
|
18
|
+
it 'with pages' do
|
19
|
+
input = 'https://doi.org/10.1155/2012/291294'
|
20
|
+
subject = described_class.new(input: input, from: 'crossref')
|
20
21
|
expect(subject.valid?).to be true
|
21
|
-
rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch(
|
22
|
-
expect(rdf_xml.dig(
|
23
|
-
expect(rdf_xml.dig(
|
24
|
-
|
25
|
-
expect(rdf_xml.dig(
|
26
|
-
expect(rdf_xml.dig(
|
22
|
+
rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch('RDF', {})
|
23
|
+
expect(rdf_xml.dig('ScholarlyArticle', 'rdf:about')).to eq('https://doi.org/10.1155/2012/291294')
|
24
|
+
expect(rdf_xml.dig('ScholarlyArticle',
|
25
|
+
'name')).to eq('Delineating a Retesting Zone Using Receiver Operating Characteristic Analysis on Serial QuantiFERON Tuberculosis Test Results in US Healthcare Workers')
|
26
|
+
expect(rdf_xml.dig('ScholarlyArticle', 'datePublished', '__content__')).to eq('2012')
|
27
|
+
expect(rdf_xml.dig('ScholarlyArticle', 'pageStart')).to eq('1')
|
28
|
+
expect(rdf_xml.dig('ScholarlyArticle', 'pageEnd')).to eq('7')
|
27
29
|
end
|
28
30
|
|
29
|
-
it
|
30
|
-
input = fixture_path
|
31
|
-
subject =
|
31
|
+
it 'Crossref DOI' do
|
32
|
+
input = "#{fixture_path}crossref.bib"
|
33
|
+
subject = described_class.new(input: input, from: 'bibtex')
|
32
34
|
expect(subject.valid?).to be true
|
33
|
-
rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch(
|
35
|
+
rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch('RDF', {})
|
34
36
|
|
35
|
-
expect(rdf_xml.dig(
|
36
|
-
expect(rdf_xml.dig(
|
37
|
-
|
38
|
-
expect(rdf_xml.dig(
|
37
|
+
expect(rdf_xml.dig('ScholarlyArticle', 'rdf:about')).to eq('https://doi.org/10.7554/elife.01567')
|
38
|
+
expect(rdf_xml.dig('ScholarlyArticle',
|
39
|
+
'name')).to eq('Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth')
|
40
|
+
expect(rdf_xml.dig('ScholarlyArticle', 'datePublished', '__content__')).to eq('2014')
|
41
|
+
expect(rdf_xml.dig('ScholarlyArticle', 'periodical', 'Journal', 'name')).to eq('eLife')
|
39
42
|
end
|
40
43
|
|
41
|
-
it
|
42
|
-
input =
|
43
|
-
subject =
|
44
|
+
it 'BlogPosting' do
|
45
|
+
input = 'https://doi.org/10.5438/4K3M-NYVG'
|
46
|
+
subject = described_class.new(input: input, from: 'datacite')
|
44
47
|
expect(subject.valid?).to be true
|
45
|
-
rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch(
|
46
|
-
expect(rdf_xml.dig(
|
47
|
-
expect(rdf_xml.dig(
|
48
|
-
expect(rdf_xml.dig(
|
49
|
-
|
48
|
+
rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch('RDF', {})
|
49
|
+
expect(rdf_xml.dig('ScholarlyArticle', 'rdf:about')).to eq('https://doi.org/10.5438/4k3m-nyvg')
|
50
|
+
expect(rdf_xml.dig('ScholarlyArticle', 'name')).to eq('Eating your own Dog Food')
|
51
|
+
expect(rdf_xml.dig('ScholarlyArticle',
|
52
|
+
'keywords')).to eq('datacite, doi, metadata, FOS: Computer and information sciences')
|
53
|
+
expect(rdf_xml.dig('ScholarlyArticle', 'datePublished', '__content__')).to eq('2016-12-20')
|
50
54
|
end
|
51
|
-
|
52
|
-
it
|
53
|
-
input = fixture_path
|
54
|
-
subject =
|
55
|
-
rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch(
|
56
|
-
expect(rdf_xml.dig(
|
57
|
-
expect(rdf_xml.dig(
|
58
|
-
expect(rdf_xml.dig(
|
55
|
+
|
56
|
+
it 'BlogPosting Citeproc JSON' do
|
57
|
+
input = "#{fixture_path}citeproc.json"
|
58
|
+
subject = described_class.new(input: input, from: 'citeproc')
|
59
|
+
rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch('RDF', {})
|
60
|
+
expect(rdf_xml.dig('BlogPosting', 'rdf:about')).to eq('https://doi.org/10.5438/4k3m-nyvg')
|
61
|
+
expect(rdf_xml.dig('BlogPosting', 'name')).to eq('Eating your own Dog Food')
|
62
|
+
expect(rdf_xml.dig('BlogPosting', 'datePublished', '__content__')).to eq('2016-12-20')
|
59
63
|
end
|
60
|
-
|
61
|
-
it
|
62
|
-
input =
|
63
|
-
subject =
|
64
|
-
rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch(
|
65
|
-
expect(rdf_xml.dig(
|
66
|
-
expect(rdf_xml.dig(
|
67
|
-
expect(rdf_xml.dig(
|
68
|
-
expect(rdf_xml.dig(
|
69
|
-
|
70
|
-
expect(rdf_xml.dig(
|
64
|
+
|
65
|
+
it 'maremma' do
|
66
|
+
input = 'https://github.com/datacite/maremma'
|
67
|
+
subject = described_class.new(input: input, from: 'codemeta')
|
68
|
+
rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch('RDF', {})
|
69
|
+
expect(rdf_xml.dig('SoftwareSourceCode', 'rdf:about')).to eq('https://doi.org/10.5438/qeg0-3gm3')
|
70
|
+
expect(rdf_xml.dig('SoftwareSourceCode', 'author', 'Person', 'rdf:about')).to eq('https://orcid.org/0000-0003-0077-4738')
|
71
|
+
expect(rdf_xml.dig('SoftwareSourceCode', 'author', 'Person', 'name')).to eq('Martin Fenner')
|
72
|
+
expect(rdf_xml.dig('SoftwareSourceCode',
|
73
|
+
'name')).to eq('Maremma: a Ruby library for simplified network calls')
|
74
|
+
expect(rdf_xml.dig('SoftwareSourceCode', 'keywords')).to eq('faraday, excon, net/http')
|
75
|
+
expect(rdf_xml.dig('SoftwareSourceCode', 'datePublished', '__content__')).to eq('2017-02-24')
|
71
76
|
end
|
72
77
|
|
73
|
-
it
|
74
|
-
input =
|
75
|
-
subject =
|
78
|
+
it 'BlogPosting schema.org' do
|
79
|
+
input = 'https://blog.front-matter.io/posts/eating-your-own-dog-food/'
|
80
|
+
subject = described_class.new(input: input, from: 'schema_org')
|
76
81
|
expect(subject.valid?).to be true
|
77
|
-
rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch(
|
78
|
-
expect(rdf_xml.dig(
|
79
|
-
expect(rdf_xml.dig(
|
80
|
-
expect(rdf_xml.dig(
|
81
|
-
expect(rdf_xml.dig(
|
82
|
-
expect(rdf_xml.dig(
|
83
|
-
expect(rdf_xml.dig(
|
82
|
+
rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch('RDF', {})
|
83
|
+
expect(rdf_xml.dig('Article', 'rdf:about')).to eq('https://doi.org/10.53731/r79vxn1-97aq74v-ag58n')
|
84
|
+
expect(rdf_xml.dig('Article', 'author', 'Person', 'rdf:about')).to eq('https://orcid.org/0000-0003-1419-2405')
|
85
|
+
expect(rdf_xml.dig('Article', 'author', 'Person', 'name')).to eq('Martin Fenner')
|
86
|
+
expect(rdf_xml.dig('Article', 'name')).to eq('Eating your own Dog Food')
|
87
|
+
expect(rdf_xml.dig('Article', 'keywords')).to eq('feature')
|
88
|
+
expect(rdf_xml.dig('Article', 'datePublished', '__content__')).to eq('2016-12-20T00:00:00Z')
|
84
89
|
end
|
85
90
|
end
|
86
91
|
end
|