uc3-dmp-id 0.0.136 → 0.0.138
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uc3-dmp-id/asserter.rb +22 -14
- data/lib/uc3-dmp-id/helper.rb +1 -1
- data/lib/uc3-dmp-id/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '02680b9c04b11bccb85df84a1284b131303a62f6d71a2f1c69916cb3354e8b6b'
|
4
|
+
data.tar.gz: 82bf4da553ab4d395d245bd35299ce92e157ee400da63cccbced150e5aa115b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4770d6f0635fb199aa1a11e0a69a22afaad6bb283068bcc83341d335fae1cc74ae33c9c129c78f8f237313fd8b9d9f8874477c73560980fe6de4b6542a7cbba
|
7
|
+
data.tar.gz: b03d6992d814a990bed40637a9f3b653273692f5cc0ede5859674d00d5332dd8d5822ab8f91568701fc8506dd8c64fc42efacd9606870cc6e6ef77b3da3f95c4
|
data/lib/uc3-dmp-id/asserter.rb
CHANGED
@@ -22,42 +22,42 @@ puts "ADDING ASSERTIONS: #{mods}"
|
|
22
22
|
# Return the DMP ID as-is if there are no assertable changes
|
23
23
|
return dmp if contact.nil? && contributor.empty? && project.empty?
|
24
24
|
|
25
|
-
# Clone any existing
|
26
|
-
assertions = Helper.deep_copy_dmp(obj: dmp.fetch('
|
25
|
+
# Clone any existing pending_assertions on the current DMP ID so we can manipulate them
|
26
|
+
assertions = Helper.deep_copy_dmp(obj: dmp.fetch('dmphub_modifications', []))
|
27
27
|
# Return the DMP ID as-is if the assertion is already on the record
|
28
|
-
return dmp if assertions.select { |entry| entry['provenance'] == updater && entry['
|
28
|
+
return dmp if assertions.select { |entry| entry['provenance'] == updater && entry['pending_assertions'] == mods }
|
29
29
|
|
30
30
|
assertions << _generate_assertion(updater: updater, mods: mods, note: note)
|
31
|
-
dmp['
|
31
|
+
dmp['dmphub_modifications'] = assertions.flatten
|
32
32
|
dmp
|
33
33
|
end
|
34
34
|
|
35
35
|
# Splice together assertions made while the user was updating the DMP ID
|
36
36
|
def splice(latest_version:, modified_version:, logger: nil)
|
37
37
|
|
38
|
-
puts "LATEST_VERSION ASSERTIONS: #{latest_version['
|
39
|
-
puts "MODIFIED_VERSION ASSERTIONS: #{modified_version['
|
38
|
+
puts "LATEST_VERSION ASSERTIONS: #{latest_version['dmphub_modifications']}"
|
39
|
+
puts "MODIFIED_VERSION ASSERTIONS: #{modified_version['dmphub_modifications']}"
|
40
40
|
|
41
41
|
# Return the modified_version if the timestamps are the same (meaning no new assertions were made while the
|
42
42
|
# user was working on the DMP ID) OR neither version has assertions
|
43
43
|
return modified_version if latest_version['modified'] == modified_version['modified'] ||
|
44
|
-
(latest_version.fetch('
|
45
|
-
modified_version.fetch('
|
44
|
+
(latest_version.fetch('dmphub_modifications', []).empty? &&
|
45
|
+
modified_version.fetch('dmphub_modifications', []).empty?)
|
46
46
|
|
47
47
|
# Clone any existing assertions on the current DMP ID so we can manipulate them
|
48
|
-
existing_assertions = Helper.deep_copy_dmp(obj: latest_version.fetch('
|
49
|
-
incoming_assertions = Helper.deep_copy_dmp(obj: modified_version.fetch('
|
48
|
+
existing_assertions = Helper.deep_copy_dmp(obj: latest_version.fetch('dmphub_modifications', []))
|
49
|
+
incoming_assertions = Helper.deep_copy_dmp(obj: modified_version.fetch('dmphub_modifications', []))
|
50
50
|
logger.debug(message: "Existing assertions", details: existing_assertions) if logger.respond_to?(:debug)
|
51
51
|
logger.debug(message: "Incoming modifications", details: incoming_assertions) if logger.respond_to?(:debug)
|
52
52
|
|
53
53
|
# Keep any assetions that were made after the modified on the incoming changes
|
54
|
-
modified_version['
|
54
|
+
modified_version['dmphub_modifications'] = existing_assertions.select do |entry|
|
55
55
|
!entry['timestamp'].nil? && Time.parse(entry['timestamp']) > Time.parse(modified_version['modified'])
|
56
56
|
end
|
57
57
|
return modified_version unless incoming_assertions.any?
|
58
58
|
|
59
59
|
# Add any of the assertions still on the incoming record back to the latest record
|
60
|
-
incoming_assertions.each { |entry| modified_version['
|
60
|
+
incoming_assertions.each { |entry| modified_version['dmphub_modifications'] << entry }
|
61
61
|
modified_version
|
62
62
|
end
|
63
63
|
|
@@ -70,7 +70,7 @@ puts "MODIFIED_VERSION ASSERTIONS: #{modified_version['dmphub_assertions']}"
|
|
70
70
|
# "provenance": "dmphub",
|
71
71
|
# "timestamp": "2023-07-07T14:50:23+00:00",
|
72
72
|
# "note": "data received from the NIH API",
|
73
|
-
# "
|
73
|
+
# "pending_assertions": {
|
74
74
|
# "contact": {
|
75
75
|
# "name": "Wrong Person"
|
76
76
|
# },
|
@@ -80,6 +80,14 @@ puts "MODIFIED_VERSION ASSERTIONS: #{modified_version['dmphub_assertions']}"
|
|
80
80
|
# "role": ["Investigation"]
|
81
81
|
# }
|
82
82
|
# ],
|
83
|
+
# "dmproadmap_related_identifiers": [
|
84
|
+
# {
|
85
|
+
# "work_type": "article",
|
86
|
+
# "descriptor": "is_cited_by",
|
87
|
+
# "type": "doi",
|
88
|
+
# "identifier": "https://dx.doi.org/99.9876/ZYX987.V6"
|
89
|
+
# }
|
90
|
+
# ],
|
83
91
|
# "project": [
|
84
92
|
# {
|
85
93
|
# "start": "2024-01-01T00:00:00+07:00",
|
@@ -110,7 +118,7 @@ puts "MODIFIED_VERSION ASSERTIONS: #{modified_version['dmphub_assertions']}"
|
|
110
118
|
timestamp: Time.now.utc.iso8601,
|
111
119
|
status: 'new',
|
112
120
|
note: note,
|
113
|
-
|
121
|
+
pending_assertions: mods
|
114
122
|
}.to_json)
|
115
123
|
end
|
116
124
|
end
|
data/lib/uc3-dmp-id/helper.rb
CHANGED
@@ -15,7 +15,7 @@ module Uc3DmpId
|
|
15
15
|
SK_DMP_REGEX = /VERSION#\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2}/.freeze
|
16
16
|
|
17
17
|
# TODO: Verify the assumed structure of the DOI is valid
|
18
|
-
DOI_REGEX = %r{[0-9]{2}\.[0-9]{
|
18
|
+
DOI_REGEX = %r{[0-9]{2}\.[0-9]{4,}/[a-zA-Z0-9/_.-]+}.freeze
|
19
19
|
URL_REGEX = %r{(https?://)?([a-zA-Z0-9\-_]\.)+[a-zA-Z0-9\-_]{2,3}(:[0-9]+)?/?}.freeze
|
20
20
|
|
21
21
|
DMP_LATEST_VERSION = "#{SK_DMP_PREFIX}latest"
|
data/lib/uc3-dmp-id/version.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.138
|
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-08-
|
11
|
+
date: 2023-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|