briard 2.4.1 → 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 +22 -0
  7. data/Gemfile +2 -0
  8. data/Gemfile.lock +43 -6
  9. data/Rakefile +1 -1
  10. data/{bolognese.gemspec → briard.gemspec} +46 -38
  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 +250 -160
  81. 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 "write metadata as datacite xml" do
7
- it "with data citation" do
8
- input = "10.7554/eLife.01567"
9
- subject = Briard::Metadata.new(input: input, from: "crossref")
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("resource", {})
12
- expect(datacite.dig("resourceType", "resourceTypeGeneral")).to eq("JournalArticle")
13
- expect(datacite.dig("titles", "title")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
14
- expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").length).to eq(28)
15
- expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").first).to eq("relatedIdentifierType"=>"ISSN", "relationType"=>"IsPartOf", "__content__"=>"2050-084X", "resourceTypeGeneral"=>"Collection")
16
- expect(datacite.dig("relatedIdentifiers", "relatedIdentifier")[1]).to eq("relatedIdentifierType"=>"DOI", "relationType"=>"References", "__content__"=>"10.1038/nature02100")
17
- expect(datacite.dig("rightsList", "rights")).to eq("rightsURI"=>"https://creativecommons.org/licenses/by/3.0/legalcode", "rightsIdentifier"=>"cc-by-3.0", "rightsIdentifierScheme"=>"SPDX", "schemeURI"=>"https://spdx.org/licenses/", "__content__"=>"Creative Commons Attribution 3.0 Unported")
18
- expect(datacite.dig("fundingReferences", "fundingReference").count).to eq(4)
19
- expect(datacite.dig("fundingReferences", "fundingReference").last).to eq("funderName"=>"University of Lausanne", "funderIdentifier" => {"funderIdentifierType"=>"Crossref Funder ID", "__content__"=>"https://doi.org/10.13039/501100006390"})
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 "with ORCID ID" do
23
- input = "https://doi.org/10.1155/2012/291294"
24
- subject = Briard::Metadata.new(input: input, from: "crossref")
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("resource", {})
27
- expect(datacite.dig("resourceType", "resourceTypeGeneral")).to eq("JournalArticle")
28
- expect(datacite.dig("creators", "creator").count).to eq(7)
29
- expect(datacite.dig("creators", "creator")[2]).to eq("creatorName" => {"__content__"=>"Hernandez, Beatriz", "nameType"=>"Personal"},
30
- "familyName" => "Hernandez",
31
- "givenName" => "Beatriz",
32
- "affiliation" => ["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"],
33
- "nameIdentifier" => {"nameIdentifierScheme"=>"ORCID", "schemeURI"=>"https://orcid.org", "__content__"=>"https://orcid.org/0000-0003-2043-4925"})
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 "with editor" do
37
- input = "https://doi.org/10.1371/journal.pone.0000030"
38
- subject = Briard::Metadata.new(input: input, from: "crossref")
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("resource", {})
41
- expect(datacite.dig("contributors", "contributor")).to eq("contributorName"=>{"__content__"=>"Janbon, Guilhem", "nameType"=>"Personal"}, "contributorType"=>"Editor", "familyName"=>"Janbon", "givenName"=>"Guilhem")
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 "Crossref DOI" do
45
- input = fixture_path + "crossref.bib"
46
- subject = Briard::Metadata.new(input: input, from: "bibtex")
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("resource", {})
49
- expect(datacite.dig("resourceType", "resourceTypeGeneral")).to eq("JournalArticle")
50
- expect(datacite.dig("titles", "title")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
51
- expect(datacite.dig("descriptions", "description").first).to eq("__content__"=>"eLife, 3", "descriptionType"=>"SeriesInformation")
52
- expect(datacite.dig("descriptions", "description", 1, "__content__")).to start_with("Among various advantages, their small size makes model organisms preferred subjects of investigation.")
53
- expect(datacite.dig("creators", "creator").count).to eq(5)
54
- expect(datacite.dig("creators", "creator").first).to eq("creatorName"=>{"__content__"=>"Sankar, Martial", "nameType"=>"Personal"}, "familyName"=>"Sankar", "givenName"=>"Martial")
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 "BlogPosting Citeproc JSON" do
58
- input = fixture_path + "citeproc.json"
59
- subject = Briard::Metadata.new(input: input, from: "citeproc")
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("resource", {})
62
- expect(datacite.dig("resourceType", "resourceTypeGeneral")).to eq("Text")
63
- expect(datacite.dig("titles", "title")).to eq("Eating your own Dog Food")
64
- expect(datacite.dig("descriptions", "description").first).to eq("__content__"=>"DataCite Blog", "descriptionType"=>"SeriesInformation")
65
- expect(datacite.dig("descriptions", "description", 1, "__content__")).to start_with("Eating your own dog food")
66
- expect(datacite.dig("creators", "creator")).to eq("creatorName"=>"Fenner, Martin", "familyName"=>"Fenner", "givenName"=>"Martin")
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 "rdataone" do
70
- input = fixture_path + 'codemeta.json'
71
- subject = Briard::Metadata.new(input: input, from: "codemeta")
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("resource", {})
74
- expect(datacite.dig("titles", "title")).to eq("R Interface to the DataONE REST API")
75
- expect(datacite.dig("creators", "creator")).to eq([{"affiliation"=>"NCEAS", "creatorName"=>{"__content__"=>"Jones, Matt", "nameType"=>"Personal"},
76
- "givenName"=>"Matt",
77
- "familyName"=>"Jones",
78
- "nameIdentifier"=>
79
- {"nameIdentifierScheme"=>"ORCID",
80
- "schemeURI"=>"https://orcid.org",
81
- "__content__"=>"https://orcid.org/0000-0003-0077-4738"}},
82
- {"affiliation"=>"NCEAS", "creatorName"=>{"__content__"=>"Slaughter, Peter", "nameType"=>"Personal"},
83
- "givenName"=>"Peter",
84
- "familyName"=>"Slaughter",
85
- "nameIdentifier"=>
86
- {"nameIdentifierScheme"=>"ORCID",
87
- "schemeURI"=>"https://orcid.org",
88
- "__content__"=>"https://orcid.org/0000-0002-2192-403X"}},
89
- {"creatorName"=>{"__content__"=>"University Of California, Santa Barbara", "nameType"=>"Organizational"}}])
90
- expect(datacite.fetch("version")).to eq("2.0.0")
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 "rdataone and codemeta_v2" do
94
- input = fixture_path + 'codemeta_v2.json'
95
- subject = Briard::Metadata.new(input: input, from: "codemeta")
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("resource", {})
98
- expect(datacite.dig("titles", "title")).to eq("R Interface to the DataONE REST API")
99
- expect(datacite.dig("creators", "creator")).to eq([{"affiliation"=>"NCEAS", "creatorName"=>{"__content__"=>"Jones, Matt", "nameType"=>"Personal"},
100
- "givenName"=>"Matt",
101
- "familyName"=>"Jones",
102
- "nameIdentifier"=>
103
- {"nameIdentifierScheme"=>"ORCID",
104
- "schemeURI"=>"https://orcid.org",
105
- "__content__"=>"https://orcid.org/0000-0003-0077-4738"}},
106
- {"affiliation"=>"NCEAS", "creatorName"=>{"__content__"=>"Slaughter, Peter", "nameType"=>"Personal"},
107
- "givenName"=>"Peter",
108
- "familyName"=>"Slaughter",
109
- "nameIdentifier"=>
110
- {"nameIdentifierScheme"=>"ORCID",
111
- "schemeURI"=>"https://orcid.org",
112
- "__content__"=>"https://orcid.org/0000-0002-2192-403X"}},
113
- {"creatorName"=>{"__content__"=>"University Of California, Santa Barbara", "nameType"=>"Organizational"}}])
114
- expect(datacite.fetch("version")).to eq("2.0.0")
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 "maremma" do
118
- input = "https://github.com/datacite/maremma"
119
- subject = Briard::Metadata.new(input: input, from: "codemeta")
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("resource", {})
122
- expect(datacite.dig("titles", "title")).to eq("Maremma: a Ruby library for simplified network calls")
123
- expect(datacite.dig("creators", "creator")).to eq("affiliation"=>"DataCite", "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"})
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 "with version" do
127
- input = "https://doi.org/10.5281/zenodo.28518"
128
- subject = Briard::Metadata.new(input: input, from: "datacite", regenerate: true)
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("https://doi.org/10.5281/zenodo.28518")
131
- expect(subject.identifiers).to eq([{"identifier"=>"https://zenodo.org/record/28518", "identifierType"=>"URL"}])
132
- expect(subject.types).to eq("bibtex" => "misc",
133
- "citeproc" => "article",
134
- "resourceTypeGeneral" => "Software",
135
- "ris" => "COMP",
136
- "schemaOrg" => "SoftwareSourceCode")
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("affiliation" => [{"name"=>"University of Washington"}],
139
- "familyName" => "Vanderplas",
140
- "givenName" => "Jake",
141
- "name" => "Vanderplas, Jake",
142
- "nameIdentifiers" => [],
143
- "nameType" => "Personal")
144
- expect(subject.titles).to eq([{"title"=>"Supersmoother: Minor Bug Fix Release"}])
145
- expect(subject.rights_list).to eq([{"rights"=>"Open Access", "rightsUri"=>"info:eu-repo/semantics/openAccess"}])
146
- expect(subject.dates).to eq([{"date"=>"2015-08-19", "dateType"=>"Issued"}])
147
- expect(subject.publication_year).to eq("2015")
148
- expect(subject.version_info).to eq("v0.3.2")
149
- expect(subject.publisher).to eq("Zenodo")
150
- expect(subject.agency).to eq("datacite")
151
- expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-4")
152
- expect(subject.datacite).to include("<version>v0.3.2</version>")
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 "Text pass-thru" do
156
- input = "https://doi.org/10.23640/07243.5153971"
157
- subject = Briard::Metadata.new(input: input, from: "datacite")
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("https://doi.org/10.23640/07243.5153971")
160
- expect(subject.types).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resourceType"=>"Paper", "resourceTypeGeneral"=>"Text", "ris"=>"RPRT", "schemaOrg"=>"ScholarlyArticle")
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("nameType"=>"Personal", "familyName" => "Paglione", "givenName" => "Laura", "nameIdentifiers" => [{"nameIdentifier"=>"https://orcid.org/0000-0003-3188-6273", "nameIdentifierScheme"=>"ORCID", "schemeUri"=>"https://orcid.org"}], "name" => "Paglione, Laura", "affiliation" => [])
163
- expect(subject.titles).to eq([{"title"=>"Recommendation of: ORCID Works Metadata Working Group"}])
164
- expect(subject.rights_list).to eq([{"rights"=>"Creative Commons Zero v1.0 Universal",
165
- "rightsIdentifier"=>"cc0-1.0",
166
- "rightsIdentifierScheme"=>"SPDX",
167
- "rightsUri"=>"https://creativecommons.org/publicdomain/zero/1.0/legalcode",
168
- "schemeUri"=>"https://spdx.org/licenses/"}])
169
- expect(subject.dates).to eq([{"date"=>"2017-06-28", "dateType"=>"Created"}, {"date"=>"2017-06-28", "dateType"=>"Updated"}, {"date"=>"2017", "dateType"=>"Issued"}])
170
- expect(subject.publication_year).to eq("2017")
171
- expect(subject.publisher).to eq("Figshare")
172
- expect(subject.subjects).to eq([{"subject"=>"information systems"},
173
- {"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
174
- "subject"=>"FOS: Computer and information sciences",
175
- "subjectScheme"=>"Fields of Science and Technology (FOS)"}])
176
- expect(subject.agency).to eq("datacite")
177
- expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3")
178
- expect(subject.datacite).to end_with("</resource>")
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 "Text pass-thru with doi in options" do
182
- input = "https://doi.org/10.23640/07243.5153971"
183
- subject = Briard::Metadata.new(input: input, from: "datacite", doi: "10.5072/07243.5153971")
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("https://doi.org/10.5072/07243.5153971")
186
- expect(subject.types).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resourceType"=>"Paper", "resourceTypeGeneral"=>"Text", "ris"=>"RPRT", "schemaOrg"=>"ScholarlyArticle")
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("nameType" => "Personal", "familyName" => "Paglione", "givenName" => "Laura", "name" => "Paglione, Laura", "nameIdentifiers" => [{"nameIdentifier"=>"https://orcid.org/0000-0003-3188-6273", "nameIdentifierScheme"=>"ORCID", "schemeUri"=>"https://orcid.org"}],"affiliation" => [])
189
- expect(subject.titles).to eq([{"title"=>"Recommendation of: ORCID Works Metadata Working Group"}])
190
- expect(subject.rights_list).to eq([{"rights"=>"Creative Commons Zero v1.0 Universal",
191
- "rightsIdentifier"=>"cc0-1.0",
192
- "rightsIdentifierScheme"=>"SPDX",
193
- "rightsUri"=>"https://creativecommons.org/publicdomain/zero/1.0/legalcode",
194
- "schemeUri"=>"https://spdx.org/licenses/"}])
195
- expect(subject.dates).to eq([{"date"=>"2017-06-28", "dateType"=>"Created"}, {"date"=>"2017-06-28", "dateType"=>"Updated"}, {"date"=>"2017", "dateType"=>"Issued"}])
196
- expect(subject.publication_year).to eq("2017")
197
- expect(subject.publisher).to eq("Figshare")
198
- expect(subject.subjects).to eq([{"subject"=>"information systems"},
199
- {"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
200
- "subject"=>"FOS: Computer and information sciences",
201
- "subjectScheme"=>"Fields of Science and Technology (FOS)"}])
202
- expect(subject.agency).to eq("datacite")
203
- expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-3")
204
- expect(subject.datacite).to end_with("</resource>")
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 "Dataset in schema 4.0" do
208
- input = "https://doi.org/10.5061/DRYAD.8515"
209
- subject = Briard::Metadata.new(input: input, from: "datacite", regenerate: true)
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("bibtex"=>"misc", "citeproc"=>"dataset", "resourceType"=>"dataset", "resourceTypeGeneral"=>"Dataset", "ris"=>"DATA", "schemaOrg"=>"Dataset")
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("nameType" => "Personal", "name"=>"Ollomo, Benjamin", "givenName"=>"Benjamin", "familyName"=>"Ollomo", "nameIdentifiers"=>[], "affiliation" => [{"affiliationIdentifier"=>"https://ror.org/01wyqb997", "affiliationIdentifierScheme"=>"ROR", "name"=>"Centre International de Recherches Médicales de Franceville"}])
214
- expect(subject.titles).to eq([{"title"=>"Data from: A new malaria agent in African hominids."}])
215
- expect(subject.id).to eq("https://doi.org/10.5061/dryad.8515")
216
- expect(subject.rights_list).to eq([{"rights"=>"Creative Commons Zero v1.0 Universal",
217
- "rightsIdentifier"=>"cc0-1.0",
218
- "rightsIdentifierScheme"=>"SPDX",
219
- "rightsUri"=>"https://creativecommons.org/publicdomain/zero/1.0/legalcode",
220
- "schemeUri"=>"https://spdx.org/licenses/"}])
221
- expect(subject.dates).to eq([{"date"=>"2011-02-01T17:22:41Z", "dateType"=>"Available"}, {"date"=>"2011", "dateType"=>"Issued"}])
222
- expect(subject.publication_year).to eq("2011")
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("relatedIdentifier" => "10.1371/journal.ppat.1000446",
225
- "relatedIdentifierType" => "DOI","relationType"=>"IsCitedBy")
226
- expect(subject.publisher).to eq("Dryad")
227
- expect(subject.agency).to eq("datacite")
228
- expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-4")
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("resource", {})
231
- expect(datacite.fetch("xsi:schemaLocation", "").split(" ").first).to eq("http://datacite.org/schema/kernel-4")
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 "Affiliation" do
235
- input = fixture_path + 'datacite-example-geolocation-2.xml'
236
- doi = "10.6071/Z7WC73"
237
- subject = Briard::Metadata.new(input: input, from: "datacite", regenerate: true)
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("bibtex"=>"misc", "citeproc"=>"dataset", "resourceType"=>"dataset", "resourceTypeGeneral"=>"Dataset", "ris"=>"DATA", "schemaOrg"=>"Dataset")
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("affiliation"=>[{"name"=>"UC Merced"}, {"name"=>"NSF"}], "familyName"=>"Bales", "givenName"=>"Roger", "name"=>"Bales, Roger", "nameType"=>"Personal", "nameIdentifiers"=>[])
242
- 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"}])
243
- expect(subject.id).to eq("https://doi.org/10.6071/z7wc73")
244
- expect(subject.rights_list).to eq([{"rights"=>"Creative Commons Attribution 4.0 International",
245
- "rightsIdentifier"=>"cc-by-4.0",
246
- "rightsIdentifierScheme"=>"SPDX",
247
- "rightsUri"=>"https://creativecommons.org/licenses/by/4.0/legalcode",
248
- "schemeUri"=>"https://spdx.org/licenses/"}])
249
- expect(subject.dates).to eq([{"date"=>"2014-10-17", "dateType"=>"Updated"}, {"date"=>"2016-03-14T17:02:02Z", "dateType"=>"Available"}, {"date"=>"2013", "dateType"=>"Issued"}])
250
- expect(subject.publication_year).to eq("2013")
251
- expect(subject.publisher).to eq("UC Merced")
252
- expect(subject.agency).to eq("datacite")
253
- expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-4")
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("resource", {})
256
- expect(datacite.fetch("xsi:schemaLocation", "").split(" ").first).to eq("http://datacite.org/schema/kernel-4")
257
- expect(datacite.dig("creators", "creator", 0, "affiliation")).to eq(["UC Merced", "NSF"])
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 "DOI not found" do
261
- input = "https://doi.org/10.4124/05F6C379-DD68-4CDB-880D-33D3E9576D52/1"
262
- subject = Briard::Metadata.new(input: input, from: "datacite")
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("https://doi.org/10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1")
265
- expect(subject.doi).to eq("10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1")
266
- expect(subject.agency).to eq("datacite")
267
- expect(subject.state).to eq("not_found")
268
- datacite = Maremma.from_xml(subject.datacite).fetch("resource", {})
269
- expect(datacite["identifier"]).to eq("identifierType"=>"DOI", "__content__"=>"10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1")
270
- expect(datacite["xmlns"]).to eq("http://datacite.org/schema/kernel-4")
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 "no input" do
328
+ it 'no input' do
274
329
  input = nil
275
- subject = Briard::Metadata.new(input: input, from: "datacite", doi: "10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1")
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("resource", {})
278
- expect(datacite["identifier"]).to eq("identifierType"=>"DOI", "__content__"=>"10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1")
279
- expect(datacite["xmlns"]).to eq("http://datacite.org/schema/kernel-4")
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 "change metadata as datacite xml" do
284
- it "with data citation" do
285
- input = "10.7554/eLife.01567"
286
- subject = Briard::Metadata.new(input: input, from: "crossref")
287
- subject.doi = "10.5061/DRYAD.8515"
288
- subject.titles = [{ "title" => "Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth" }]
289
- subject.types = { "schemaOrg" => "Dataset", "resourceTypeGeneral" => "Dataset" }
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("resource", {})
292
- expect(datacite.dig("identifier", "__content__")).to eq("10.5061/DRYAD.8515")
293
- expect(datacite.dig("resourceType", "resourceTypeGeneral")).to eq("Dataset")
294
- expect(datacite.dig("titles", "title")).to eq("Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
295
- expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").length).to eq(28)
296
- expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").first).to eq("__content__"=>"2050-084X", "relatedIdentifierType"=>"ISSN", "relationType"=>"IsPartOf", "resourceTypeGeneral"=>"Collection")
297
- expect(datacite.dig("relatedIdentifiers", "relatedIdentifier")[1]).to eq("relatedIdentifierType"=>"DOI", "relationType"=>"References", "__content__"=>"10.1038/nature02100")
298
- expect(datacite.dig("rightsList", "rights")).to eq("rightsURI"=>"https://creativecommons.org/licenses/by/3.0/legalcode", "rightsIdentifier"=>"cc-by-3.0", "rightsIdentifierScheme"=>"SPDX", "schemeURI"=>"https://spdx.org/licenses/", "__content__"=>"Creative Commons Attribution 3.0 Unported")
299
- expect(datacite.dig("fundingReferences", "fundingReference").count).to eq(4)
300
- expect(datacite.dig("fundingReferences", "fundingReference").last).to eq("funderName"=>"University of Lausanne", "funderIdentifier" => {"funderIdentifierType"=>"Crossref Funder ID", "__content__"=>"https://doi.org/10.13039/501100006390"})
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 "change description" do
304
- input = "10.7554/eLife.01567"
305
- subject = Briard::Metadata.new(input: input, from: "crossref")
306
- subject.descriptions = { "description" => "This is an abstract." }
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("resource", {})
309
- expect(datacite.dig("descriptions", "description")).to eq([{"__content__"=>"eLife, 3, e01567", "descriptionType"=>"SeriesInformation"}, {"__content__"=>"This is an abstract.", "descriptionType"=>"Abstract"}])
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 "change description no input" do
383
+ it 'change description no input' do
313
384
  input = nil
314
- subject = Briard::Metadata.new(input: input, from: "datacite", doi: "10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1")
315
- subject.descriptions = "This is an abstract."
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("resource", {})
318
- expect(datacite.dig("descriptions", "description")).to eq("descriptionType"=>"Abstract", "__content__"=>"This is an abstract.")
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 "required metadata no input" do
395
+ it 'required metadata no input' do
322
396
  input = nil
323
- subject = Briard::Metadata.new(input: input, doi: "10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1")
324
- subject.creators = [{"creatorName"=>"Fenner, Martin", "givenName"=>"Martin", "familyName"=>"Fenner"}]
325
- subject.titles = [{ "title" => "Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth" }]
326
- subject.types = { "schemaOrg" => "Dataset", "resourceTypeGeneral" => "Dataset" }
327
- subject.publication_year = "2011"
328
- subject.state = "findable"
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("resource", {})
331
- expect(datacite.dig("identifier", "__content__")).to eq("10.4124/05f6c379-dd68-4cdb-880d-33d3e9576d52/1")
332
- expect(datacite.dig("resourceType", "resourceTypeGeneral")).to eq("Dataset")
333
- expect(datacite.dig("titles", "title")).to eq("Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
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 "change license" do
338
- input = "10.7554/eLife.01567"
339
- subject = Briard::Metadata.new(input: input, from: "crossref")
340
- subject.rights_list = [{ "rights_uri" => "https://creativecommons.org/licenses/by-nc-sa/4.0", "rights" => "Creative Commons Attribution-NonCommercial-ShareAlike" }]
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("resource", {})
343
- expect(datacite.dig("rightsList", "rights")).to eq("Creative Commons Attribution-NonCommercial-ShareAlike")
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 "change license url" do
347
- input = "10.7554/eLife.01567"
348
- subject = Briard::Metadata.new(input: input, from: "crossref")
349
- subject.rights_list = [{ "rightsUri" => "https://creativecommons.org/licenses/by-nc-sa/4.0" }]
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("resource", {})
352
- expect(datacite.dig("rightsList", "rights")).to eq("rightsURI"=>"https://creativecommons.org/licenses/by-nc-sa/4.0")
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 "change license name" do
356
- input = "10.7554/eLife.01567"
357
- subject = Briard::Metadata.new(input: input, from: "crossref")
358
- subject.rights_list = [{ "rights" => "Creative Commons Attribution-NonCommercial-ShareAlike" }]
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("resource", {})
361
- expect(datacite.dig("rightsList", "rights")).to eq("Creative Commons Attribution-NonCommercial-ShareAlike")
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 "change state" do
365
- input = "10.7554/eLife.01567"
366
- subject = Briard::Metadata.new(input: input, from: "crossref")
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("findable")
369
- subject.state = "registered"
370
- datacite = Maremma.from_xml(subject.datacite).fetch("resource", {})
371
- expect(datacite.dig("identifier", "__content__")).to eq("10.7554/elife.01567")
372
- expect(subject.state).to eq("registered")
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 "change identifiers" do
376
- input = "10.7554/eLife.01567"
377
- subject = Briard::Metadata.new(input: input, from: "crossref")
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([{"identifier"=>"e01567", "identifierType"=>"article_number"}])
380
- subject.identifiers = [{ "identifierType" => "article_number", "identifier" => "abc" }]
381
- datacite = Maremma.from_xml(subject.datacite).fetch("resource", {})
382
- expect(datacite.dig("identifier", "__content__")).to eq("10.7554/elife.01567")
383
- expect(subject.identifiers).to eq([{"identifier"=>"abc", "identifierType"=>"article_number"}])
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 "validates against schema" do
387
- input = "10.7554/eLife.01567"
388
- subject = Briard::Metadata.new(input: input, from: "crossref")
389
- subject.doi = "123"
390
- subject.titles = "Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth"
391
- subject.types = { "schemaOrg" => "Dataset", "resourceTypeGeneral" => "Dataset" }
392
- expect(subject.doi).to eq("123")
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 "from schema_org gtex" do
397
- input = fixture_path + "schema_org_gtex.json"
398
- subject = Briard::Metadata.new(input: input, from: "schema_org")
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("resource", {})
401
- expect(datacite.dig("identifier", "__content__")).to eq("10.25491/d50j-3083")
402
- expect(datacite.dig("creators", "creator").count).to eq(1)
403
- expect(datacite.dig("creators", "creator")).to eq("creatorName"=>{"__content__"=>"The GTEx Consortium", "nameType"=>"Organizational"})
404
- expect(datacite.dig("resourceType", "resourceTypeGeneral")).to eq("Dataset")
405
- expect(datacite.dig("resourceType", "__content__")).to eq("Gene expression matrices")
406
- expect(datacite.dig("titles", "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")
407
- expect(datacite.dig("version")).to eq("v7")
408
- expect(datacite.dig("publisher")).to eq("GTEx")
409
- expect(datacite.dig("descriptions", "description")).to eq("__content__"=>"GTEx", "descriptionType"=>"SeriesInformation")
410
- expect(datacite.dig("publicationYear")).to eq("2017")
411
- expect(datacite.dig("dates", "date")).to eq("__content__"=>"2017", "dateType"=>"Issued")
412
- expect(datacite.dig("subjects", "subject")).to eq(["gtex", "annotation", "phenotype", "gene regulation", "transcriptomics"])
413
- expect(datacite.dig("alternateIdentifiers", "alternateIdentifier")).to eq("__content__"=>"687610993", "alternateIdentifierType"=>"md5")
414
- expect(datacite.dig("fundingReferences", "fundingReference").count).to eq(7)
415
- expect(datacite.dig("fundingReferences", "fundingReference").last).to eq("funderIdentifier" => {"__content__"=>"https://doi.org/10.13039/100000065", "funderIdentifierType"=>"Crossref Funder ID"},"funderName" => "National Institute of Neurological Disorders and Stroke (NINDS)")
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