briard 2.4.1 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
data/spec/utils_spec.rb CHANGED
@@ -3,652 +3,676 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Briard::Metadata, vcr: true do
6
- let(:input) { "https://doi.org/10.1101/097196" }
6
+ subject { described_class.new(input: input, from: 'crossref') }
7
7
 
8
- subject { Briard::Metadata.new(input: input, from: "crossref") }
8
+ let(:input) { 'https://doi.org/10.1101/097196' }
9
9
 
10
- context "validate url" do
11
- it "DOI" do
12
- str = "https://doi.org/10.5438/0000-00ss"
10
+ context 'validate url' do
11
+ it 'DOI' do
12
+ str = 'https://doi.org/10.5438/0000-00ss'
13
13
  response = subject.validate_url(str)
14
- expect(response).to eq("DOI")
14
+ expect(response).to eq('DOI')
15
15
  end
16
16
 
17
- it "URL" do
18
- str = "https://blog.datacite.org/eating-your-own-dog-food"
17
+ it 'URL' do
18
+ str = 'https://blog.datacite.org/eating-your-own-dog-food'
19
19
  response = subject.validate_url(str)
20
- expect(response).to eq("URL")
20
+ expect(response).to eq('URL')
21
21
  end
22
22
 
23
- it "ISSN" do
24
- str = "ISSN 2050-084X"
23
+ it 'ISSN' do
24
+ str = 'ISSN 2050-084X'
25
25
  response = subject.validate_url(str)
26
- expect(response).to eq("ISSN")
26
+ expect(response).to eq('ISSN')
27
27
  end
28
28
 
29
- it "string" do
30
- str = "eating-your-own-dog-food"
29
+ it 'string' do
30
+ str = 'eating-your-own-dog-food'
31
31
  response = subject.validate_url(str)
32
- expect(response).to be_nil
32
+ expect(response.nil?).to be(true)
33
33
  end
34
34
  end
35
35
 
36
- context "validate_orcid" do
37
- it "validate_orcid" do
38
- orcid = "http://orcid.org/0000-0002-2590-225X"
36
+ context 'validate_orcid' do
37
+ it 'validate_orcid' do
38
+ orcid = 'http://orcid.org/0000-0002-2590-225X'
39
39
  response = subject.validate_orcid(orcid)
40
- expect(response).to eq("0000-0002-2590-225X")
40
+ expect(response).to eq('0000-0002-2590-225X')
41
41
  end
42
42
 
43
- it "validate_orcid https" do
44
- orcid = "https://orcid.org/0000-0002-2590-225X"
43
+ it 'validate_orcid https' do
44
+ orcid = 'https://orcid.org/0000-0002-2590-225X'
45
45
  response = subject.validate_orcid(orcid)
46
- expect(response).to eq("0000-0002-2590-225X")
46
+ expect(response).to eq('0000-0002-2590-225X')
47
47
  end
48
48
 
49
- it "validate_orcid id" do
50
- orcid = "0000-0002-2590-225X"
49
+ it 'validate_orcid id' do
50
+ orcid = '0000-0002-2590-225X'
51
51
  response = subject.validate_orcid(orcid)
52
- expect(response).to eq("0000-0002-2590-225X")
52
+ expect(response).to eq('0000-0002-2590-225X')
53
53
  end
54
54
 
55
- it "validate_orcid www" do
56
- orcid = "http://www.orcid.org/0000-0002-2590-225X"
55
+ it 'validate_orcid www' do
56
+ orcid = 'http://www.orcid.org/0000-0002-2590-225X'
57
57
  response = subject.validate_orcid(orcid)
58
- expect(response).to eq("0000-0002-2590-225X")
58
+ expect(response).to eq('0000-0002-2590-225X')
59
59
  end
60
60
 
61
- it "validate_orcid with spaces" do
62
- orcid = "0000 0002 1394 3097"
61
+ it 'validate_orcid with spaces' do
62
+ orcid = '0000 0002 1394 3097'
63
63
  response = subject.validate_orcid(orcid)
64
- expect(response).to eq("0000-0002-1394-3097")
64
+ expect(response).to eq('0000-0002-1394-3097')
65
65
  end
66
66
 
67
- it "validate_orcid sandbox" do
68
- orcid = "http://sandbox.orcid.org/0000-0002-2590-225X"
67
+ it 'validate_orcid sandbox' do
68
+ orcid = 'http://sandbox.orcid.org/0000-0002-2590-225X'
69
69
  response = subject.validate_orcid(orcid)
70
- expect(response).to eq("0000-0002-2590-225X")
70
+ expect(response).to eq('0000-0002-2590-225X')
71
71
  end
72
72
 
73
- it "validate_orcid sandbox https" do
74
- orcid = "https://sandbox.orcid.org/0000-0002-2590-225X"
73
+ it 'validate_orcid sandbox https' do
74
+ orcid = 'https://sandbox.orcid.org/0000-0002-2590-225X'
75
75
  response = subject.validate_orcid(orcid)
76
- expect(response).to eq("0000-0002-2590-225X")
76
+ expect(response).to eq('0000-0002-2590-225X')
77
77
  end
78
78
 
79
- it "validate_orcid wrong id" do
80
- orcid = "0000-0002-1394-309"
79
+ it 'validate_orcid wrong id' do
80
+ orcid = '0000-0002-1394-309'
81
81
  response = subject.validate_orcid(orcid)
82
- expect(response).to be_nil
82
+ expect(response.nil?).to be(true)
83
83
  end
84
84
  end
85
85
 
86
- context "validate_orcid_scheme" do
87
- it "validate_orcid_scheme" do
88
- orcid = "http://orcid.org"
86
+ context 'validate_orcid_scheme' do
87
+ it 'validate_orcid_scheme' do
88
+ orcid = 'http://orcid.org'
89
89
  response = subject.validate_orcid_scheme(orcid)
90
- expect(response).to eq("orcid.org")
90
+ expect(response).to eq('orcid.org')
91
91
  end
92
92
 
93
- it "validate_orcid_scheme trailing slash" do
94
- orcid = "http://orcid.org/"
93
+ it 'validate_orcid_scheme trailing slash' do
94
+ orcid = 'http://orcid.org/'
95
95
  response = subject.validate_orcid_scheme(orcid)
96
- expect(response).to eq("orcid.org")
96
+ expect(response).to eq('orcid.org')
97
97
  end
98
98
 
99
- it "validate_orcid_scheme https" do
100
- orcid = "https://orcid.org"
99
+ it 'validate_orcid_scheme https' do
100
+ orcid = 'https://orcid.org'
101
101
  response = subject.validate_orcid_scheme(orcid)
102
- expect(response).to eq("orcid.org")
102
+ expect(response).to eq('orcid.org')
103
103
  end
104
104
 
105
- it "validate_orcid_scheme www" do
106
- orcid = "http://www.orcid.org"
105
+ it 'validate_orcid_scheme www' do
106
+ orcid = 'http://www.orcid.org'
107
107
  response = subject.validate_orcid_scheme(orcid)
