briard 2.4.2 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codeql-analysis.yml +72 -0
  3. data/.github/workflows/rubocop.yml +50 -0
  4. data/.rubocop.yml +144 -620
  5. data/.rubocop_todo.yml +76 -0
  6. data/CHANGELOG.md +18 -0
  7. data/Gemfile +2 -0
  8. data/Gemfile.lock +40 -6
  9. data/Rakefile +1 -1
  10. data/{bolognese.gemspec → briard.gemspec} +46 -39
  11. data/lib/briard/array.rb +2 -2
  12. data/lib/briard/author_utils.rb +79 -71
  13. data/lib/briard/cli.rb +12 -13
  14. data/lib/briard/crossref_utils.rb +73 -61
  15. data/lib/briard/datacite_utils.rb +132 -106
  16. data/lib/briard/doi_utils.rb +10 -10
  17. data/lib/briard/metadata.rb +96 -106
  18. data/lib/briard/metadata_utils.rb +87 -78
  19. data/lib/briard/readers/bibtex_reader.rb +65 -65
  20. data/lib/briard/readers/cff_reader.rb +88 -70
  21. data/lib/briard/readers/citeproc_reader.rb +90 -84
  22. data/lib/briard/readers/codemeta_reader.rb +68 -50
  23. data/lib/briard/readers/crosscite_reader.rb +2 -2
  24. data/lib/briard/readers/crossref_reader.rb +249 -210
  25. data/lib/briard/readers/datacite_json_reader.rb +3 -3
  26. data/lib/briard/readers/datacite_reader.rb +225 -189
  27. data/lib/briard/readers/npm_reader.rb +49 -42
  28. data/lib/briard/readers/ris_reader.rb +82 -80
  29. data/lib/briard/readers/schema_org_reader.rb +182 -159
  30. data/lib/briard/string.rb +1 -1
  31. data/lib/briard/utils.rb +4 -4
  32. data/lib/briard/version.rb +3 -1
  33. data/lib/briard/whitelist_scrubber.rb +11 -4
  34. data/lib/briard/writers/bibtex_writer.rb +14 -8
  35. data/lib/briard/writers/cff_writer.rb +33 -26
  36. data/lib/briard/writers/codemeta_writer.rb +19 -15
  37. data/lib/briard/writers/csv_writer.rb +6 -4
  38. data/lib/briard/writers/datacite_json_writer.rb +8 -2
  39. data/lib/briard/writers/jats_writer.rb +33 -28
  40. data/lib/briard/writers/rdf_xml_writer.rb +1 -1
  41. data/lib/briard/writers/ris_writer.rb +30 -18
  42. data/lib/briard/writers/turtle_writer.rb +1 -1
  43. data/lib/briard.rb +6 -6
  44. data/rubocop.sarif +0 -0
  45. data/spec/array_spec.rb +5 -5
  46. data/spec/author_utils_spec.rb +151 -132
  47. data/spec/datacite_utils_spec.rb +135 -83
  48. data/spec/doi_utils_spec.rb +168 -164
  49. data/spec/find_from_format_spec.rb +69 -69
  50. data/spec/fixtures/vcr_cassettes/Briard_Metadata/sanitize/onlies_keep_specific_tags.yml +65 -0
  51. data/spec/fixtures/vcr_cassettes/Briard_Metadata/sanitize/removes_a_tags.yml +65 -0
  52. data/spec/metadata_spec.rb +91 -90
  53. data/spec/readers/bibtex_reader_spec.rb +43 -38
  54. data/spec/readers/cff_reader_spec.rb +165 -153
  55. data/spec/readers/citeproc_reader_spec.rb +45 -40
  56. data/spec/readers/codemeta_reader_spec.rb +128 -115
  57. data/spec/readers/crosscite_reader_spec.rb +34 -24
  58. data/spec/readers/crossref_reader_spec.rb +1098 -939
  59. data/spec/readers/datacite_json_reader_spec.rb +53 -40
  60. data/spec/readers/datacite_reader_spec.rb +1541 -1337
  61. data/spec/readers/npm_reader_spec.rb +48 -43
  62. data/spec/readers/ris_reader_spec.rb +53 -47
  63. data/spec/readers/schema_org_reader_spec.rb +329 -267
  64. data/spec/spec_helper.rb +6 -5
  65. data/spec/utils_spec.rb +371 -347
  66. data/spec/writers/bibtex_writer_spec.rb +143 -143
  67. data/spec/writers/cff_writer_spec.rb +96 -90
  68. data/spec/writers/citation_writer_spec.rb +34 -33
  69. data/spec/writers/citeproc_writer_spec.rb +226 -224
  70. data/spec/writers/codemeta_writer_spec.rb +18 -16
  71. data/spec/writers/crosscite_writer_spec.rb +91 -73
  72. data/spec/writers/crossref_writer_spec.rb +99 -91
  73. data/spec/writers/csv_writer_spec.rb +70 -70
  74. data/spec/writers/datacite_json_writer_spec.rb +78 -68
  75. data/spec/writers/datacite_writer_spec.rb +417 -322
  76. data/spec/writers/jats_writer_spec.rb +177 -161
  77. data/spec/writers/rdf_xml_writer_spec.rb +68 -63
  78. data/spec/writers/ris_writer_spec.rb +162 -162
  79. data/spec/writers/turtle_writer_spec.rb +47 -47
  80. metadata +242 -166
  81. 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 "write metadata as jats xml" do
