commonmeta-ruby 3.2.8 → 3.2.10
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -3
- data/commonmeta.gemspec +1 -1
- data/lib/commonmeta/crossref_utils.rb +79 -81
- data/lib/commonmeta/utils.rb +14 -6
- data/lib/commonmeta/version.rb +1 -1
- data/spec/utils_spec.rb +15 -0
- data/spec/writers/crossref_xml_writer_spec.rb +3 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7def7640d11d8d88a8a9fb8b18394cd88d5de57e44832c9b05d7c23213857970
|
|
4
|
+
data.tar.gz: 9adc93a35e9c9060ddd3bda1bb859e88f45a00d31454af13c54b54d4c96209b8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61ab2849532d1967e78111a68eec7c4ece6c1cbb968ae705fde933e11dab50079a4f441a4ab4c3acfe2e6d5e9d76dd1496d7b2092244cde2e5a0d588c8747b0d
|
|
7
|
+
data.tar.gz: cd470bf78ce018a78d89133ec5e17ab5dc6f3f35f982cc0e26736b24661bb316b6b9491e93ff897d98773ab027264b4532d367da2c03e546331ee20600c12a24
|
data/Gemfile.lock
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
commonmeta-ruby (3.2.
|
|
4
|
+
commonmeta-ruby (3.2.10)
|
|
5
5
|
activesupport (>= 4.2.5, < 8.0)
|
|
6
6
|
addressable (~> 2.8.1, < 2.8.2)
|
|
7
|
-
base32-url (>= 0.
|
|
7
|
+
base32-url (>= 0.7.0, < 1)
|
|
8
8
|
bibtex-ruby (~> 6.0)
|
|
9
9
|
builder (~> 3.2, >= 3.2.4)
|
|
10
10
|
citeproc-ruby (~> 2.0)
|
|
@@ -34,7 +34,8 @@ GEM
|
|
|
34
34
|
addressable (2.8.1)
|
|
35
35
|
public_suffix (>= 2.0.2, < 6.0)
|
|
36
36
|
ast (2.4.2)
|
|
37
|
-
base32-url (0.
|
|
37
|
+
base32-url (0.7.0)
|
|
38
|
+
uuidtools (~> 2.1, >= 2.1.5)
|
|
38
39
|
bibtex-ruby (6.0.0)
|
|
39
40
|
latex-decode (~> 0.0)
|
|
40
41
|
builder (3.2.4)
|
|
@@ -241,6 +242,7 @@ GEM
|
|
|
241
242
|
unf_ext (0.0.8.2)
|
|
242
243
|
unicode-display_width (2.4.2)
|
|
243
244
|
unicode-types (1.8.0)
|
|
245
|
+
uuidtools (2.2.0)
|
|
244
246
|
vcr (6.1.0)
|
|
245
247
|
webmock (3.18.1)
|
|
246
248
|
addressable (>= 2.8.0)
|
data/commonmeta.gemspec
CHANGED
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
|
20
20
|
# Declare dependencies here, rather than in the Gemfile
|
|
21
21
|
s.add_dependency 'activesupport', '>= 4.2.5', '< 8.0'
|
|
22
22
|
s.add_dependency 'addressable', '~> 2.8.1', '< 2.8.2'
|
|
23
|
-
s.add_dependency 'base32-url', '>= 0.
|
|
23
|
+
s.add_dependency 'base32-url', '>= 0.7.0', '< 1'
|
|
24
24
|
s.add_dependency 'bibtex-ruby', '~> 6.0'
|
|
25
25
|
s.add_dependency 'builder', '~> 3.2', '>= 3.2.4'
|
|
26
26
|
s.add_dependency 'citeproc-ruby', '~> 2.0'
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
module Commonmeta
|
|
4
4
|
module CrossrefUtils
|
|
5
5
|
def write_crossref_xml
|
|
6
|
-
@crossref_xml ||= Nokogiri::XML::Builder.new(encoding:
|
|
6
|
+
@crossref_xml ||= Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
|
|
7
7
|
xml.doi_batch(crossref_root_attributes) do
|
|
8
8
|
xml.head do
|
|
9
9
|
# we use a uuid as batch_id
|
|
10
10
|
xml.doi_batch_id(SecureRandom.uuid)
|
|
11
|
-
xml.timestamp(Time.now.utc.strftime(
|
|
11
|
+
xml.timestamp(Time.now.utc.strftime("%Y%m%d%H%M%S"))
|
|
12
12
|
xml.depositor do
|
|
13
13
|
xml.depositor_name(depositor)
|
|
14
14
|
xml.email_address(email)
|
|
@@ -23,12 +23,12 @@ module Commonmeta
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def crossref_errors(xml: nil)
|
|
26
|
-
filepath = File.expand_path(
|
|
27
|
-
File.open(filepath,
|
|
26
|
+
filepath = File.expand_path("../../resources/crossref/crossref5.3.1.xsd", __dir__)
|
|
27
|
+
File.open(filepath, "r") do |f|
|
|
28
28
|
schema = Nokogiri::XML::Schema(f)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
schema.validate(Nokogiri::XML(xml, nil,
|
|
31
|
+
schema.validate(Nokogiri::XML(xml, nil, "UTF-8")).map(&:to_s).unwrap
|
|
32
32
|
rescue Nokogiri::XML::SyntaxError => e
|
|
33
33
|
e.message
|
|
34
34
|
end
|
|
@@ -37,9 +37,9 @@ module Commonmeta
|
|
|
37
37
|
return xml if doi_from_url(id).blank?
|
|
38
38
|
|
|
39
39
|
case type
|
|
40
|
-
when
|
|
40
|
+
when "JournalArticle"
|
|
41
41
|
insert_journal(xml)
|
|
42
|
-
when
|
|
42
|
+
when "Article"
|
|
43
43
|
insert_posted_content(xml)
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -47,21 +47,21 @@ module Commonmeta
|
|
|
47
47
|
def insert_journal(xml)
|
|
48
48
|
xml.journal do
|
|
49
49
|
if language.present?
|
|
50
|
-
xml.journal_metadata(
|
|
51
|
-
xml.full_title(container[
|
|
50
|
+
xml.journal_metadata("language" => language[0..1]) do
|
|
51
|
+
xml.full_title(container["title"])
|
|
52
52
|
end
|
|
53
53
|
else
|
|
54
54
|
xml.journal_metadata do
|
|
55
|
-
xml.full_title(container[
|
|
55
|
+
xml.full_title(container["title"])
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
|
-
xml.journal_article(
|
|
58
|
+
xml.journal_article("publication_type" => "full_text") do
|
|
59
59
|
insert_crossref_titles(xml)
|
|
60
60
|
insert_crossref_creators(xml)
|
|
61
61
|
insert_crossref_publication_date(xml)
|
|
62
62
|
insert_crossref_abstract(xml)
|
|
63
63
|
insert_crossref_issn(xml)
|
|
64
|
-
|
|
64
|
+
insert_item_number(xml)
|
|
65
65
|
insert_crossref_access_indicators(xml)
|
|
66
66
|
insert_doi_data(xml)
|
|
67
67
|
insert_citation_list(xml)
|
|
@@ -70,7 +70,7 @@ module Commonmeta
|
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
def insert_posted_content(xml)
|
|
73
|
-
posted_content = {
|
|
73
|
+
posted_content = { "type" => "other", "language" => language ? language[0..1] : nil }.compact
|
|
74
74
|
|
|
75
75
|
xml.posted_content(posted_content) do
|
|
76
76
|
insert_group_title(xml)
|
|
@@ -78,7 +78,7 @@ module Commonmeta
|
|
|
78
78
|
insert_crossref_titles(xml)
|
|
79
79
|
insert_posted_date(xml)
|
|
80
80
|
insert_institution(xml)
|
|
81
|
-
|
|
81
|
+
insert_item_number(xml)
|
|
82
82
|
insert_crossref_abstract(xml)
|
|
83
83
|
insert_crossref_access_indicators(xml)
|
|
84
84
|
insert_doi_data(xml)
|
|
@@ -89,14 +89,14 @@ module Commonmeta
|
|
|
89
89
|
def insert_group_title(xml)
|
|
90
90
|
return xml if subjects.blank?
|
|
91
91
|
|
|
92
|
-
xml.group_title(subjects.first[
|
|
92
|
+
xml.group_title(subjects.first["subject"].titleize)
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
def insert_crossref_creators(xml)
|
|
96
96
|
xml.contributors do
|
|
97
97
|
Array.wrap(creators).each_with_index do |person, index|
|
|
98
|
-
xml.person_name(
|
|
99
|
-
|
|
98
|
+
xml.person_name("contributor_role" => "author",
|
|
99
|
+
"sequence" => index.zero? ? "first" : "additional") do
|
|
100
100
|
insert_crossref_person(xml, person)
|
|
101
101
|
end
|
|
102
102
|
end
|
|
@@ -104,15 +104,15 @@ module Commonmeta
|
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
def insert_crossref_person(xml, person)
|
|
107
|
-
xml.given_name(person[
|
|
108
|
-
xml.surname(person[
|
|
109
|
-
if person.dig(
|
|
110
|
-
xml.ORCID(person.dig(
|
|
107
|
+
xml.given_name(person["givenName"]) if person["givenName"].present?
|
|
108
|
+
xml.surname(person["familyName"]) if person["familyName"].present?
|
|
109
|
+
if person.dig("id") && URI.parse(person.dig("id")).host == "orcid.org"
|
|
110
|
+
xml.ORCID(person.dig("id"))
|
|
111
111
|
end
|
|
112
|
-
Array.wrap(person[
|
|
113
|
-
attributes = {
|
|
114
|
-
|
|
115
|
-
xml.affiliation(affiliation[
|
|
112
|
+
Array.wrap(person["affiliation"]).each do |affiliation|
|
|
113
|
+
attributes = { "affiliationIdentifier" => affiliation["affiliationIdentifier"],
|
|
114
|
+
"affiliationIdentifierScheme" => affiliation["affiliationIdentifierScheme"], "schemeURI" => affiliation["schemeUri"] }.compact
|
|
115
|
+
xml.affiliation(affiliation["name"], attributes)
|
|
116
116
|
end
|
|
117
117
|
end
|
|
118
118
|
|
|
@@ -120,7 +120,7 @@ module Commonmeta
|
|
|
120
120
|
xml.titles do
|
|
121
121
|
Array.wrap(titles).each do |title|
|
|
122
122
|
if title.is_a?(Hash)
|
|
123
|
-
xml.title(title[
|
|
123
|
+
xml.title(title["title"])
|
|
124
124
|
else
|
|
125
125
|
xml.title(title)
|
|
126
126
|
end
|
|
@@ -131,15 +131,15 @@ module Commonmeta
|
|
|
131
131
|
def insert_citation_list(xml)
|
|
132
132
|
xml.citation_list do
|
|
133
133
|
Array.wrap(references).each do |ref|
|
|
134
|
-
xml.citation(
|
|
135
|
-
xml.journal_article(ref[
|
|
136
|
-
xml.author(ref[
|
|
137
|
-
xml.volume(ref[
|
|
138
|
-
xml.first_page(ref[
|
|
139
|
-
xml.cYear(ref[
|
|
140
|
-
xml.article_title(ref[
|
|
141
|
-
xml.doi(doi_from_url(ref[
|
|
142
|
-
xml.unstructured_citation(ref[
|
|
134
|
+
xml.citation("key" => ref["key"]) do
|
|
135
|
+
xml.journal_article(ref["journal_title"]) if ref["journal_title"].present?
|
|
136
|
+
xml.author(ref["author"]) if ref["author"].present?
|
|
137
|
+
xml.volume(ref["volume"]) if ref["volume"].present?
|
|
138
|
+
xml.first_page(ref["first_page"]) if ref["first_page"].present?
|
|
139
|
+
xml.cYear(ref["cYear"]) if ref["cYear"].present?
|
|
140
|
+
xml.article_title(ref["article_title"]) if ref["article_title"].present?
|
|
141
|
+
xml.doi(doi_from_url(ref["doi"])) if ref["doi"].present?
|
|
142
|
+
xml.unstructured_citation(ref["url"]) if ref["url"].present?
|
|
143
143
|
end
|
|
144
144
|
end
|
|
145
145
|
end
|
|
@@ -163,12 +163,12 @@ module Commonmeta
|
|
|
163
163
|
def insert_crossref_access_indicators(xml)
|
|
164
164
|
return xml if license.blank?
|
|
165
165
|
|
|
166
|
-
rights_uri = license[
|
|
166
|
+
rights_uri = license["url"]
|
|
167
167
|
|
|
168
|
-
xml.program(
|
|
169
|
-
|
|
170
|
-
xml.license_ref(rights_uri,
|
|
171
|
-
xml.license_ref(rights_uri,
|
|
168
|
+
xml.program("xmlns" => "http://www.crossref.org/AccessIndicators.xsd",
|
|
169
|
+
"name" => "AccessIndicators") do
|
|
170
|
+
xml.license_ref(rights_uri, "applies_to" => "vor")
|
|
171
|
+
xml.license_ref(rights_uri, "applies_to" => "tdm")
|
|
172
172
|
end
|
|
173
173
|
end
|
|
174
174
|
|
|
@@ -204,7 +204,7 @@ module Commonmeta
|
|
|
204
204
|
xml.subjects do
|
|
205
205
|
subjects.each do |subject|
|
|
206
206
|
if subject.is_a?(Hash)
|
|
207
|
-
xml.subject(subject[
|
|
207
|
+
xml.subject(subject["subject"])
|
|
208
208
|
else
|
|
209
209
|
xml.subject(subject)
|
|
210
210
|
end
|
|
@@ -225,11 +225,11 @@ module Commonmeta
|
|
|
225
225
|
end
|
|
226
226
|
|
|
227
227
|
def insert_crossref_publication_date(xml)
|
|
228
|
-
return xml if date[
|
|
228
|
+
return xml if date["registered"].blank?
|
|
229
229
|
|
|
230
|
-
date_ = get_datetime_from_iso8601(date[
|
|
230
|
+
date_ = get_datetime_from_iso8601(date["registered"])
|
|
231
231
|
|
|
232
|
-
xml.publication_date(
|
|
232
|
+
xml.publication_date("media_type" => "online") do
|
|
233
233
|
xml.month(date_.month) if date_.month.present?
|
|
234
234
|
xml.day(date_.day) if date_.day.present?
|
|
235
235
|
xml.year(date_.year) if date_.year.present?
|
|
@@ -237,9 +237,9 @@ module Commonmeta
|
|
|
237
237
|
end
|
|
238
238
|
|
|
239
239
|
def insert_posted_date(xml)
|
|
240
|
-
return xml if date[
|
|
240
|
+
return xml if date["published"].blank?
|
|
241
241
|
|
|
242
|
-
date_ = get_datetime_from_iso8601(date[
|
|
242
|
+
date_ = get_datetime_from_iso8601(date["published"])
|
|
243
243
|
|
|
244
244
|
xml.posted_date do
|
|
245
245
|
xml.month(date_.month) if date_.month.present?
|
|
@@ -252,24 +252,22 @@ module Commonmeta
|
|
|
252
252
|
return xml if publisher.blank?
|
|
253
253
|
|
|
254
254
|
xml.institution do
|
|
255
|
-
xml.institution_name(publisher[
|
|
255
|
+
xml.institution_name(publisher["name"])
|
|
256
256
|
end
|
|
257
257
|
end
|
|
258
258
|
|
|
259
|
-
def
|
|
259
|
+
def insert_item_number(xml)
|
|
260
260
|
return xml if alternate_identifiers.blank?
|
|
261
261
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}.compact
|
|
267
|
-
|
|
268
|
-
# remove dashes from UUIDs, as item_number can only be 32 characters long
|
|
269
|
-
alternate_identifier['alternateIdentifier'].gsub!('-', '') if alternate_identifier['alternateIdentifierType'] == 'UUID'
|
|
262
|
+
alternate_identifiers.each do |alternate_identifier|
|
|
263
|
+
attributes = {
|
|
264
|
+
"item_number_type" => alternate_identifier["alternateIdentifierType"] ? alternate_identifier["alternateIdentifierType"].downcase : nil,
|
|
265
|
+
}.compact
|
|
270
266
|
|
|
271
|
-
|
|
272
|
-
|
|
267
|
+
# convert UUIDs into base32 encoded strings, as item_number can only be 32 characters long (UUIDv4 is 36 characters long)
|
|
268
|
+
alternate_identifier["alternateIdentifier"] = Base32::URL.encode_uuid(alternate_identifier["alternateIdentifier"], split: 7, checksum: true) if alternate_identifier["alternateIdentifierType"] == "UUID"
|
|
269
|
+
|
|
270
|
+
xml.item_number(alternate_identifier["alternateIdentifier"], attributes)
|
|
273
271
|
end
|
|
274
272
|
end
|
|
275
273
|
|
|
@@ -279,9 +277,9 @@ module Commonmeta
|
|
|
279
277
|
xml.doi_data do
|
|
280
278
|
xml.doi(doi_from_url(id).downcase)
|
|
281
279
|
xml.resource(url)
|
|
282
|
-
xml.collection(
|
|
280
|
+
xml.collection("property" => "text-mining") do
|
|
283
281
|
xml.item do
|
|
284
|
-
xml.resource(url,
|
|
282
|
+
xml.resource(url, "mime_type" => "text/html")
|
|
285
283
|
end
|
|
286
284
|
end
|
|
287
285
|
end
|
|
@@ -296,26 +294,26 @@ module Commonmeta
|
|
|
296
294
|
r = rights
|
|
297
295
|
else
|
|
298
296
|
r = {}
|
|
299
|
-
r[
|
|
300
|
-
r[
|
|
297
|
+
r["rights"] = rights
|
|
298
|
+
r["rightsUri"] = normalize_id(rights)
|
|
301
299
|
end
|
|
302
300
|
|
|
303
301
|
attributes = {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
302
|
+
"rightsURI" => r["rightsUri"],
|
|
303
|
+
"rightsIdentifier" => r["rightsIdentifier"],
|
|
304
|
+
"rightsIdentifierScheme" => r["rightsIdentifierScheme"],
|
|
305
|
+
"schemeURI" => r["schemeUri"],
|
|
306
|
+
"xml:lang" => r["lang"],
|
|
309
307
|
}.compact
|
|
310
308
|
|
|
311
|
-
xml.rights(r[
|
|
309
|
+
xml.rights(r["rights"], attributes)
|
|
312
310
|
end
|
|
313
311
|
end
|
|
314
312
|
|
|
315
313
|
def insert_crossref_issn(xml)
|
|
316
|
-
issn = if container.to_h.fetch(
|
|
317
|
-
|
|
318
|
-
|
|
314
|
+
issn = if container.to_h.fetch("identifierType", nil) == "ISSN"
|
|
315
|
+
container.to_h.fetch("identifier", nil)
|
|
316
|
+
end
|
|
319
317
|
|
|
320
318
|
return xml if issn.blank?
|
|
321
319
|
|
|
@@ -329,22 +327,22 @@ module Commonmeta
|
|
|
329
327
|
d = descriptions.first
|
|
330
328
|
else
|
|
331
329
|
d = {}
|
|
332
|
-
d[
|
|
330
|
+
d["description"] = descriptions.first
|
|
333
331
|
end
|
|
334
332
|
|
|
335
|
-
xml.abstract(
|
|
336
|
-
xml.p(d[
|
|
333
|
+
xml.abstract("xmlns" => "http://www.ncbi.nlm.nih.gov/JATS1") do
|
|
334
|
+
xml.p(d["description"])
|
|
337
335
|
end
|
|
338
336
|
end
|
|
339
337
|
|
|
340
338
|
def crossref_root_attributes
|
|
341
|
-
{ 'xmlns:xsi':
|
|
342
|
-
'xsi:schemaLocation':
|
|
343
|
-
xmlns:
|
|
344
|
-
'xmlns:jats':
|
|
345
|
-
'xmlns:fr':
|
|
346
|
-
'xmlns:mml':
|
|
347
|
-
version:
|
|
339
|
+
{ 'xmlns:xsi': "http://www.w3.org/2001/XMLSchema-instance",
|
|
340
|
+
'xsi:schemaLocation': "http://www.crossref.org/schema/5.3.1 https://www.crossref.org/schemas/crossref5.3.1.xsd",
|
|
341
|
+
xmlns: "http://www.crossref.org/schema/5.3.1",
|
|
342
|
+
'xmlns:jats': "http://www.ncbi.nlm.nih.gov/JATS1",
|
|
343
|
+
'xmlns:fr': "http://www.crossref.org/fundref.xsd",
|
|
344
|
+
'xmlns:mml': "http://www.w3.org/1998/Math/MathML",
|
|
345
|
+
version: "5.3.1" }
|
|
348
346
|
end
|
|
349
347
|
end
|
|
350
348
|
end
|
data/lib/commonmeta/utils.rb
CHANGED
|
@@ -1367,19 +1367,27 @@ module Commonmeta
|
|
|
1367
1367
|
end
|
|
1368
1368
|
end
|
|
1369
1369
|
|
|
1370
|
-
def encode_doi(prefix)
|
|
1370
|
+
def encode_doi(prefix, options = {})
|
|
1371
1371
|
# DOI suffix is a generated from a random number, encoded in base32
|
|
1372
1372
|
# suffix has 8 digits plus two checksum digits. With base32 there are
|
|
1373
1373
|
# 32 possible digits, so 8 digits gives 32^8 possible combinations
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1374
|
+
if options[:uuid]
|
|
1375
|
+
str = Base32::URL.encode_uuid(options[:uuid], split: 7, checksum: true)
|
|
1376
|
+
else
|
|
1377
|
+
random_int = SecureRandom.random_number(32 ** 7..(32 ** 8) - 1)
|
|
1378
|
+
suffix = Base32::URL.encode(random_int, checksum: true)
|
|
1379
|
+
str = "#{suffix[0, 5]}-#{suffix[5, 10]}"
|
|
1380
|
+
end
|
|
1377
1381
|
"https://doi.org/#{prefix}/#{str}"
|
|
1378
1382
|
end
|
|
1379
1383
|
|
|
1380
|
-
def decode_doi(doi)
|
|
1384
|
+
def decode_doi(doi, options = {})
|
|
1381
1385
|
suffix = doi.split("/", 5).last
|
|
1382
|
-
|
|
1386
|
+
if options[:uuid]
|
|
1387
|
+
Base32::URL.decode_uuid(suffix)
|
|
1388
|
+
else
|
|
1389
|
+
Base32::URL.decode(suffix)
|
|
1390
|
+
end
|
|
1383
1391
|
end
|
|
1384
1392
|
|
|
1385
1393
|
def encode_container_id
|
data/lib/commonmeta/version.rb
CHANGED
data/spec/utils_spec.rb
CHANGED
|
@@ -650,6 +650,15 @@ describe Commonmeta::Metadata, vcr: true do
|
|
|
650
650
|
expect(response.length).to eq(36)
|
|
651
651
|
end
|
|
652
652
|
|
|
653
|
+
it "encode doi from uuid" do
|
|
654
|
+
prefix = "10.53731"
|
|
655
|
+
uuid = "c3095752-2af0-40a4-a229-3ceb7424bce2"
|
|
656
|
+
response = subject.encode_doi(prefix, uuid: uuid)
|
|
657
|
+
puts response
|
|
658
|
+
expect(response).to match(%r{#{prefix}/[a-z0-9]+})
|
|
659
|
+
expect(response.length).to eq(56)
|
|
660
|
+
end
|
|
661
|
+
|
|
653
662
|
it "decode doi" do
|
|
654
663
|
doi = "https://doi.org/10.53731/revzwnv-rpd913d-8drwz"
|
|
655
664
|
response = subject.decode_doi(doi)
|
|
@@ -661,6 +670,12 @@ describe Commonmeta::Metadata, vcr: true do
|
|
|
661
670
|
response = subject.decode_doi(doi)
|
|
662
671
|
expect(response).to eq(30_198_793_950_250_854_133_601_922_433)
|
|
663
672
|
end
|
|
673
|
+
|
|
674
|
+
it "decode doi to uuid" do
|
|
675
|
+
doi = "https://doi.org/10.53731/6315bn4-aqg82ja-4a9wxdt-29f7279"
|
|
676
|
+
response = subject.decode_doi(doi, uuid: true)
|
|
677
|
+
expect(response).to eq('255d48ab-c102-9288-a4f3-add092f388e9')
|
|
678
|
+
end
|
|
664
679
|
end
|
|
665
680
|
|
|
666
681
|
context "random id" do
|
|
@@ -191,6 +191,7 @@ describe Commonmeta::Metadata, vcr: true do
|
|
|
191
191
|
"person_name")).first).to eq("ORCID" => "https://orcid.org/0000-0001-9165-2757", "contributor_role" => "author", "given_name" => "Esha", "sequence" => "first", "surname" => "Datta")
|
|
192
192
|
expect(crossref_xml.dig("titles",
|
|
193
193
|
"title")).to eq("Attempts at automating journal subject classification")
|
|
194
|
+
expect(crossref_xml.dig('item_number')).to eq("__content__"=>"2x2kzts-edc9rgb-vg6s4j6-z9t0d56", "item_number_type"=>"uuid")
|
|
194
195
|
end
|
|
195
196
|
|
|
196
197
|
it "json_feed_item with references" do
|
|
@@ -218,7 +219,7 @@ describe Commonmeta::Metadata, vcr: true do
|
|
|
218
219
|
"title")).to eq("The Research Software Alliance (ReSA)")
|
|
219
220
|
expect(crossref_xml.dig("citation_list", "citation").length).to eq(11)
|
|
220
221
|
expect(crossref_xml.dig("citation_list", "citation").last).to eq("doi"=>"10.5281/zenodo.3699950", "key"=>"ref11")
|
|
221
|
-
expect(crossref_xml.dig('
|
|
222
|
+
expect(crossref_xml.dig('item_number')).to eq("__content__"=>"4n9y0kg-3pd8288-fheey4m-qy53g93", "item_number_type"=>"uuid")
|
|
222
223
|
end
|
|
223
224
|
|
|
224
225
|
it "json_feed_item from rogue scholar with doi" do
|
|
@@ -242,6 +243,7 @@ describe Commonmeta::Metadata, vcr: true do
|
|
|
242
243
|
"person_name")).first).to eq("ORCID"=>"https://orcid.org/0000-0003-3334-2771", "contributor_role"=>"author", "given_name"=>"Heinz", "sequence"=>"first", "surname"=>"Pampel")
|
|
243
244
|
expect(crossref_xml.dig("titles",
|
|
244
245
|
"title")).to eq("EU-Mitgliedstaaten betonen die Rolle von wissenschaftsgeleiteten Open-Access-Modellen jenseits von APCs")
|
|
246
|
+
expect(crossref_xml.dig('item_number')).to eq("__content__"=>"way2ng-4s48j9v-hbw4rjf-aqh9f33", "item_number_type"=>"uuid")
|
|
245
247
|
end
|
|
246
248
|
end
|
|
247
249
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: commonmeta-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.2.
|
|
4
|
+
version: 3.2.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Martin Fenner
|
|
@@ -56,7 +56,7 @@ dependencies:
|
|
|
56
56
|
requirements:
|
|
57
57
|
- - ">="
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: 0.
|
|
59
|
+
version: 0.7.0
|
|
60
60
|
- - "<"
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
62
|
version: '1'
|
|
@@ -66,7 +66,7 @@ dependencies:
|
|
|
66
66
|
requirements:
|
|
67
67
|
- - ">="
|
|
68
68
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: 0.
|
|
69
|
+
version: 0.7.0
|
|
70
70
|
- - "<"
|
|
71
71
|
- !ruby/object:Gem::Version
|
|
72
72
|
version: '1'
|