108
- expect(response).to eq("orcid.org")
108
+ expect(response).to eq('orcid.org')
109
109
  end
110
110
  end
111
111
 
112
- context "parse attributes" do
113
- it "string" do
114
- element = "10.5061/DRYAD.8515"
112
+ context 'parse attributes' do
113
+ it 'string' do
114
+ element = '10.5061/DRYAD.8515'
115
115
  response = subject.parse_attributes(element)
116
- expect(response).to eq("10.5061/DRYAD.8515")
116
+ expect(response).to eq('10.5061/DRYAD.8515')
117
117
  end
118
118
 
119
- it "hash" do
120
- element = { "__content__" => "10.5061/DRYAD.8515" }
119
+ it 'hash' do
120
+ element = { '__content__' => '10.5061/DRYAD.8515' }
121
121
  response = subject.parse_attributes(element)
122
- expect(response).to eq("10.5061/DRYAD.8515")
122
+ expect(response).to eq('10.5061/DRYAD.8515')
123
123
  end
124
124
 
125
- it "array" do
126
- element = [{ "__content__" => "10.5061/DRYAD.8515" }]
125
+ it 'array' do
126
+ element = [{ '__content__' => '10.5061/DRYAD.8515' }]
127
127
  response = subject.parse_attributes(element)
128
- expect(response).to eq("10.5061/DRYAD.8515")
128
+ expect(response).to eq('10.5061/DRYAD.8515')
129
129
  end
130
130
 
131
- it "array of strings" do
132
- element = ["datacite", "doi", "metadata", "featured"]
131
+ it 'array of strings' do
132
+ element = %w[datacite doi metadata featured]
133
133
  response = subject.parse_attributes(element)
134
- expect(response).to eq(["datacite", "doi", "metadata", "featured"])
134
+ expect(response).to eq(%w[datacite doi metadata featured])
135
135
  end
136
136
 
137
- it "nil" do
137
+ it 'nil' do
138
138
  element = nil
139
139
  response = subject.parse_attributes(element)
140
- expect(response).to be_nil
140
+ expect(response.nil?).to be(true)
141
141
  end
142
142
 
143
- it "first" do
144
- element = [{ "__content__" => "10.5061/DRYAD.8515/1" }, { "__content__" => "10.5061/DRYAD.8515/2" }]
143
+ it 'first' do
144
+ element = [{ '__content__' => '10.5061/DRYAD.8515/1' },
145
+ { '__content__' => '10.5061/DRYAD.8515/2' }]
145
146
  response = subject.parse_attributes(element, first: true)
146
- expect(response).to eq("10.5061/DRYAD.8515/1")
147
+ expect(response).to eq('10.5061/DRYAD.8515/1')
147
148
  end
148
149
  end
149
150
 
150
- context "normalize id" do
151
- it "doi" do
152
- doi = "10.5061/DRYAD.8515"
151
+ context 'normalize id' do
152
+ it 'doi' do
153
+ doi = '10.5061/DRYAD.8515'
153
154
  response = subject.normalize_id(doi)
154
- expect(response).to eq("https://doi.org/10.5061/dryad.8515")
155
+ expect(response).to eq('https://doi.org/10.5061/dryad.8515')
155
156
  end
156
157
 
157
- it "doi as url" do
158
- doi = "http://dx.doi.org/10.5061/DRYAD.8515"
158
+ it 'doi as url' do
159
+ doi = 'http://dx.doi.org/10.5061/DRYAD.8515'
159
160
  response = subject.normalize_id(doi)
160
- expect(response).to eq("https://doi.org/10.5061/dryad.8515")
161
+ expect(response).to eq('https://doi.org/10.5061/dryad.8515')
161
162
  end
162
163
 
163
- it "url" do
164
- url = "https://blog.datacite.org/eating-your-own-dog-food/"
164
+ it 'url' do
165
+ url = 'https://blog.datacite.org/eating-your-own-dog-food/'
165
166
  response = subject.normalize_id(url)
166
- expect(response).to eq("https://blog.datacite.org/eating-your-own-dog-food")
167
+ expect(response).to eq('https://blog.datacite.org/eating-your-own-dog-food')
167
168
  end
168
169
 
169
- it "url with utf-8" do
170
- url = "http://www.詹姆斯.com/eating-your-own-dog-food/"
170
+ it 'url with utf-8' do
171
+ url = 'http://www.詹姆斯.com/eating-your-own-dog-food/'
171
172
  response = subject.normalize_id(url)
172
- expect(response).to eq("http://www.xn--8ws00zhy3a.com/eating-your-own-dog-food")
173
+ expect(response).to eq('http://www.xn--8ws00zhy3a.com/eating-your-own-dog-food')
173
174
  end
174
175
 
175
- it "ftp" do
176
- url = "ftp://blog.datacite.org/eating-your-own-dog-food/"
176
+ it 'ftp' do
177
+ url = 'ftp://blog.datacite.org/eating-your-own-dog-food/'
177
178
  response = subject.normalize_id(url)
178
- expect(response).to be_nil
179
+ expect(response.nil?).to be(true)
179
180
  end
180
181
 
181
- it "invalid url" do
182
- url = "http://"
182
+ it 'invalid url' do
183
+ url = 'http://'
183
184
  response = subject.normalize_id(url)
184
- expect(response).to be_nil
185
+ expect(response.nil?).to be(true)
185
186
  end
186
187
 
187
- it "string" do
188
- url = "eating-your-own-dog-food"
188
+ it 'string' do
189
+ url = 'eating-your-own-dog-food'
189
190
  response = subject.normalize_id(url)
190
- expect(response).to be_nil
191
+ expect(response.nil?).to be(true)
191
192
  end
192
193
 
193
- it "sandbox via url" do
194
- url = "https://handle.stage.datacite.org/10.20375/0000-0001-ddb8-7"
194
+ it 'sandbox via url' do
195
+ url = 'https://handle.stage.datacite.org/10.20375/0000-0001-ddb8-7'
195
196
  response = subject.normalize_id(url)
196
- expect(response).to eq("https://handle.stage.datacite.org/10.20375/0000-0001-ddb8-7")
197
+ expect(response).to eq('https://handle.stage.datacite.org/10.20375/0000-0001-ddb8-7')
197
198
  end
198
199
 
199
- it "sandbox via options" do
200
- url = "10.20375/0000-0001-ddb8-7"
200
+ it 'sandbox via options' do
201
+ url = '10.20375/0000-0001-ddb8-7'
201
202
  response = subject.normalize_id(url, sandbox: true)
202
- expect(response).to eq("https://handle.stage.datacite.org/10.20375/0000-0001-ddb8-7")
203
+ expect(response).to eq('https://handle.stage.datacite.org/10.20375/0000-0001-ddb8-7')
203
204
  end
204
205
  end
205
206
 
