uc3-dmp-id 0.1.7 → 0.1.9

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: 5d3c26185a12403a3c3dfa1b9ab0dec6b798b1b127905a22d04f6f929d8cbf73
4
- data.tar.gz: de6b7a8f6c3395516ed10adc6eb55d0d84a9f52ae785dc36418f408f097c5900
3
+ metadata.gz: 8c486be80d903bf0a84eb05a414d4654bc4e89e54486ee8daee6a451c18c4fd5
4
+ data.tar.gz: f7fad411d4c5118dacd0e40d169de08465e97bddeb0a7985a2c320a95004eccf
5
5
  SHA512:
6
- metadata.gz: 1e790c4ee74028bc85b924ec1f82b4301be23014f1e0543c69103e285993002be0c00642b0a58a3e2d7418956708142f562f5306af69eeae3377609e5a3f3cb9
7
- data.tar.gz: 06bd91810cde2da48258c1a22bc699788a131c1e4aaae3b1d12f86edbfb55ac85fd560803dcc84df4632fbafa9257650f56529d0475b03f291a4b9e0b76e829d
6
+ metadata.gz: 317feb916c8d16e49b34b560d13f553f46969dfdec67bebf55a2a8afd98b5a59668f5b7f7ce0cb25a1a05c9cd11539e3af0aecc29ee3fb7396f4f869c5eb255e
7
+ data.tar.gz: 3cd7d6ae9a8485b1ded6782db3e2b2ba01fc2f7afdc9cf8414200f9827084e42567418686fb4d153b14188971cb86ad41d0876cceea1ec1606c19d78e5e53576
@@ -29,7 +29,7 @@ module Uc3DmpId
29
29
  end
30
30
  # rubocop:enable Metrics/AbcSize
31
31
 
32
- # rubocop:disable Metrics/AbcSize
32
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
33
33
  def add_modifications(works:)
34
34
  mod_hash = _generate_mod_header
35
35
 
@@ -42,13 +42,15 @@ module Uc3DmpId
42
42
  fundings = publication.fetch('fundingReferences', [])
43
43
  next unless fundings.any?
44
44
 
45
- award_hash = fundings.map { |funding| _funding_to_mod_entry(funding:) }
45
+ award_hash = fundings.map { |funding| _funding_to_mod_entry(work: publication, funding:) }
46
46
  mod_hash.fetch('funding', []) << award_hash unless award_hash.nil?
47
47
  end
48
48
  return 0 unless mod_hash['dmproadmap_related_identifiers'].any? || mod_hash.fetch('funding', []).any?
49
49
 
50
+ # A single work can have multiple fundingReferences, so flatten the array
51
+ mod_hash['funding'] = mod_hash.fetch('funding', []).flatten.compact.uniq
52
+
50
53
  # Save the DMP
51
- mods = (@known_mods.nil? ? [] : @known_mods)
52
54
  @dmp['dmphub_modifications'] = (@known_mods.nil? ? [] : @known_mods) << mod_hash
53
55
 
54
56
  client = Uc3DmpDynamo::Client.new
@@ -58,7 +60,7 @@ module Uc3DmpId
58
60
  # Return the number of modifications added to the DMP
59
61
  mod_hash.fetch('dmproadmap_related_identifiers', []).length + mod_hash.fetch('funding', []).length
60
62
  end
61
- # rubocop:enable Metrics/AbcSize
63
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
62
64
 
63
65
  private
64
66
 
@@ -68,7 +70,7 @@ module Uc3DmpId
68
70
  provenance: @augmenter['name'],
69
71
  timestamp: Time.now.utc.iso8601,
70
72
  dmproadmap_related_identifiers: [],
71
- fundings: []
73
+ funding: []
72
74
  }.to_json)
73
75
  end
74
76
 
@@ -80,7 +82,10 @@ module Uc3DmpId
80
82
  type: 'doi',
81
83
  identifier: work['id'],
82
84
  descriptor: 'references',
83
- status: 'pending'
85
+ status: 'pending',
86
+ confidence: work['confidence'],
87
+ score: work['score'],
88
+ notes: work['notes']
84
89
  }
85
90
  work_type = work.fetch('type', 'Text')&.downcase&.strip
86
91
  ret[:work_type] = work_type == 'text' ? type : work_type
@@ -94,7 +99,7 @@ module Uc3DmpId
94
99
  # Convert a funding entry for the dmphub_modification
95
100
  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
96
101
  # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
97
- def _funding_to_mod_entry(funding:)
102
+ def _funding_to_mod_entry(work:, funding:)
98
103
  return nil unless funding.is_a?(Hash) && (!funding['awardUri'] || !funding['awardNumber'])
99
104
  return nil if @known_awards.include?(funding['awardUri']) || @known_awards.include?(funding['awardNumber'])
100
105
 
@@ -103,6 +108,9 @@ module Uc3DmpId
103
108
 
104
109
  ret = {
105
110
  status: 'pending',
111
+ confidence: work['confidence'],
112
+ score: work['score'],
113
+ notes: work['notes'],
106
114
  name: funding['funderName'],
107
115
  funding_status: 'granted',
108
116
  grant_id: {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.1.7'
4
+ VERSION = '0.1.9'
5
5
  end
data/lib/uc3-dmp-id.rb CHANGED
@@ -6,7 +6,6 @@ require 'json-schema'
6
6
 
7
7
  require 'uc3-dmp-event-bridge'
8
8
 
9
- require 'uc3-dmp-id/asserter'
10
9
  require 'uc3-dmp-id/augmenter'
11
10
  require 'uc3-dmp-id/comparator'
12
11
  require 'uc3-dmp-id/creator'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley