uc3-dmp-id 0.0.120 → 0.0.121
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 +3 -1
- data/lib/uc3-dmp-id/creator.rb +6 -0
- data/lib/uc3-dmp-id/deleter.rb +7 -1
- data/lib/uc3-dmp-id/updater.rb +5 -0
- data/lib/uc3-dmp-id/version.rb +1 -1
- data/lib/uc3-dmp-id/versioner.rb +3 -2
- 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: 6a7b18e8a03e8b1fec669c319659352f4cee0fc5d726c92a45c178ea37116375
|
4
|
+
data.tar.gz: 4239900d4abfe0c89126ba713d135b55ede35b05db53671390fabab773372933
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e2d9142e4adcc5604ee23d35d16f3f06c48f872476d049223293c6779c89ec5cdb5b5db80a0ad27ded0c46110d105ed41351b55b4dcc655b9eec698b56ddb1a
|
7
|
+
data.tar.gz: 93393c6f351ceef8afdf2f59213f58ac8a908bde9511d67e263e780b1bc2d0120ed0d9de02a6a93e9151e5289176162473929afc7de65952aa1cab354ee781a6
|
data/lib/uc3-dmp-id/asserter.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'time'
|
4
|
+
|
3
5
|
module Uc3DmpId
|
4
6
|
class AsserterError < StandardError; end
|
5
7
|
|
@@ -105,7 +107,7 @@ puts "MODIFIED_VERSION ASSERTIONS: #{modified_version['dmphub_assertions']}"
|
|
105
107
|
JSON.parse({
|
106
108
|
id: SecureRandom.hex(4).upcase,
|
107
109
|
provenance: updater.gsub('PROVENANCE#', ''),
|
108
|
-
timestamp: Time.now.iso8601,
|
110
|
+
timestamp: Time.now.utc.iso8601,
|
109
111
|
status: 'new',
|
110
112
|
note: note,
|
111
113
|
assertions: mods
|
data/lib/uc3-dmp-id/creator.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'securerandom'
|
4
|
+
require 'time'
|
4
5
|
|
5
6
|
module Uc3DmpId
|
6
7
|
class CreatorError < StandardError; end
|
@@ -40,6 +41,11 @@ module Uc3DmpId
|
|
40
41
|
annotated = Helper.annotate_dmp_json(provenance: provenance, p_key: p_key, json: json['dmp'])
|
41
42
|
logger.info(message: "Creating DMP ID: #{p_key}") if logger.respond_to?(:debug)
|
42
43
|
|
44
|
+
# Set the :created and :modified timestamps
|
45
|
+
now = Time.now.utc.iso8601
|
46
|
+
annotated['created'] = now
|
47
|
+
annotated['modified'] = now
|
48
|
+
|
43
49
|
# Create the item
|
44
50
|
resp = client.put_item(json: annotated, logger: logger)
|
45
51
|
raise CreatorError, Uc3DmpId::MSG_DMP_NO_DMP_ID if resp.nil?
|
data/lib/uc3-dmp-id/deleter.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'time'
|
4
|
+
|
3
5
|
module Uc3DmpId
|
4
6
|
class DeleterError < StandardError; end
|
5
7
|
|
@@ -27,10 +29,14 @@ module Uc3DmpId
|
|
27
29
|
|
28
30
|
# Annotate the DMP ID
|
29
31
|
dmp['dmp']['SK'] = Helper::DMP_TOMBSTONE_VERSION
|
30
|
-
dmp['dmp']['dmphub_tombstoned_at'] = Time.now.iso8601
|
32
|
+
dmp['dmp']['dmphub_tombstoned_at'] = Time.now.utc.iso8601
|
31
33
|
dmp['dmp']['title'] = "OBSOLETE: #{dmp['title']}"
|
32
34
|
logger.info(message: "Tomstoning DMP ID: #{p_key}") if logger.respond_to?(:debug)
|
33
35
|
|
36
|
+
# Set the :modified timestamps
|
37
|
+
now = Time.now.utc.iso8601
|
38
|
+
dmp['modified'] = now
|
39
|
+
|
34
40
|
# Create the Tombstone version
|
35
41
|
resp = client.put_item(json: dmp, logger: logger)
|
36
42
|
raise DeleterError, MSG_DMP_NO_TOMBSTONE if resp.nil?
|
data/lib/uc3-dmp-id/updater.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'securerandom'
|
4
|
+
require 'time'
|
4
5
|
|
5
6
|
module Uc3DmpId
|
6
7
|
class UpdaterError < StandardError; end
|
@@ -42,6 +43,10 @@ module Uc3DmpId
|
|
42
43
|
version = _process_modifications(owner: owner, updater: updater, version: version, mods: mods, note: note,
|
43
44
|
logger: logger)
|
44
45
|
|
46
|
+
# Set the :modified timestamps
|
47
|
+
now = Time.now.utc.iso8601
|
48
|
+
version['modified'] = now
|
49
|
+
|
45
50
|
# Save the changes
|
46
51
|
resp = client.put_item(json: version, logger: logger)
|
47
52
|
raise UpdaterError, MSG_DMP_UNABLE_TO_VERSION if resp.nil?
|
data/lib/uc3-dmp-id/version.rb
CHANGED
data/lib/uc3-dmp-id/versioner.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'uc3-dmp-dynamo'
|
4
|
+
require 'time'
|
4
5
|
|
5
6
|
module Uc3DmpId
|
6
7
|
class VersionerError < StandardError; end
|
@@ -31,7 +32,7 @@ module Uc3DmpId
|
|
31
32
|
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
32
33
|
def generate_version(client:, latest_version:, owner:, updater:, logger: nil)
|
33
34
|
# Only create a version if the Updater is not the Owner OR the changes have happened on a different day
|
34
|
-
mod_time = Time.parse(latest_version.fetch('modified', Time.now.iso8601))
|
35
|
+
mod_time = Time.parse(latest_version.fetch('modified', Time.now.utc.iso8601))
|
35
36
|
now = Time.now
|
36
37
|
if mod_time.nil? || !(now - mod_time).is_a?(Float)
|
37
38
|
logger.error(message: "#{SOURCE} unable to determine mod time: #{mod_time}") if logger.respond_to?(:debug)
|
@@ -50,7 +51,7 @@ module Uc3DmpId
|
|
50
51
|
# Make a copy of the latest_version and then update it's SK to the :modified to mark it in a point of time
|
51
52
|
# We essentially make a snapshot of the record before making changes
|
52
53
|
prior = Helper.deep_copy_dmp(obj: latest_version)
|
53
|
-
prior['SK'] = "#{Helper::SK_DMP_PREFIX}#{latest_version['modified'] || Time.now.iso8601}"
|
54
|
+
prior['SK'] = "#{Helper::SK_DMP_PREFIX}#{latest_version['modified'] || Time.now.utc.iso8601}"
|
54
55
|
# Create the prior version record ()
|
55
56
|
client = client.nil? ? Uc3DmpDynamo::Client.new : client
|
56
57
|
resp = client.put_item(json: prior, logger: logger)
|