206
- context "normalize ids" do
207
- it "doi" do
208
- ids = [{"@type"=>"CreativeWork", "@id"=>"https://doi.org/10.5438/0012"}, {"@type"=>"CreativeWork", "@id"=>"https://doi.org/10.5438/55E5-T5C0"}]
207
+ context 'normalize ids' do
208
+ it 'doi' do
209
+ ids = [{ '@type' => 'CreativeWork', '@id' => 'https://doi.org/10.5438/0012' },
210
+ { '@type' => 'CreativeWork', '@id' => 'https://doi.org/10.5438/55E5-T5C0' }]
209
211
  response = subject.normalize_ids(ids: ids)
210
- expect(response).to eq([{"relatedIdentifier"=>"10.5438/0012",
211
- "relatedIdentifierType"=>"DOI",
212
- "resourceTypeGeneral"=>"Text"},
213
- {"relatedIdentifier"=>"10.5438/55e5-t5c0",
214
- "relatedIdentifierType"=>"DOI",
215
- "resourceTypeGeneral"=>"Text"}])
212
+ expect(response).to eq([{ 'relatedIdentifier' => '10.5438/0012',
213
+ 'relatedIdentifierType' => 'DOI',
214
+ 'resourceTypeGeneral' => 'Text' },
215
+ { 'relatedIdentifier' => '10.5438/55e5-t5c0',
216
+ 'relatedIdentifierType' => 'DOI',
217
+ 'resourceTypeGeneral' => 'Text' }])
216
218
  end
217
219
 
218
- it "url" do
219
- ids = [{"@type"=>"CreativeWork", "@id"=>"https://blog.datacite.org/eating-your-own-dog-food/"}]
220
+ it 'url' do
221
+ ids = [{ '@type' => 'CreativeWork',
222
+ '@id' => 'https://blog.datacite.org/eating-your-own-dog-food/' }]
220
223
  response = subject.normalize_ids(ids: ids)
221
- expect(response).to eq("relatedIdentifier"=>"https://blog.datacite.org/eating-your-own-dog-food", "relatedIdentifierType"=>"URL", "resourceTypeGeneral" => "Text")
224
+ expect(response).to eq(
225
+ 'relatedIdentifier' => 'https://blog.datacite.org/eating-your-own-dog-food', 'relatedIdentifierType' => 'URL', 'resourceTypeGeneral' => 'Text'
226
+ )
222
227
  end
223
228
  end
224
229
 
225
- context "normalize url" do
226
- it "with trailing slash" do
227
- url = "http://creativecommons.org/publicdomain/zero/1.0/"
230
+ context 'normalize url' do
231
+ it 'with trailing slash' do
232
+ url = 'http://creativecommons.org/publicdomain/zero/1.0/'
228
233
  response = subject.normalize_url(url)
229
- expect(response).to eq("http://creativecommons.org/publicdomain/zero/1.0")
234
+ expect(response).to eq('http://creativecommons.org/publicdomain/zero/1.0')
230
235
  end
231
236
 
232
- it "with trailing slash and to https" do
233
- url = "http://creativecommons.org/publicdomain/zero/1.0/"
237
+ it 'with trailing slash and to https' do
238
+ url = 'http://creativecommons.org/publicdomain/zero/1.0/'
234
239
  response = subject.normalize_url(url, https: true)
235
- expect(response).to eq("https://creativecommons.org/publicdomain/zero/1.0")
240
+ expect(response).to eq('https://creativecommons.org/publicdomain/zero/1.0')
236
241
  end
237
242
 
238
- it "uri" do
239
- url = "info:eu-repo/semantics/openAccess"
243
+ it 'uri' do
244
+ url = 'info:eu-repo/semantics/openAccess'
240
245
  response = subject.normalize_url(url)
241
- expect(response).to eq("info:eu-repo/semantics/openAccess")
246
+ expect(response).to eq('info:eu-repo/semantics/openAccess')
242
247
  end
243
248
  end
244
249
 
245
- context "normalize cc url" do
246
- it "with trailing slash" do
247
- url = "http://creativecommons.org/publicdomain/zero/1.0/"
250
+ context 'normalize cc url' do
251
+ it 'with trailing slash' do
252
+ url = 'http://creativecommons.org/publicdomain/zero/1.0/'
248
253
  response = subject.normalize_cc_url(url)
249
- expect(response).to eq("https://creativecommons.org/publicdomain/zero/1.0/legalcode")
254
+ expect(response).to eq('https://creativecommons.org/publicdomain/zero/1.0/legalcode')
250
255
  end
251
256
 
252
- it "with trailing slash and to https" do
253
- url = "http://creativecommons.org/publicdomain/zero/1.0/"
257
+ it 'with trailing slash and to https' do
258
+ url = 'http://creativecommons.org/publicdomain/zero/1.0/'
254
259
  response = subject.normalize_cc_url(url)
255
- expect(response).to eq("https://creativecommons.org/publicdomain/zero/1.0/legalcode")
260
+ expect(response).to eq('https://creativecommons.org/publicdomain/zero/1.0/legalcode')
256
261
  end
257
262
 
258
- it "not found" do
259
- url = "http://creativecommons.org/publicdomain/zero/2.0/"
263
+ it 'not found' do
264
+ url = 'http://creativecommons.org/publicdomain/zero/2.0/'
260
265
  response = subject.normalize_cc_url(url)
261
- expect(response).to eq("https://creativecommons.org/publicdomain/zero/2.0")
266
+ expect(response).to eq('https://creativecommons.org/publicdomain/zero/2.0')
262
267
  end
263
268
  end
264
269
 
265
- context "normalize issn" do
266
- it "from array" do
267
- input = [{"media_type"=>"print", "__content__"=>"13040855"}, {"media_type"=>"electronic", "__content__"=>"21468427"}]
270
+ context 'normalize issn' do
271
+ it 'from array' do
272
+ input = [{ 'media_type' => 'print', '__content__' => '13040855' },
273
+ { 'media_type' => 'electronic', '__content__' => '21468427' }]
268
274
  response = subject.normalize_issn(input)
269
- expect(response).to eq("2146-8427")
275
+ expect(response).to eq('2146-8427')
270
276
  end
271
277
 
272
- it "from empty array" do
278
+ it 'from empty array' do
273
279
  input = []
274
280
  response = subject.normalize_issn(input)
275
- expect(response).to be_nil
281
+ expect(response.nil?).to be(true)
276
282
  end
277
283
 
278
- it "from hash" do
279
- input = {"media_type"=>"electronic", "__content__"=>"21468427"}
284
+ it 'from hash' do
285
+ input = { 'media_type' => 'electronic', '__content__' => '21468427' }
280
286
  response = subject.normalize_issn(input)
281
- expect(response).to eq("2146-8427")
287
+ expect(response).to eq('2146-8427')
282
288
  end
283
289
 
284
- it "from string" do
285
- input = "2146-8427"
290
+ it 'from string' do
291
+ input = '2146-8427'
286
292
  response = subject.normalize_issn(input)
