uc3-dmp-id 0.1.8 → 0.1.9

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: 80c3e05c1426f027f21fe1530f64359defcf49008544c5ba6dce81bf9956c34b
4
- data.tar.gz: 56ffbdebfc4489eee4180049a4f966c85a13bfde59b41138bfd399ce019eac56
3
+ metadata.gz: 8c486be80d903bf0a84eb05a414d4654bc4e89e54486ee8daee6a451c18c4fd5
4
+ data.tar.gz: f7fad411d4c5118dacd0e40d169de08465e97bddeb0a7985a2c320a95004eccf
5
5
  SHA512:
6
- metadata.gz: '0379e03b861cc814ba551ef07839a4120e69159593a53cc84439e1b5e40da8caae9f0caf661cddcefddbf786509e288c3e0572f66c94263d03cb6262cd357750'
7
- data.tar.gz: 64a025580d936ef6002a5e5810a172dbfbd056844c4cab7d18892001f10803babb6fcc6a90e1354667c5304dee5bf98c649a9d12fe4c2622ddada394bc2d1064
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.8'
4
+ VERSION = '0.1.9'
5
5
  end
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.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley