uc3-dmp-id 0.1.12 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3f3549ad23c4656916e7e6daf8f9152eb755d46279b7a3b689a26dd7d02d26b
4
- data.tar.gz: 41a955d7b0e97e1094be9fd9d80b8f7ca45d17b901464aaae6816d09b757aa5a
3
+ metadata.gz: 7ae3b97965d06d3157328d0c23441eb32b63013b52d78f631cb8bd5a9459eebd
4
+ data.tar.gz: 4d731209d7649e2ed868d00cb7f69b061545edd75f36b73e7e0356aadae34a41
5
5
  SHA512:
6
- metadata.gz: 2dd968c76f1e6fc0af048385872b93d7b3764b0f11bbfd7925c23233235b61b83a6678daec0544dcf6f0625797733b2de04e98691aff56359228caca849b1269
7
- data.tar.gz: be3757e058012feaa9d9f0e11c0b0a75730031ad80f76793bb6f916247bff4c60f001bec49db41466e9aacc8a3b8dbbfcde303b73e5849855b119413fe202bc4
6
+ metadata.gz: 236e174f59feb0b53bf812c7baf81eaa505e041e01fc9e5b5a689f402b746c9b53652aff506742a1210b9265e5341119d1e52d816e2fce99fac58e59132cf427
7
+ data.tar.gz: 3daabef6a600a9b490100b6a09db742c7e44e28368a9e936914371b34d25c8f2df996fbe3a19577cb64973c8f5a38a4c2d784563ceed4acd147779785277ee4b
@@ -36,17 +36,18 @@ module Uc3DmpId
36
36
  def add_modifications(works:)
37
37
  mod_hash = _generate_mod_header
38
38
 
39
- works.fetch('publications', []).each do |publication|
40
- # Skip the entry if we already know about this identifier
41
- next if @known_works.include?(publication['id'])
42
-
43
- work_hash = _work_to_mod_entry(type: 'publication', work: publication)
44
- mod_hash.fetch('dmproadmap_related_identifiers', []) << work_hash unless work_hash.nil?
45
- fundings = publication.fetch('fundingReferences', [])
46
- next unless fundings.any?
47
-
48
- award_hash = fundings.map { |funding| _funding_to_mod_entry(work: publication, funding:) }
49
- mod_hash.fetch('funding', []) << award_hash unless award_hash.nil?
39
+ %w[publications datasets softwares].each do |work_type|
40
+ works.fetch(work_type, []).each do |work|
41
+ next if @known_works.include?(work['id'])
42
+
43
+ work_hash = _work_to_mod_entry(type: work_type[0..work_type.length - 2], work:)
44
+ mod_hash.fetch('dmproadmap_related_identifiers', []) << work_hash unless work_hash.nil?
45
+ fundings = publication.fetch('fundingReferences', [])
46
+ next unless fundings.any?
47
+
48
+ award_hash = fundings.map { |funding| _funding_to_mod_entry(work:, funding:) }
49
+ mod_hash.fetch('funding', []) << award_hash unless award_hash.nil?
50
+ end
50
51
  end
51
52
  return 0 unless mod_hash['dmproadmap_related_identifiers'].any? || mod_hash.fetch('funding', []).any?
52
53
 
@@ -107,7 +108,7 @@ module Uc3DmpId
107
108
  return nil unless funding.is_a?(Hash) && (!funding['awardUri'] || !funding['awardNumber'])
108
109
  return nil if @known_awards.include?(funding['awardUri']) || @known_awards.include?(funding['awardNumber'])
109
110
 
110
- id = funding['awardUri'] if funding.fetch('awardUri', '').start_with?('http')
111
+ id = funding['awardUri'] if funding.fetch('awardUri', '')&.start_with?('http')
111
112
  id = funding['awardNumber'] if id.nil?
112
113
 
113
114
  ret = {
@@ -116,16 +117,11 @@ module Uc3DmpId
116
117
  score: work['score'],
117
118
  notes: work['notes'],
118
119
  name: funding['funderName'],
119
- funding_status: 'granted',
120
- grant_id: {
121
- type: if id.start_with?('http')
122
- id.include?('doi') ? 'doi' : 'url'
123
- else
124
- 'other'
125
- end,
126
- identifier: id
127
- }
120
+ funding_status: id.nil? ? 'planned' : 'granted'
128
121
  }
122
+ id_type = id.start_with?('http') ? (id.include?('doi') ? 'doi' : 'url') : 'other' unless id.nil?
123
+ ret[:grant_id] = { type: id_type, identifier: id } unless id.nil?
124
+
129
125
  funder_id = funding['funderIdentifier']
130
126
  @logger&.debug(message: "Assessing Work: #{work['id']} (pre funder_id)", details: ret)
131
127
  return JSON.parse(ret.to_json) if funder_id.nil?
@@ -143,7 +143,7 @@ module Uc3DmpId
143
143
  @details_hash[:identifiers] << grant&.split('/')&.last&.downcase&.strip
144
144
  @details_hash[:identifiers] << opportunity&.downcase&.strip
145
145
 
146
- @details_hash[:funder_names] << funding['name']&.downcase&.strip
146
+ @details_hash[:funder_names] << funding['name']&.downcase&.split(' (').first&.strip
147
147
  @details_hash[:funder_ids] << fundref
148
148
  @details_hash[:opportunity_ids] << opportunity&.downcase&.strip
149
149
  @details_hash[:grant_ids] << [grant&.downcase&.strip, grant&.split('/')&.last&.downcase&.strip]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.1.12'
4
+ VERSION = '0.1.14'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-31 00:00:00.000000000 Z
11
+ date: 2023-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json