287
- expect(response).to eq("2146-8427")
293
+ expect(response).to eq('2146-8427')
288
294
  end
289
295
  end
290
296
 
291
- context "to_schema_org" do
292
- it "with id" do
293
- author = {"type"=>"Person", "id"=>"http://orcid.org/0000-0003-1419-2405", "givenName"=>"Martin", "familyName"=>"Fenner", "name"=>"Martin Fenner" }
297
+ context 'to_schema_org' do
298
+ it 'with id' do
299
+ author = { 'type' => 'Person', 'id' => 'http://orcid.org/0000-0003-1419-2405', 'givenName' => 'Martin', 'familyName' => 'Fenner', 'name' => 'Martin Fenner' }
294
300
  response = subject.to_schema_org(author)
295
- expect(response).to eq("givenName"=>"Martin", "familyName"=>"Fenner", "name"=>"Martin Fenner", "@type"=>"Person", "@id"=>"http://orcid.org/0000-0003-1419-2405")
301
+ expect(response).to eq('givenName' => 'Martin', 'familyName' => 'Fenner',
302
+ 'name' => 'Martin Fenner', '@type' => 'Person', '@id' => 'http://orcid.org/0000-0003-1419-2405')
296
303
  end
297
304
  end
298
305
 
299
- context "from_schema_org" do
300
- it "with @id" do
301
- author = {"@type"=>"Person", "@id"=>"http://orcid.org/0000-0003-1419-2405", "givenName"=>"Martin", "familyName"=>"Fenner", "name"=>"Martin Fenner" }
306
+ context 'from_schema_org' do
307
+ it 'with @id' do
308
+ author = { '@type' => 'Person', '@id' => 'http://orcid.org/0000-0003-1419-2405', 'givenName' => 'Martin', 'familyName' => 'Fenner', 'name' => 'Martin Fenner' }
302
309
  response = subject.from_schema_org(author)
303
- expect(response).to eq("givenName"=>"Martin", "familyName"=>"Fenner", "name"=>"Martin Fenner", "type"=>"Person", "id"=>"http://orcid.org/0000-0003-1419-2405")
310
+ expect(response).to eq('givenName' => 'Martin', 'familyName' => 'Fenner',
311
+ 'name' => 'Martin Fenner', 'type' => 'Person', 'id' => 'http://orcid.org/0000-0003-1419-2405')
304
312
  end
305
313
  end
306
314
 
307
- context "from_schema_org_creators" do
308
- it "with affiliation" do
309
- authors = [{"@type"=>"Person", "@id"=>"http://orcid.org/0000-0003-1419-2405", "givenName"=>"Martin", "familyName"=>"Fenner", "name"=>"Martin Fenner", "affiliation" => {
310
- "@id" => "https://ror.org/04wxnsj81",
311
- "name" => "DataCite",
312
- "@type" => "Organization"
313
- }}]
315
+ context 'from_schema_org_creators' do
316
+ it 'with affiliation' do
317
+ authors = [{ '@type' => 'Person', '@id' => 'http://orcid.org/0000-0003-1419-2405', 'givenName' => 'Martin', 'familyName' => 'Fenner', 'name' => 'Martin Fenner', 'affiliation' => {
318
+ '@id' => 'https://ror.org/04wxnsj81',
319
+ 'name' => 'DataCite',
320
+ '@type' => 'Organization'
321
+ } }]
314
322
  response = subject.from_schema_org_creators(authors)
315
- expect(response).to eq([{"affiliation"=>
316
- {"affiliationIdentifier"=>"https://ror.org/04wxnsj81",
317
- "affiliationIdentifierScheme"=>"ROR",
318
- "__content__"=>"DataCite",
319
- "schemeUri"=>"https://ror.org/"},
320
- "creatorName"=>{"__content__"=>"Martin Fenner", "nameType"=>"Personal"},
321
- "familyName"=>"Fenner",
322
- "givenName"=>"Martin",
323
- "nameIdentifier"=>
324
- [{"__content__"=>"http://orcid.org/0000-0003-1419-2405",
325
- "nameIdentifierScheme"=>"ORCID",
326
- "schemeUri"=>"https://orcid.org"}]}])
327
- end
328
-
329
- it "without affiliation" do
330
- authors = [{"@type"=>"Person", "@id"=>"http://orcid.org/0000-0003-1419-2405", "givenName"=>"Martin", "familyName"=>"Fenner", "name"=>"Martin Fenner" }]
323
+ expect(response).to eq([{ 'affiliation' =>
324
+ { 'affiliationIdentifier' => 'https://ror.org/04wxnsj81',
325
+ 'affiliationIdentifierScheme' => 'ROR',
326
+ '__content__' => 'DataCite',
327
+ 'schemeUri' => 'https://ror.org/' },
328
+ 'creatorName' => { '__content__' => 'Martin Fenner',
329
+ 'nameType' => 'Personal' },
330
+ 'familyName' => 'Fenner',
331
+ 'givenName' => 'Martin',
332
+ 'nameIdentifier' =>
333
+ [{ '__content__' => 'http://orcid.org/0000-0003-1419-2405',
334
+ 'nameIdentifierScheme' => 'ORCID',
335
+ 'schemeUri' => 'https://orcid.org' }] }])
336
+ end
337
+
338
+ it 'without affiliation' do
339
+ authors = [{ '@type' => 'Person', '@id' => 'http://orcid.org/0000-0003-1419-2405',
340
+ 'givenName' => 'Martin', 'familyName' => 'Fenner', 'name' => 'Martin Fenner' }]
331
341
  response = subject.from_schema_org_creators(authors)
332
- expect(response).to eq([{"creatorName"=>{"__content__"=>"Martin Fenner", "nameType"=>"Personal"},
333
- "familyName"=>"Fenner",
334
- "givenName"=>"Martin",
335
- "nameIdentifier"=>
336
- [{"__content__"=>"http://orcid.org/0000-0003-1419-2405",
337
- "nameIdentifierScheme"=>"ORCID",
338
- "schemeUri"=>"https://orcid.org"}]}])
342
+ expect(response).to eq([{ 'creatorName' => { '__content__' => 'Martin Fenner', 'nameType' => 'Personal' },
343
+ 'familyName' => 'Fenner',
344
+ 'givenName' => 'Martin',
345
+ 'nameIdentifier' =>
346
+ [{ '__content__' => 'http://orcid.org/0000-0003-1419-2405',
347
+ 'nameIdentifierScheme' => 'ORCID',
348
+ 'schemeUri' => 'https://orcid.org' }] }])
339
349
  end
340
350
  end
341
351
 