7
- it "with data citation" do
8
- input = "10.7554/eLife.01567"
9
- subject = Briard::Metadata.new(input: input, from: "crossref")
10
- jats = Maremma.from_xml(subject.jats).fetch("element_citation", {})
11
- expect(jats.dig("publication_type")).to eq("journal")
12
- expect(jats.dig("article_title")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
13
- expect(jats.dig("source")).to eq("eLife")
14
- expect(jats.dig("person_group", "name").length).to eq(5)
15
- expect(jats.dig("person_group", "name").first).to eq("surname"=>"Sankar", "given_names"=>"Martial")
16
- expect(jats.dig("year")).to eq("iso_8601_date"=>"2014-02-11", "__content__"=>"2014")
17
- expect(jats.dig("month")).to eq("02")
18
- expect(jats.dig("day")).to eq("11")
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 "with ORCID ID" do
22
- input = "https://doi.org/10.1155/2012/291294"
23
- subject = Briard::Metadata.new(input: input, from: "crossref")
24
- jats = Maremma.from_xml(subject.jats).fetch("element_citation", {})
25
- expect(jats.dig("publication_type")).to eq("journal")
26
- expect(jats.dig("article_title")).to eq("Delineating a Retesting Zone Using Receiver Operating Characteristic Analysis on Serial QuantiFERON Tuberculosis Test Results in US Healthcare Workers")
27
- expect(jats.dig("source")).to eq("Pulmonary Medicine")
28
- expect(jats.dig("person_group", "name").length).to eq(7)
29
- expect(jats.dig("person_group", "name").first).to eq("surname"=>"Thanassi", "given_names"=>"Wendy")
30
- expect(jats.dig("year")).to eq("iso_8601_date"=>"2012", "__content__"=>"2012")
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 "with editor" do
34
- input = "https://doi.org/10.1371/journal.pone.0000030"
35
- subject = Briard::Metadata.new(input: input, from: "crossref")
36
- jats = Maremma.from_xml(subject.jats).fetch("element_citation", {})
37
- expect(jats.dig("publication_type")).to eq("journal")
38
- expect(jats.dig("article_title")).to eq("Triose Phosphate Isomerase Deficiency Is Caused by Altered Dimerization???Not Catalytic Inactivity???of the Mutant Enzymes")
39
- expect(jats.dig("source")).to eq("PLoS ONE")
40
- expect(jats.dig("person_group", 0, "name").length).to eq(5)
41
- expect(jats.dig("person_group", 0, "name").first).to eq("surname"=>"Ralser", "given_names"=>"Markus")
42
- expect(jats.dig("person_group", 1, "name")).to eq("surname"=>"Janbon", "given_names"=>"Guilhem")
43
- expect(jats.dig("year")).to eq("iso_8601_date"=>"2006-12-20", "__content__"=>"2006")
44
- expect(jats.dig("month")).to eq("12")
45
- expect(jats.dig("day")).to eq("20")
46
- expect(jats.dig("fpage")).to eq("e30")
47
- expect(jats.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.1371/journal.pone.0000030")
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 "book chapter" do
51
- input = "https://doi.org/10.5005/jp/books/12414_3"
52
- subject = Briard::Metadata.new(input: input, from: "crossref")
53
- jats = Maremma.from_xml(subject.jats).fetch("element_citation", {})
54
- expect(jats.dig("publication_type")).to eq("chapter")
55
- expect(jats.dig("chapter_title")).to eq("Physical Examinations")
56
- expect(jats.dig("source")).to eq("Jaypee Brothers Medical Publishing")
57
- expect(jats.dig("person_group", "name")).to eq("surname"=>"Saha", "given_names"=>"Ashis")
58
- expect(jats.dig("year")).to eq("iso_8601_date"=>"2015", "__content__"=>"2015")
59
- expect(jats.dig("fpage")).to eq("27")
60
- expect(jats.dig("lpage")).to eq("27")
61
- expect(jats.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.5005/jp/books/12414_3")
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 "Crossref DOI" do
65
- input = fixture_path + "crossref.bib"
66
- subject = Briard::Metadata.new(input: input, from: "bibtex")
67
- jats = Maremma.from_xml(subject.jats).fetch("element_citation", {})
68
- expect(jats.dig("publication_type")).to eq("journal")
69
- expect(jats.dig("article_title")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
70
- expect(jats.dig("source")).to eq("eLife")
71
- expect(jats.dig("person_group", "name").length).to eq(5)
72
- expect(jats.dig("person_group", "name").first).to eq("surname"=>"Sankar", "given_names"=>"Martial")
73
- expect(jats.dig("year")).to eq("iso_8601_date"=>"2014", "__content__"=>"2014")
74
- expect(jats.dig("month")).to be_nil
75
- expect(jats.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.7554/elife.01567")
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 "BlogPosting Citeproc JSON" do
79
- input = fixture_path + "citeproc.json"
80
- subject = Briard::Metadata.new(input: input, from: "citeproc")
81
- jats = Maremma.from_xml(subject.jats).fetch("element_citation", {})
82
- expect(jats.dig("publication_type")).to be_nil
83
- expect(jats.dig("source")).to eq("Eating your own Dog Food")
84
- expect(jats.dig("publisher_name")).to eq("DataCite")
85
- expect(jats.dig("person_group", "name")).to eq("surname"=>"Fenner", "given_names"=>"Martin")
86
- expect(jats.dig("year")).to eq("iso_8601_date"=>"2016-12-20", "__content__"=>"2016")
87
- expect(jats.dig("month")).to eq("12")
88
- expect(jats.dig("day")).to eq("20")
89
- expect(jats.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.5438/4k3m-nyvg")
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 "rdataone" do
93
- input = fixture_path + 'codemeta.json'
94
- subject = Briard::Metadata.new(input: input, from: "codemeta")
95
- jats = Maremma.from_xml(subject.jats).fetch("element_citation", {})
96
- expect(jats.dig("publication_type")).to eq("software")
97
- expect(jats.dig("source")).to eq("R Interface to the DataONE REST API")
98
- expect(jats.dig("publisher_name")).to eq("https://cran.r-project.org")
99
- expect(jats.dig("person_group", "name").length).to eq(3)
100
- expect(jats.dig("person_group", "name").first).to eq("surname"=>"Jones", "given_names"=>"Matt")
101
- expect(jats.dig("year")).to eq("iso_8601_date"=>"2016-05-27", "__content__"=>"2016")
102
- expect(jats.dig("month")).to eq("05")
103
- expect(jats.dig("day")).to eq("27")
104
- expect(jats.dig("version")).to eq("2.0.0")
105
- expect(jats.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.5063/f1m61h5x")
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 "maremma" do
109
- input = "https://github.com/datacite/maremma"
110
- subject = Briard::Metadata.new(input: input, from: "codemeta")
111
- jats = Maremma.from_xml(subject.jats).fetch("element_citation", {})
112
- expect(jats.dig("publication_type")).to eq("software")
113
- expect(jats.dig("source")).to eq("Maremma: a Ruby library for simplified network calls")
114
- expect(jats.dig("publisher_name")).to eq("DataCite")
115
- expect(jats.dig("person_group", "name")).to eq("surname"=>"Fenner", "given_names"=>"Martin")
116
- expect(jats.dig("year")).to eq("iso_8601_date"=>"2017-02-24", "__content__"=>"2017")
117
- expect(jats.dig("month")).to eq("02")
118
- expect(jats.dig("day")).to eq("24")
119
- expect(jats.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.5438/qeg0-3gm3")
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 "Text pass-thru" do
123
- input = "https://doi.org/10.23640/07243.5153971"
124
- subject = Briard::Metadata.new(input: input, from: "datacite")
125
- jats = Maremma.from_xml(subject.jats).fetch("element_citation", {})
126
- expect(jats.dig("publication_type")).to eq("journal")
127
- expect(jats.dig("article_title")).to eq("Recommendation of: ORCID Works Metadata Working Group")
128
- expect(jats.dig("source")).to eq("Figshare")
129
- expect(jats.dig("person_group", "name").length).to eq(20)
130
- expect(jats.dig("person_group", "name").first).to eq("surname"=>"Paglione", "given_names"=>"Laura")
131
- expect(jats.dig("year")).to eq("iso_8601_date"=>"2017", "__content__"=>"2017")
132
- expect(jats.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.23640/07243.5153971")
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 "Dataset in schema 4.0" do
136
- input = "https://doi.org/10.5061/DRYAD.8515"
137
- subject = Briard::Metadata.new(input: input, from: "datacite", regenerate: true)
138
- jats = Maremma.from_xml(subject.jats).fetch("element_citation", {})
139
- expect(jats.dig("publication_type")).to eq("data")
140
- expect(jats.dig("data_title")).to eq("Data from: A new malaria agent in African hominids.")
141
- expect(jats.dig("source")).to eq("Dryad")
142
- expect(jats.dig("person_group", "name").length).to eq(8)
143
- expect(jats.dig("person_group", "name").first).to eq("surname"=>"Ollomo", "given_names"=>"Benjamin")
144
- expect(jats.dig("year")).to eq("iso_8601_date"=>"2011", "__content__"=>"2011")
145
- expect(jats.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.5061/dryad.8515")
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 "from schema_org" do
149
- input = "https://blog.front-matter.io/posts/eating-your-own-dog-food/"
150
- subject = Briard::Metadata.new(input: input, from: "schema_org")
151
- jats = Maremma.from_xml(subject.jats).fetch("element_citation", {})
152
- expect(jats.dig("publication_type")).to eq("journal")
153
- expect(jats.dig("article_title")).to eq("Eating your own Dog Food")
154
- expect(jats.dig("source")).to eq("Front Matter")
155
- expect(jats.dig("publisher_name")).to eq("Front Matter")
156
- expect(jats.dig("person_group", "name")).to eq("surname"=>"Fenner", "given_names"=>"Martin")
157
- expect(jats.dig("year")).to eq("iso_8601_date"=>"2016-12-20T00:00:00Z", "__content__"=>"2016")
158
- expect(jats.dig("month")).to eq("12")
159
- expect(jats.dig("day")).to eq("20")
160
- expect(jats.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.53731/r79vxn1-97aq74v-ag58n")
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 "interactive resource without dates" do
164
- input = "https://doi.org/10.34747/g6yb-3412"
165
- subject = Briard::Metadata.new(input: input, from: "datacite")
166
- jats = Maremma.from_xml(subject.jats).fetch("element_citation", {})
167
- expect(jats.dig("publication_type")).to be_nil
168
- expect(jats.dig("source")).to eq("Exploring the \"Many analysts, one dataset\" project from COS")
169
- expect(jats.dig("publisher_name")).to eq("Gigantum, Inc.")
170
- expect(jats.dig("person_group", "name")).to eq("given_names"=>"Dav", "surname"=>"Clark")
171
- expect(jats.dig("year")).to eq("__content__"=>"2019", "iso_8601_date"=>"2019")
172
- expect(jats.dig("month")).to be_nil
173
- expect(jats.dig("day")).to be_nil
174
- expect(jats.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.34747/g6yb-3412")
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 "change metadata as datacite xml" do
179
- it "with data citation" do
180
- input = "10.7554/eLife.01567"
181
- subject = Briard::Metadata.new(input: input, from: "crossref")
182
- jats = Maremma.from_xml(subject.jats).fetch("element_citation", {})
183
- expect(jats.dig("publication_type")).to eq("journal")
184
- expect(jats.dig("article_title")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
185
- expect(jats.dig("source")).to eq("eLife")
186
- expect(jats.dig("person_group", "name").length).to eq(5)
187
- expect(jats.dig("person_group", "name").first).to eq("surname"=>"Sankar", "given_names"=>"Martial")
188
- expect(jats.dig("year")).to eq("iso_8601_date"=>"2014-02-11", "__content__"=>"2014")
189
- expect(jats.dig("month")).to eq("02")
190
- expect(jats.dig("day")).to eq("11")
191
- expect(jats.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.7554/elife.01567")
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 "write metadata as rdf xml" do
7
- it "journal article" do
8
- input = "10.7554/eLife.01567"
9
- subject = Briard::Metadata.new(input: input, from: "crossref")
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("RDF", {})
12
- expect(rdf_xml.dig("ScholarlyArticle", "rdf:about")).to eq("https://doi.org/10.7554/elife.01567")
13
- expect(rdf_xml.dig("ScholarlyArticle", "name")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
14
- expect(rdf_xml.dig("ScholarlyArticle", "datePublished", "__content__")).to eq("2014-02-11")
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 "with pages" do
18
- input = "https://doi.org/10.1155/2012/291294"
19
- subject = Briard::Metadata.new(input: input, from: "crossref")
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("RDF", {})
22
- expect(rdf_xml.dig("ScholarlyArticle", "rdf:about")).to eq("https://doi.org/10.1155/2012/291294")
23
- expect(rdf_xml.dig("ScholarlyArticle", "name")).to eq("Delineating a Retesting Zone Using Receiver Operating Characteristic Analysis on Serial QuantiFERON Tuberculosis Test Results in US Healthcare Workers")
24
- expect(rdf_xml.dig("ScholarlyArticle", "datePublished", "__content__")).to eq("2012")
25
- expect(rdf_xml.dig("ScholarlyArticle", "pageStart")).to eq("1")
26
- expect(rdf_xml.dig("ScholarlyArticle", "pageEnd")).to eq("7")
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 "Crossref DOI" do
30
- input = fixture_path + "crossref.bib"
31
- subject = Briard::Metadata.new(input: input, from: "bibtex")
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("RDF", {})
35
+ rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch('RDF', {})
34
36
 
35
- expect(rdf_xml.dig("ScholarlyArticle", "rdf:about")).to eq("https://doi.org/10.7554/elife.01567")
36
- expect(rdf_xml.dig("ScholarlyArticle", "name")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
37
- expect(rdf_xml.dig("ScholarlyArticle", "datePublished", "__content__")).to eq("2014")
38
- expect(rdf_xml.dig("ScholarlyArticle", "periodical", "Journal", "name")).to eq("eLife")
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 "BlogPosting" do
42
- input = "https://doi.org/10.5438/4K3M-NYVG"
43
- subject = Briard::Metadata.new(input: input, from: "datacite")
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("RDF", {})
46
- expect(rdf_xml.dig("ScholarlyArticle", "rdf:about")).to eq("https://doi.org/10.5438/4k3m-nyvg")
47
- expect(rdf_xml.dig("ScholarlyArticle", "name")).to eq("Eating your own Dog Food")
48
- expect(rdf_xml.dig("ScholarlyArticle", "keywords")).to eq("datacite, doi, metadata, FOS: Computer and information sciences")
49
- expect(rdf_xml.dig("ScholarlyArticle", "datePublished", "__content__")).to eq("2016-12-20")
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 "BlogPosting Citeproc JSON" do
53
- input = fixture_path + "citeproc.json"
54
- subject = Briard::Metadata.new(input: input, from: "citeproc")
55
- rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch("RDF", {})
56
- expect(rdf_xml.dig("BlogPosting", "rdf:about")).to eq("https://doi.org/10.5438/4k3m-nyvg")
57
- expect(rdf_xml.dig("BlogPosting", "name")).to eq("Eating your own Dog Food")
58
- expect(rdf_xml.dig("BlogPosting", "datePublished", "__content__")).to eq("2016-12-20")
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 "maremma" do
62
- input = "https://github.com/datacite/maremma"
63
- subject = Briard::Metadata.new(input: input, from: "codemeta")
64
- rdf_xml = Maremma.from_xml(subject.rdf_xml).fetch("RDF", {})
65
- expect(rdf_xml.dig("SoftwareSourceCode", "rdf:about")).to eq("https://doi.org/10.5438/qeg0-3gm3")
66
- expect(rdf_xml.dig("SoftwareSourceCode", "author", "Person", "rdf:about")).to eq("https://orcid.org/0000-0003-0077-4738")
67
- expect(rdf_xml.dig("SoftwareSourceCode", "author", "Person", "name")).to eq("Martin Fenner")
68
- expect(rdf_xml.dig("SoftwareSourceCode", "name")).to eq("Maremma: a Ruby library for simplified network calls")
69
- expect(rdf_xml.dig("SoftwareSourceCode", "keywords")).to eq("faraday, excon, net/http")
70
- expect(rdf_xml.dig("SoftwareSourceCode", "datePublished", "__content__")).to eq("2017-02-24")
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 "BlogPosting schema.org" do
74
- input = "https://blog.front-matter.io/posts/eating-your-own-dog-food/"
75
- subject = Briard::Metadata.new(input: input, from: "schema_org")
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("RDF", {})
78
- expect(rdf_xml.dig("Article", "rdf:about")).to eq("https://doi.org/10.53731/r79vxn1-97aq74v-ag58n")
79
- expect(rdf_xml.dig("Article", "author", "Person", "rdf:about")).to eq("https://orcid.org/0000-0003-1419-2405")
80
- expect(rdf_xml.dig("Article", "author", "Person", "name")).to eq("Martin Fenner")
81
- expect(rdf_xml.dig("Article", "name")).to eq("Eating your own Dog Food")
82
- expect(rdf_xml.dig("Article", "keywords")).to eq("feature")
83
- expect(rdf_xml.dig("Article", "datePublished", "__content__")).to eq("2016-12-20T00:00:00Z")
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