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 +4 -4
- data/lib/uc3-dmp-id/augmenter.rb +15 -7
- data/lib/uc3-dmp-id/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c486be80d903bf0a84eb05a414d4654bc4e89e54486ee8daee6a451c18c4fd5
|
4
|
+
data.tar.gz: f7fad411d4c5118dacd0e40d169de08465e97bddeb0a7985a2c320a95004eccf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 317feb916c8d16e49b34b560d13f553f46969dfdec67bebf55a2a8afd98b5a59668f5b7f7ce0cb25a1a05c9cd11539e3af0aecc29ee3fb7396f4f869c5eb255e
|
7
|
+
data.tar.gz: 3cd7d6ae9a8485b1ded6782db3e2b2ba01fc2f7afdc9cf8414200f9827084e42567418686fb4d153b14188971cb86ad41d0876cceea1ec1606c19d78e5e53576
|
data/lib/uc3-dmp-id/augmenter.rb
CHANGED
@@ -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
|
-
|
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: {
|
data/lib/uc3-dmp-id/version.rb
CHANGED