342
- context "to_schema_org_identifiers" do
343
- it "with identifiers" do
344
- identifiers = [{"identifier" => "https://doi.org/10.23725/8na3-9s47", "identifierType" => "DOI"}, {"identifierType"=>"md5", "identifier"=>"3b33f6b9338fccab0901b7d317577ea3"}, {"identifierType"=>"minid", "identifier"=>"ark:/99999/fk41CrU4eszeLUDe"}, {"identifierType"=>"dataguid", "identifier"=>"dg.4503/c3d66dc9-58da-411c-83c4-dd656aa3c4b7"}]
345
- response = subject.to_schema_org_identifiers(identifiers, type: "Dataset")
346
- expect(response).to eq([{"@type"=>"PropertyValue", "propertyID"=>"DOI", "value"=>"https://doi.org/10.23725/8na3-9s47"},
347
- {"@type"=>"PropertyValue",
348
- "propertyID"=>"md5",
349
- "value"=>"3b33f6b9338fccab0901b7d317577ea3"},
350
- {"@type"=>"PropertyValue",
351
- "propertyID"=>"minid",
352
- "value"=>"ark:/99999/fk41CrU4eszeLUDe"},
353
- {"@type"=>"PropertyValue",
354
- "propertyID"=>"dataguid",
355
- "value"=>"dg.4503/c3d66dc9-58da-411c-83c4-dd656aa3c4b7"}])
352
+ context 'to_schema_org_identifiers' do
353
+ it 'with identifiers' do
354
+ identifiers = [
355
+ { 'identifier' => 'https://doi.org/10.23725/8na3-9s47',
356
+ 'identifierType' => 'DOI' }, { 'identifierType' => 'md5', 'identifier' => '3b33f6b9338fccab0901b7d317577ea3' }, { 'identifierType' => 'minid', 'identifier' => 'ark:/99999/fk41CrU4eszeLUDe' }, { 'identifierType' => 'dataguid', 'identifier' => 'dg.4503/c3d66dc9-58da-411c-83c4-dd656aa3c4b7' }
357
+ ]
358
+ response = subject.to_schema_org_identifiers(identifiers, type: 'Dataset')
359
+ expect(response).to eq([{ '@type' => 'PropertyValue', 'propertyID' => 'DOI', 'value' => 'https://doi.org/10.23725/8na3-9s47' },
360
+ { '@type' => 'PropertyValue',
361
+ 'propertyID' => 'md5',
362
+ 'value' => '3b33f6b9338fccab0901b7d317577ea3' },
363
+ { '@type' => 'PropertyValue',
364
+ 'propertyID' => 'minid',
365
+ 'value' => 'ark:/99999/fk41CrU4eszeLUDe' },
366
+ { '@type' => 'PropertyValue',
367
+ 'propertyID' => 'dataguid',
368
+ 'value' => 'dg.4503/c3d66dc9-58da-411c-83c4-dd656aa3c4b7' }])
356
369
  end
357
370
  end
358
371
 
359
- context "sanitize" do
360
- it 'should remove a tags' do
361
- text = "In 1998 <strong>Tim Berners-Lee</strong> coined the term <a href=\"https://www.w3.org/Provider/Style/URI\">cool URIs</a>"
372
+ context 'sanitize' do
373
+ it 'removes a tags' do
374
+ text = 'In 1998 <strong>Tim Berners-Lee</strong> coined the term <a href="https://www.w3.org/Provider/Style/URI">cool URIs</a>'
362
375
  content = subject.sanitize(text)
363
- expect(content).to eq("In 1998 <strong>Tim Berners-Lee</strong> coined the term cool URIs")
376
+ expect(content).to eq('In 1998 <strong>Tim Berners-Lee</strong> coined the term cool URIs')
364
377
  end
365
378
 
366
- it 'should only keep specific tags' do
367
- text = "In 1998 <strong>Tim Berners-Lee</strong> coined the term <a href=\"https://www.w3.org/Provider/Style/URI\">cool URIs</a>"
368
- content = subject.sanitize(text, tags: ["a"])
369
- expect(content).to eq("In 1998 Tim Berners-Lee coined the term <a href=\"https://www.w3.org/Provider/Style/URI\">cool URIs</a>")
379
+ it 'onlies keep specific tags' do
380
+ text = 'In 1998 <strong>Tim Berners-Lee</strong> coined the term <a href="https://www.w3.org/Provider/Style/URI">cool URIs</a>'
381
+ content = subject.sanitize(text, tags: ['a'])
382
+ expect(content).to eq('In 1998 Tim Berners-Lee coined the term <a href="https://www.w3.org/Provider/Style/URI">cool URIs</a>')
370
383
  end
371
384
  end
372
385
 
373
- context "get_datetime_from_time" do
374
- it "present" do
375
- time = "20200226071709"
386
+ context 'get_datetime_from_time' do
387
+ it 'present' do
388
+ time = '20200226071709'
376
389
  response = subject.get_datetime_from_time(time)
377
- expect(response).to eq("2020-02-26T07:17:09Z")
390
+ expect(response).to eq('2020-02-26T07:17:09Z')
378
391
  end
379
392
 
380
- it "past" do
381
- time = "18770312071709"
393
+ it 'past' do
394
+ time = '18770312071709'
382
395
  response = subject.get_datetime_from_time(time)
383
- expect(response).to eq("1877-03-12T07:17:09Z")
396
+ expect(response).to eq('1877-03-12T07:17:09Z')
384
397
  end
385
398
 
386
- it "future" do
387
- time = "20970114071709"
399
+ it 'future' do
400
+ time = '20970114071709'
388
401
  response = subject.get_datetime_from_time(time)
389
- expect(response).to eq("2097-01-14T07:17:09Z")
402
+ expect(response).to eq('2097-01-14T07:17:09Z')
390
403
  end
391
404
 
392
- it "invalid" do
393
- time = "20201587168864794"
405
+ it 'invalid' do
406
+ time = '20201587168864794'
394
407
  response = subject.get_datetime_from_time(time)
395
- expect(response).to be_nil
408
+ expect(response.nil?).to be(true)
396
409
  end
397
410
 
398
- it "nil" do
411
+ it 'nil' do
399
412
  time = nil
400
413
  response = subject.get_datetime_from_time(time)
401
- expect(response).to be_nil
414
+ expect(response.nil?).to be(true)
402
415
  end
403
416
  end
404
417
 
405
- context "get_date_parts" do
406
- it "date" do
407
- date = "2016-12-20"
418
+ context 'get_date_parts' do
419
+ it 'date' do
420
+ date = '2016-12-20'
408
421
  response = subject.get_date_parts(date)
409
- expect(response).to eq("date-parts"=>[[2016, 12, 20]])
422
+ expect(response).to eq('date-parts' => [[2016, 12, 20]])
410
423
  end
411
424
 
412
- it "year-month" do
413
- date = "2016-12"
425
+ it 'year-month' do
426
+ date = '2016-12'
414
427
  response = subject.get_date_parts(date)
415
- expect(response).to eq("date-parts"=>[[2016, 12]])
428
+ expect(response).to eq('date-parts' => [[2016, 12]])
416
429
  end
417
430
 
