commonmeta-ruby 3.2.13 → 3.2.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/commonmeta/crossref_utils.rb +3 -3
- data/lib/commonmeta/readers/json_feed_reader.rb +6 -2
- data/lib/commonmeta/readers/schema_org_reader.rb +1 -1
- data/lib/commonmeta/utils.rb +6 -3
- data/lib/commonmeta/version.rb +1 -1
- data/lib/commonmeta/writers/bibtex_writer.rb +1 -1
- data/lib/commonmeta/writers/ris_writer.rb +1 -1
- data/lib/commonmeta/writers/schema_org_writer.rb +1 -1
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/substack_post_with_broken_reference.yml +1316 -0
- data/spec/readers/cff_reader_spec.rb +33 -33
- data/spec/readers/codemeta_reader_spec.rb +8 -8
- data/spec/readers/json_feed_reader_spec.rb +204 -154
- data/spec/readers/schema_org_reader_spec.rb +38 -38
- data/spec/utils_spec.rb +3 -3
- data/spec/writers/bibtex_writer_spec.rb +3 -3
- data/spec/writers/cff_writer_spec.rb +2 -2
- data/spec/writers/crossref_xml_writer_spec.rb +21 -9
- data/spec/writers/ris_writer_spec.rb +8 -8
- data/spec/writers/schema_org_writer_spec.rb +6 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43a78bfc4b2f9b77c966597e4593cdfef5f6b3fffc493857b99e224ff94fb70b
|
4
|
+
data.tar.gz: 7b95a16aa8de6c5f7ce04352966e0855be5a174175514f77fe9ac82efc85d605
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf12683197ddff178718725b72976b1b2fecef23c2bafff50f9c81b9c29b2da67554937830d60b9860d59d9294d5cd7ccd0e86d15633948758896abf3a8827c5
|
7
|
+
data.tar.gz: e357c0d3871e0fd53e2371e792c487f2ba8895bb789982bddef496830d5aea08f0c571f209d8bcaf0f99365ec245eaf38621d7ad4230a548ab3e6f6ca1a7d7fe
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
commonmeta-ruby (3.2.
|
4
|
+
commonmeta-ruby (3.2.15)
|
5
5
|
activesupport (>= 4.2.5, < 8.0)
|
6
6
|
addressable (~> 2.8.1, < 2.8.2)
|
7
7
|
base32-url (>= 0.7.0, < 1)
|
@@ -121,7 +121,7 @@ GEM
|
|
121
121
|
crass (~> 1.0.2)
|
122
122
|
nokogiri (>= 1.12.0)
|
123
123
|
matrix (0.4.2)
|
124
|
-
minitest (5.18.
|
124
|
+
minitest (5.18.1)
|
125
125
|
multi_json (1.15.0)
|
126
126
|
namae (1.1.1)
|
127
127
|
nokogiri (1.15.2-arm64-darwin)
|
@@ -89,7 +89,7 @@ module Commonmeta
|
|
89
89
|
def insert_group_title(xml)
|
90
90
|
return xml if subjects.blank?
|
91
91
|
|
92
|
-
xml.group_title(subjects.first["subject"]
|
92
|
+
xml.group_title(subjects.first["subject"])
|
93
93
|
end
|
94
94
|
|
95
95
|
def insert_crossref_creators(xml)
|
@@ -264,8 +264,8 @@ module Commonmeta
|
|
264
264
|
"item_number_type" => alternate_identifier["alternateIdentifierType"] ? alternate_identifier["alternateIdentifierType"].downcase : nil,
|
265
265
|
}.compact
|
266
266
|
|
267
|
-
#
|
268
|
-
alternate_identifier["alternateIdentifier"] =
|
267
|
+
# strip hyphen from UUIDs, as item_number can only be 32 characters long (UUIDv4 is 36 characters long)
|
268
|
+
alternate_identifier["alternateIdentifier"] = alternate_identifier["alternateIdentifier"].gsub('-','') if alternate_identifier["alternateIdentifierType"] == "UUID"
|
269
269
|
|
270
270
|
xml.item_number(alternate_identifier["alternateIdentifier"], attributes)
|
271
271
|
end
|
@@ -54,7 +54,7 @@ module Commonmeta
|
|
54
54
|
end
|
55
55
|
language = meta.fetch("language", nil) || meta.dig("blog", "language")
|
56
56
|
state = id.present? || read_options.present? ? "findable" : "not_found"
|
57
|
-
subjects = Array.wrap(meta.
|
57
|
+
subjects = Array.wrap(meta.dig("blog", "category")).reduce([]) do |sum, subject|
|
58
58
|
sum += name_to_fos(subject)
|
59
59
|
|
60
60
|
sum
|
@@ -82,7 +82,11 @@ module Commonmeta
|
|
82
82
|
def get_references(meta)
|
83
83
|
# check that references resolve
|
84
84
|
Array.wrap(meta["references"]).reduce([]) do |sum, reference|
|
85
|
-
|
85
|
+
if reference["doi"] && validate_doi(reference["doi"])
|
86
|
+
sum << reference if [200, 301, 302].include? HTTP.head(reference["doi"]).status
|
87
|
+
elsif reference["url"] && validate_url(reference["url"]) == "URL"
|
88
|
+
sum << reference if [200, 301, 302].include? HTTP.head(reference["url"]).status
|
89
|
+
end
|
86
90
|
|
87
91
|
sum
|
88
92
|
end
|
@@ -208,7 +208,7 @@ module Commonmeta
|
|
208
208
|
|
209
209
|
# handle keywords as array and as comma-separated string
|
210
210
|
subjects = meta.fetch('keywords', nil)
|
211
|
-
subjects = subjects.to_s.
|
211
|
+
subjects = subjects.to_s.split(', ') if subjects.is_a?(String)
|
212
212
|
subjects = Array.wrap(subjects).reduce([]) do |sum, subject|
|
213
213
|
sum += name_to_fos(subject)
|
214
214
|
sum
|
data/lib/commonmeta/utils.rb
CHANGED
@@ -1253,6 +1253,9 @@ module Commonmeta
|
|
1253
1253
|
end
|
1254
1254
|
|
1255
1255
|
def name_to_fos(name)
|
1256
|
+
# make sure name is capitalized
|
1257
|
+
name = name.capitalize
|
1258
|
+
|
1256
1259
|
# first find subject in Fields of Science (OECD)
|
1257
1260
|
fos = JSON.load(File.read(File.expand_path("../../resources/oecd/fos-mappings.json",
|
1258
1261
|
__dir__))).fetch("fosFields")
|
@@ -1261,7 +1264,7 @@ module Commonmeta
|
|
1261
1264
|
|
1262
1265
|
if subject
|
1263
1266
|
return [{
|
1264
|
-
"subject" => sanitize(name)
|
1267
|
+
"subject" => sanitize(name),
|
1265
1268
|
},
|
1266
1269
|
{
|
1267
1270
|
"subject" => "FOS: " + subject["fosLabel"],
|
@@ -1282,7 +1285,7 @@ module Commonmeta
|
|
1282
1285
|
|
1283
1286
|
if subject
|
1284
1287
|
[{
|
1285
|
-
"subject" => sanitize(name)
|
1288
|
+
"subject" => sanitize(name),
|
1286
1289
|
},
|
1287
1290
|
{
|
1288
1291
|
"subject" => "FOS: " + subject["fosLabel"],
|
@@ -1290,7 +1293,7 @@ module Commonmeta
|
|
1290
1293
|
"schemeUri" => "http://www.oecd.org/science/inno/38235147.pdf",
|
1291
1294
|
}]
|
1292
1295
|
else
|
1293
|
-
[{ "subject" => sanitize(name)
|
1296
|
+
[{ "subject" => sanitize(name) }]
|
1294
1297
|
end
|
1295
1298
|
end
|
1296
1299
|
|
data/lib/commonmeta/version.rb
CHANGED
@@ -17,7 +17,7 @@ module Commonmeta
|
|
17
17
|
keywords: if subjects.present?
|
18
18
|
Array.wrap(subjects).map do |k|
|
19
19
|
parse_attributes(k, content: 'subject', first: true)
|
20
|
-
end.join(', ')
|
20
|
+
end.join(', ').capitalize
|
21
21
|
end,
|
22
22
|
language: language,
|
23
23
|
title: parse_attributes(titles, content: 'title', first: true),
|
@@ -15,7 +15,7 @@ module Commonmeta
|
|
15
15
|
'UR' => url,
|
16
16
|
'AB' => parse_attributes(descriptions, content: 'description', first: true),
|
17
17
|
'KW' => Array.wrap(subjects).map do |k|
|
18
|
-
parse_attributes(k, content: 'subject', first: true)
|
18
|
+
parse_attributes(k, content: 'subject', first: true).capitalize
|
19
19
|
end.presence,
|
20
20
|
'PY' => date['published'] && date['published'].split('-').first,
|
21
21
|
'PB' => publisher['name'],
|
@@ -19,7 +19,7 @@ module Commonmeta
|
|
19
19
|
'keywords' => if subjects.present?
|
20
20
|
Array.wrap(subjects).map do |k|
|
21
21
|
parse_attributes(k, content: 'subject', first: true)
|
22
|
-
end.join(', ')
|
22
|
+
end.join(', ').capitalize
|
23
23
|
end,
|
24
24
|
'inLanguage' => language,
|
25
25
|
'contentSize' => Array.wrap(sizes).unwrap,
|