uc3-dmp-id 0.0.87 → 0.0.89
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/updater.rb +4 -11
- data/lib/uc3-dmp-id/version.rb +1 -1
- data/lib/uc3-dmp-id/versioner.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: 060e5579b7df045a30beb6431b0954b19e8542b42e1dacc933c9f0f025d521a8
|
4
|
+
data.tar.gz: b784e85e55401583d782363b0b9d99f23839db175aac2e4ccfa498b5c98481c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bc49726eb20d814984f6bd3585510f7d45b5dd00479cc95933f6ade4e5ca2b77a191d18377b05af0d3303b3ba19f7cedb54a85abb11d77ea45a712305c0816b
|
7
|
+
data.tar.gz: 1c6048b78d7b9c38b16433e93b3bc64df70ccfcecda64e6cc4f223ce7253bde6868b9d53834c0d3e7e17fc46cac1569acaf76a1588bf3c5a38fb2e76154f6d72
|
data/lib/uc3-dmp-id/updater.rb
CHANGED
@@ -24,19 +24,16 @@ puts annotated
|
|
24
24
|
# fetch the existing latest version of the DMP ID
|
25
25
|
client = Uc3DmpDynamo::Client.new(debug: debug)
|
26
26
|
existing = Finder.by_pk(p_key: p_key, client: client, debug: debug)
|
27
|
-
|
28
|
-
puts 'EXISTING:'
|
29
|
-
puts existing
|
30
|
-
|
31
27
|
errs = _updateable?(provenance: provenance, p_key: p_key, json: annotated)
|
32
28
|
raise UpdaterError, errs if errs.is_a?(Array) && errs.any?
|
33
29
|
# Don't continue if nothing has changed!
|
34
|
-
raise UpdaterError, MSG_NO_CHANGE if Helper.eql?(dmp_a: existing, dmp_b:
|
30
|
+
raise UpdaterError, MSG_NO_CHANGE if Helper.eql?(dmp_a: existing, dmp_b: dmp)
|
35
31
|
|
36
32
|
# Generate a new version of the DMP. This involves versioning the current latest version
|
37
|
-
new_version =
|
33
|
+
new_version = Versioner.new_version(provenance: provenance, p_key: p_key, client: client, debug: debug,
|
34
|
+
dmp: dmp, latest_version: existing)
|
38
35
|
|
39
|
-
puts '
|
36
|
+
puts 'New version:'
|
40
37
|
puts new_version
|
41
38
|
|
42
39
|
raise UpdaterError, MSG_DMP_UNABLE_TO_VERSION if new_version.nil?
|
@@ -84,12 +81,8 @@ puts new_version
|
|
84
81
|
# Validate the incoming JSON first
|
85
82
|
errs = Validator.validate(mode: 'author', json: json)
|
86
83
|
return errs.join(', ') if errs.is_a?(Array) && errs.any? && errs.first != Validator::MSG_VALID_JSON
|
87
|
-
|
88
|
-
puts "Provenance: #{provenance['PK']}, DMP_ID to PK #{Helper.dmp_id_to_pk(json: json['dmp'].fetch('dmp_id', {}))} == P_KEY: #{p_key}"
|
89
|
-
|
90
84
|
# Fail if the provenance is not defined
|
91
85
|
return [MSG_DMP_FORBIDDEN] unless provenance.is_a?(Hash) && !provenance['PK'].nil?
|
92
|
-
|
93
86
|
# Verify that the JSON is for the same DMP in the PK
|
94
87
|
dmp_id = json['dmp'].fetch('dmp_id', {})
|
95
88
|
return [MSG_DMP_FORBIDDEN] unless Helper.dmp_id_to_pk(json: dmp_id) == p_key
|
data/lib/uc3-dmp-id/version.rb
CHANGED
data/lib/uc3-dmp-id/versioner.rb
CHANGED
@@ -29,7 +29,7 @@ module Uc3DmpId
|
|
29
29
|
# - Saving the new `VERSION=yyyy-mm-ddThh:mm:ss+zz:zz` item
|
30
30
|
# - Splicing in the current changes onto the existing `VERSION#latest` item
|
31
31
|
# - Returning the spliced `VERSION#latest` back to this method
|
32
|
-
def new_version(provenance:, p_key:, client: nil, dmp:, latest_version: {})
|
32
|
+
def new_version(provenance:, p_key:, client: nil, dmp:, latest_version: {}, debug: false)
|
33
33
|
return nil unless p_key.is_a?(String) && !p_key.strip.empty? && _versionable?(dmp: dmp)
|
34
34
|
|
35
35
|
client = Uc3DmpDynamo::Client.new(debug: debug) if client.nil?
|