418
- it "year" do
419
- date = "2016"
431
+ it 'year' do
432
+ date = '2016'
420
433
  response = subject.get_date_parts(date)
421
- expect(response).to eq("date-parts"=>[[2016]])
434
+ expect(response).to eq('date-parts' => [[2016]])
422
435
  end
423
436
  end
424
437
 
425
- context "get_date_from_parts" do
426
- it "date" do
438
+ context 'get_date_from_parts' do
439
+ it 'date' do
427
440
  response = subject.get_date_from_parts(2016, 12, 20)
428
- expect(response).to eq("2016-12-20")
441
+ expect(response).to eq('2016-12-20')
429
442
  end
430
443
 
431
- it "year-month" do
444
+ it 'year-month' do
432
445
  response = subject.get_date_from_parts(2016, 12)
433
- expect(response).to eq("2016-12")
446
+ expect(response).to eq('2016-12')
434
447
  end
435
448
 
436
- it "year" do
449
+ it 'year' do
437
450
  response = subject.get_date_from_parts(2016)
438
- expect(response).to eq("2016")
451
+ expect(response).to eq('2016')
439
452
  end
440
453
  end
441
454
 
442
- context "get_date_from_date_parts" do
443
- it "date" do
444
- date_as_parts = { "date-parts"=>[[2016, 12, 20]] }
455
+ context 'get_date_from_date_parts' do
456
+ it 'date' do
457
+ date_as_parts = { 'date-parts' => [[2016, 12, 20]] }
445
458
  response = subject.get_date_from_date_parts(date_as_parts)
446
- expect(response).to eq("2016-12-20")
459
+ expect(response).to eq('2016-12-20')
447
460
  end
448
461
 
449
- it "year-month" do
450
- date_as_parts = { "date-parts"=>[[2016, 12]] }
462
+ it 'year-month' do
463
+ date_as_parts = { 'date-parts' => [[2016, 12]] }
451
464
  response = subject.get_date_from_date_parts(date_as_parts)
452
- expect(response).to eq("2016-12")
465
+ expect(response).to eq('2016-12')
453
466
  end
454
467
 
455
- it "year" do
456
- date_as_parts = { "date-parts"=>[[2016]] }
468
+ it 'year' do
469
+ date_as_parts = { 'date-parts' => [[2016]] }
457
470
  response = subject.get_date_from_date_parts(date_as_parts)
458
- expect(response).to eq("2016")
471
+ expect(response).to eq('2016')
459
472
  end
460
473
  end
461
474
 
462
- context "get_date" do
463
- it "publication date" do
464
- dates = [{ "date"=>"2016-12-20", "dateType" => "Issued" }]
465
- response = subject.get_date(dates, "Issued")
466
- expect(response).to eq("2016-12-20")
475
+ context 'get_date' do
476
+ it 'publication date' do
477
+ dates = [{ 'date' => '2016-12-20', 'dateType' => 'Issued' }]
478
+ response = subject.get_date(dates, 'Issued')
479
+ expect(response).to eq('2016-12-20')
467
480
  end
468
481
  end
469
482
 
470
- context "get_series_information" do
471
- it "only title" do
483
+ context 'get_series_information' do
484
+ it 'only title' do
472
485
  str = nil
473
486
  response = subject.get_series_information(str)
474
487
  expect(response).to eq({})
475
488
  end
476
489
 
477
- it "only title" do
478
- str = "DataCite Blog"
490
+ it 'only title' do
491
+ str = 'DataCite Blog'
479
492
  response = subject.get_series_information(str)
480
- expect(response).to eq("title"=>"DataCite Blog")
493
+ expect(response).to eq('title' => 'DataCite Blog')
481
494
  end
482
495
 
483
- it "title and pages" do
484
- str = "DataCite Blog, 1-3"
496
+ it 'title and pages' do
497
+ str = 'DataCite Blog, 1-3'
485
498
  response = subject.get_series_information(str)
486
- expect(response).to eq("firstPage"=>"1", "lastPage"=>"3", "title"=>"DataCite Blog")
499
+ expect(response).to eq('firstPage' => '1', 'lastPage' => '3', 'title' => 'DataCite Blog')
487
500
  end
488
501
 
489
- it "title, volume and pages" do
490
- str = "DataCite Blog, 7, 1-3"
502
+ it 'title, volume and pages' do
503
+ str = 'DataCite Blog, 7, 1-3'
491
504
  response = subject.get_series_information(str)
492
- expect(response).to eq("firstPage"=>"1", "lastPage"=>"3", "title"=>"DataCite Blog", "volume"=>"7")
505
+ expect(response).to eq('firstPage' => '1', 'lastPage' => '3', 'title' => 'DataCite Blog',
506
+ 'volume' => '7')
493
507
  end
494
508
 
495
- it "title, volume, issue and pages" do
496
- str = "DataCite Blog, 7(11), 1-3"
509
+ it 'title, volume, issue and pages' do
510
+ str = 'DataCite Blog, 7(11), 1-3'
497
511
  response = subject.get_series_information(str)
498
- expect(response).to eq("firstPage"=>"1", "issue"=>"11", "lastPage"=>"3", "title"=>"DataCite Blog", "volume"=>"7")
512
+ expect(response).to eq('firstPage' => '1', 'issue' => '11', 'lastPage' => '3',
513
+ 'title' => 'DataCite Blog', 'volume' => '7')
499
514
  end
500
515
  end
501
516
 
502
- context "github" do
503
- it "github_from_url" do
504
- url = "https://github.com/datacite/bolognese"
517
+ context 'github' do
518
+ it 'github_from_url' do
519
+ url = 'https://github.com/datacite/bolognese'
505
520
  response = subject.github_from_url(url)
506
- expect(response).to eq(:owner=>"datacite", :repo=>"bolognese")
521
+ expect(response).to eq(owner: 'datacite', repo: 'bolognese')
507
522
  end
508
523
 
509
- it "github_from_url file" do
510
- url = "https://github.com/datacite/metadata-reports/blob/master/software/codemeta.json"
524
+ it 'github_from_url file' do
525
+ url = 'https://github.com/datacite/metadata-reports/blob/master/software/codemeta.json'
511
526
  response = subject.github_from_url(url)
512
- expect(response).to eq(:owner=>"datacite", :repo=>"metadata-reports", :release=>"master", :path=>"software/codemeta.json")
527
+ expect(response).to eq(owner: 'datacite', repo: 'metadata-reports', release: 'master',
528
+ path: 'software/codemeta.json')
513
529
  end
514
530
 
515
- it "github_from_url cff file" do
516
- url = "https://github.com/citation-file-format/ruby-cff/blob/main/CITATION.cff"
531
+ it 'github_from_url cff file' do
532
+ url = 'https://github.com/citation-file-format/ruby-cff/blob/main/CITATION.cff'
517
533
  response = subject.github_from_url(url)
