commonmeta-ruby 3.2.13 → 3.2.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bac0bef429dfb0d6b215f3e9224dea78c3bae41ecc96dc9aa8c74fb45f14adc9
4
- data.tar.gz: fe9f8e4628fb8ea120f858d24fc803e8183693104be98ffc96c3b608c76ef2ea
3
+ metadata.gz: 43a78bfc4b2f9b77c966597e4593cdfef5f6b3fffc493857b99e224ff94fb70b
4
+ data.tar.gz: 7b95a16aa8de6c5f7ce04352966e0855be5a174175514f77fe9ac82efc85d605
5
5
  SHA512:
6
- metadata.gz: 14422b80a42b7c9093f9ca564486005248f9b2cfcde00a3d7a8f880844e50a62501bf0a516a83fff0a05ee123fe5aa7a990d3f2bc7c1f2d6b1fe25742b0c6dd4
7
- data.tar.gz: 2ed255c095195200bbf1ca9c9c5d9207541a3196df57c3e951c11610ce3e56d19ca2d1f19f446481f66beda29bc7cf5b1a25f6ac611f0102b16f0f02e29c3cbd
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.13)
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.0)
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"].titleize)
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
- # 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"
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.fetch("tags", nil)).reduce([]) do |sum, subject|
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
- sum << reference if [200, 301, 302].include? HTTP.head(reference["doi"] || reference["url"]).status
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.downcase.split(', ') if subjects.is_a?(String)
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
@@ -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).downcase,
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).downcase,
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).downcase }]
1296
+ [{ "subject" => sanitize(name) }]
1294
1297
  end
1295
1298
  end
1296
1299
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Commonmeta
4
- VERSION = '3.2.13'
4
+ VERSION = '3.2.15'
5
5
  end
@@ -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,