518
- expect(response).to eq(:owner=>"citation-file-format", :path=>"CITATION.cff", :release=>"main", :repo=>"ruby-cff")
534
+ expect(response).to eq(owner: 'citation-file-format', path: 'CITATION.cff',
535
+ release: 'main', repo: 'ruby-cff')
519
536
  end
520
537
 
521
- it "github_as_codemeta_url" do
522
- url = "https://github.com/datacite/bolognese"
538
+ it 'github_as_codemeta_url' do
539
+ url = 'https://github.com/datacite/bolognese'
523
540
  response = subject.github_as_codemeta_url(url)
524
- expect(response).to eq("https://raw.githubusercontent.com/datacite/bolognese/master/codemeta.json")
541
+ expect(response).to eq('https://raw.githubusercontent.com/datacite/bolognese/master/codemeta.json')
525
542
  end
526
543
 
527
- it "github_as_cff_url" do
528
- url = "https://github.com/citation-file-format/ruby-cff"
544
+ it 'github_as_cff_url' do
545
+ url = 'https://github.com/citation-file-format/ruby-cff'
529
546
  response = subject.github_as_cff_url(url)
530
- expect(response).to eq("https://raw.githubusercontent.com/citation-file-format/ruby-cff/main/CITATION.cff")
547
+ expect(response).to eq('https://raw.githubusercontent.com/citation-file-format/ruby-cff/main/CITATION.cff')
531
548
  end
532
549
 
533
- it "github_from_url file" do
534
- url = "https://github.com/datacite/metadata-reports/blob/master/software/codemeta.json"
550
+ it 'github_from_url file' do
551
+ url = 'https://github.com/datacite/metadata-reports/blob/master/software/codemeta.json'
535
552
  response = subject.github_as_codemeta_url(url)
536
- expect(response).to eq("https://raw.githubusercontent.com/datacite/metadata-reports/master/software/codemeta.json")
553
+ expect(response).to eq('https://raw.githubusercontent.com/datacite/metadata-reports/master/software/codemeta.json')
537
554
  end
538
555
  end
539
556
 
540
- context "spdx" do
541
- it "name_to_spdx exists" do
542
- name = "Creative Commons Attribution 4.0 International"
557
+ context 'spdx' do
558
+ it 'name_to_spdx exists' do
559
+ name = 'Creative Commons Attribution 4.0 International'
543
560
  response = subject.name_to_spdx(name)
544
- expect(response).to eq({"rights"=>"Creative Commons Attribution 4.0 International", "rightsUri"=>"https://creativecommons.org/licenses/by/4.0/legalcode", "rightsIdentifier"=>"cc-by-4.0", "rightsIdentifierScheme"=>"SPDX", "schemeUri"=>"https://spdx.org/licenses/"})
561
+ expect(response).to eq({ 'rights' => 'Creative Commons Attribution 4.0 International',
562
+ 'rightsUri' => 'https://creativecommons.org/licenses/by/4.0/legalcode', 'rightsIdentifier' => 'cc-by-4.0', 'rightsIdentifierScheme' => 'SPDX', 'schemeUri' => 'https://spdx.org/licenses/' })
545
563
  end
546
564
 
547
- it "name_to_spdx id" do
548
- name = "CC-BY-4.0"
565
+ it 'name_to_spdx id' do
566
+ name = 'CC-BY-4.0'
549
567
  response = subject.name_to_spdx(name)
550
- expect(response).to eq({"rights"=>"Creative Commons Attribution 4.0 International", "rightsUri"=>"https://creativecommons.org/licenses/by/4.0/legalcode", "rightsIdentifier"=>"cc-by-4.0", "rightsIdentifierScheme"=>"SPDX", "schemeUri"=>"https://spdx.org/licenses/"})
568
+ expect(response).to eq({ 'rights' => 'Creative Commons Attribution 4.0 International',
569
+ 'rightsUri' => 'https://creativecommons.org/licenses/by/4.0/legalcode', 'rightsIdentifier' => 'cc-by-4.0', 'rightsIdentifierScheme' => 'SPDX', 'schemeUri' => 'https://spdx.org/licenses/' })
551
570
  end
552
571
 
553
- it "hsh_to_spdx id" do
554
- hsh = { "rightsIdentifier" => "cc-by-4.0" }
572
+ it 'hsh_to_spdx id' do
573
+ hsh = { 'rightsIdentifier' => 'cc-by-4.0' }
555
574
  response = subject.hsh_to_spdx(hsh)
556
- expect(response).to eq({"rights"=>"Creative Commons Attribution 4.0 International", "rightsUri"=>"https://creativecommons.org/licenses/by/4.0/legalcode", "rightsIdentifier"=>"cc-by-4.0", "rightsIdentifierScheme"=>"SPDX", "schemeUri"=>"https://spdx.org/licenses/"})
575
+ expect(response).to eq({ 'rights' => 'Creative Commons Attribution 4.0 International',
576
+ 'rightsUri' => 'https://creativecommons.org/licenses/by/4.0/legalcode', 'rightsIdentifier' => 'cc-by-4.0', 'rightsIdentifierScheme' => 'SPDX', 'schemeUri' => 'https://spdx.org/licenses/' })
557
577
  end
558
578
 
559
- it "hsh_to_spdx url" do
560
- hsh = { "rightsURI" => "http://creativecommons.org/licenses/by-nc/4.0/legalcode" }
579
+ it 'hsh_to_spdx url' do
580
+ hsh = { 'rightsURI' => 'http://creativecommons.org/licenses/by-nc/4.0/legalcode' }
561
581
  response = subject.hsh_to_spdx(hsh)
562
- expect(response).to eq("rights"=>"Creative Commons Attribution Non Commercial 4.0 International", "rightsUri"=>"https://creativecommons.org/licenses/by-nc/4.0/legalcode", "rightsIdentifier"=>"cc-by-nc-4.0", "rightsIdentifierScheme"=>"SPDX", "schemeUri"=>"https://spdx.org/licenses/")
582
+ expect(response).to eq(
583
+ 'rights' => 'Creative Commons Attribution Non Commercial 4.0 International', 'rightsUri' => 'https://creativecommons.org/licenses/by-nc/4.0/legalcode', 'rightsIdentifier' => 'cc-by-nc-4.0', 'rightsIdentifierScheme' => 'SPDX', 'schemeUri' => 'https://spdx.org/licenses/'
584
+ )
563
585
  end
564
586
 
565
- it "hsh_to_spdx not found" do
566
- hsh = { "rightsURI" => "info:eu-repo/semantics/openAccess" }
587
+ it 'hsh_to_spdx not found' do
588
+ hsh = { 'rightsURI' => 'info:eu-repo/semantics/openAccess' }
567
589
  response = subject.hsh_to_spdx(hsh)
568
- expect(response).to eq({"rightsUri"=>"info:eu-repo/semantics/openAccess"})
590
+ expect(response).to eq({ 'rightsUri' => 'info:eu-repo/semantics/openAccess' })
569
591
  end
570
592
  end
571
593
 
572
- context "fos" do
573
- it "name_to_fos match" do
574
- name = "Biological sciences"
594
+ context 'fos' do
595
+ it 'name_to_fos match' do
596
+ name = 'Biological sciences'
575
597
  response = subject.name_to_fos(name)
576
- expect(response).to eq([{"subject"=>"biological sciences"},
577
- {"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
578
- "subject"=>"FOS: Biological sciences",
579
- "subjectScheme"=>"Fields of Science and Technology (FOS)"}])
598
+ expect(response).to eq([{ 'subject' => 'biological sciences' },
599
+ { 'schemeUri' => 'http://www.oecd.org/science/inno/38235147.pdf',
600
+ 'subject' => 'FOS: Biological sciences',
601
+ 'subjectScheme' => 'Fields of Science and Technology (FOS)' }])
580
602
  end
581
603
 
582
- it "name_to_fos for match" do
583
- name = "Statistics"
604
+ it 'name_to_fos for match' do
605
+ name = 'Statistics'
584
606
  response = subject.name_to_fos(name)
585
- expect(response).to eq([{"subject"=>"statistics"},
586
- {"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
587
- "subject"=>"FOS: Mathematics",
588
- "subjectScheme"=>"Fields of Science and Technology (FOS)"}])
607
+ expect(response).to eq([{ 'subject' => 'statistics' },
608
+ { 'schemeUri' => 'http://www.oecd.org/science/inno/38235147.pdf',
609
+ 'subject' => 'FOS: Mathematics',
610
+ 'subjectScheme' => 'Fields of Science and Technology (FOS)' }])
589
611
  end
590
612
 
591
- it "name_to_fos no match" do
592
- name = "Random tag"
613
+ it 'name_to_fos no match' do
614
+ name = 'Random tag'
593
615
  response = subject.name_to_fos(name)
594
- expect(response).to eq([{"subject"=>"random tag"}])
616
+ expect(response).to eq([{ 'subject' => 'random tag' }])
595
617
  end
596
618
 
597
- it "hsh_to_fos match" do
598
- hsh = { "__content__" => "Biological sciences" }
619
+ it 'hsh_to_fos match' do
620
+ hsh = { '__content__' => 'Biological sciences' }
599
621
  response = subject.hsh_to_fos(hsh)
600
- expect(response).to eq([{"subject"=>"Biological sciences"},
601
- {"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
602
- "subject"=>"FOS: Biological sciences",
603
- "subjectScheme"=>"Fields of Science and Technology (FOS)"}])
622
+ expect(response).to eq([{ 'subject' => 'Biological sciences' },
623
+ { 'schemeUri' => 'http://www.oecd.org/science/inno/38235147.pdf',
624
+ 'subject' => 'FOS: Biological sciences',
625
+ 'subjectScheme' => 'Fields of Science and Technology (FOS)' }])
604
626
  end
605
627
 
606
- it "hsh_to_fos for match" do
607
- hsh = { "__content__" => "Statistics" }
628
+ it 'hsh_to_fos for match' do
629
+ hsh = { '__content__' => 'Statistics' }
608
630
  response = subject.hsh_to_fos(hsh)
609
- expect(response).to eq([{"subject"=>"Statistics"},
610
- {"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
611
- "subject"=>"FOS: Mathematics",
612
- "subjectScheme"=>"Fields of Science and Technology (FOS)"}])
631
+ expect(response).to eq([{ 'subject' => 'Statistics' },
632
+ { 'schemeUri' => 'http://www.oecd.org/science/inno/38235147.pdf',
633
+ 'subject' => 'FOS: Mathematics',
634
+ 'subjectScheme' => 'Fields of Science and Technology (FOS)' }])
613
635
  end
614
636
 
615
- it "hsh_to_fos for with schemeUri in hash" do
637
+ it 'hsh_to_fos for with schemeUri in hash' do
616
638
  hsh = {
617
- "subject" => "FOS: Computer and information sciences",
618
- "subjectScheme" => "Fields of Science and Technology (FOS)",
619
- "schemeUri" => "http://www.oecd.org/science/inno/38235147.pdf"}
639
+ 'subject' => 'FOS: Computer and information sciences',
640
+ 'subjectScheme' => 'Fields of Science and Technology (FOS)',
641
+ 'schemeUri' => 'http://www.oecd.org/science/inno/38235147.pdf'
642
+ }
620
643
  response = subject.hsh_to_fos(hsh)
621
644
  expect(response).to eq([{
622
- "subject" => "FOS: Computer and information sciences",
623
- "subjectScheme" => "Fields of Science and Technology (FOS)",
624
- "schemeUri" => "http://www.oecd.org/science/inno/38235147.pdf"}])
645
+ 'subject' => 'FOS: Computer and information sciences',
646
+ 'subjectScheme' => 'Fields of Science and Technology (FOS)',
647
+ 'schemeUri' => 'http://www.oecd.org/science/inno/38235147.pdf'
648
+ }])
625
649
  end
626
650
 
627
- it "hsh_to_fos no match" do
628
- hsh = { "__content__"=>"Random tag" }
651
+ it 'hsh_to_fos no match' do
652
+ hsh = { '__content__' => 'Random tag' }
629
653
  response = subject.hsh_to_fos(hsh)
630
- expect(response).to eq([{"subject"=>"Random tag"}])
654
+ expect(response).to eq([{ 'subject' => 'Random tag' }])
631
655
  end
632
656
  end
633
657
 
634
- context "random doi" do
635
- it "encode doi" do
636
- prefix = "10.53731"
658
+ context 'random doi' do
659
+ it 'encode doi' do
660
+ prefix = '10.53731'
637
661
  response = subject.encode_doi(prefix)
638
- expect(response).to match(/#{prefix}\/[-._;()\/:A-Za-z0-9]+/)
662
+ expect(response).to match(%r{#{prefix}/[-._;()/:A-Za-z0-9]+})
639
663
  expect(response.length).to eq(40)
640
664
  end
641
665
 
642
- it "decode doi" do
643
- doi = "https://doi.org/10.53731/revzwnv-rpd913d-8drwz"
666
+ it 'decode doi' do
667
+ doi = 'https://doi.org/10.53731/revzwnv-rpd913d-8drwz'
644
668
  response = subject.decode_doi(doi)
645
- expect(response).to eq (30286005717401267192153432991)
669
+ expect(response).to eq(30_286_005_717_401_267_192_153_432_991)
646
670
  end
647
671
 
648
- it "decode anothe doi" do
649
- doi = "https://doi.org/10.53731/rckvde5-tzg61kj-7zvc1"
672
+ it 'decode anothe doi' do
673
+ doi = 'https://doi.org/10.53731/rckvde5-tzg61kj-7zvc1'
650
674
  response = subject.decode_doi(doi)
651
- expect(response).to eq (30198793950250854133601922433)
675
+ expect(response).to eq(30_198_793_950_250_854_133_601_922_433)
652
676
  end
653
677
  end
654
678
  end