uc3-dmp-id 0.0.46 → 0.0.48
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/creator.rb +1 -1
- data/lib/uc3-dmp-id/helper.rb +29 -0
- data/lib/uc3-dmp-id/updater.rb +1 -1
- 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: f184f47843a41741118c64764999e2e63e66bf8092c8052d00f75bf7b5a04063
|
4
|
+
data.tar.gz: 44b5cafd4ef3f6043a4b1873d66fa3f9b9dde2f328203b8dd0c5537a042a245c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6923c6148a6b347efbf00955d7aaafb810edbc42c38818191a9e440faaf648555753fc271a47f520d6ef489a135b5b9d65b468311c24da9feb22e7aa256660b
|
7
|
+
data.tar.gz: 0d54dc2c84c8a74dc0edf02a88971939fd307940837a0edd9ec1fae4144c3dcf5675e89dcb9b9cf08a2a6072eb44cae9bb14ad82e6343ea0b4676e0904f3970c
|
data/lib/uc3-dmp-id/creator.rb
CHANGED
@@ -38,7 +38,7 @@ module Uc3DmpId
|
|
38
38
|
raise CreatorError, MSG_UNABLE_TO_MINT if p_key.nil?
|
39
39
|
|
40
40
|
# Add the DMPHub specific attributes and then save
|
41
|
-
annotated = Helper.annotate_dmp_json(provenance: provenance, owner_org: owner_org, p_key: p_key, json: json)
|
41
|
+
annotated = Helper.annotate_dmp_json(provenance: provenance, owner_org: owner_org, p_key: p_key, json: json['dmp'])
|
42
42
|
puts "CREATING DMP ID:" if debug
|
43
43
|
puts annotated if debug
|
44
44
|
|
data/lib/uc3-dmp-id/helper.rb
CHANGED
@@ -213,6 +213,35 @@ module Uc3DmpId
|
|
213
213
|
end
|
214
214
|
end
|
215
215
|
# rubocop:enable Metrics/AbcSize
|
216
|
+
|
217
|
+
# Appends the Provenance system's identifier to the value
|
218
|
+
# For a DOI, it will return the DOI as-is
|
219
|
+
#
|
220
|
+
# For a :provenance whose PK is 'PROVENANCE#example' and homepage is 'https://example.com' and
|
221
|
+
# callbackUri is 'https://example.com/callback':
|
222
|
+
# when the :value is '12345', it will return 'example#12345'
|
223
|
+
# when the :value is 'https://example.com/dmps/12345', it will return 'example#dmp/12345'
|
224
|
+
# when the :value is 'https://example.com/callback/12345' it will return 'example#12345'
|
225
|
+
#
|
226
|
+
# rubocop:disable Metrics/AbcSize
|
227
|
+
def format_provenance_id(provenance:, value:)
|
228
|
+
# return it as-is if there is no provenance or it's already a URL
|
229
|
+
return value if provenance.nil?
|
230
|
+
|
231
|
+
# return it as-is if it's a DOI
|
232
|
+
doi = value.match(DOI_REGEX).to_s
|
233
|
+
return value unless doi.nil? || doi == '' || !value.start_with?('http')
|
234
|
+
|
235
|
+
# Remove the homepage or callbackUri because we will add this when needed. we just want the id
|
236
|
+
val = value.downcase
|
237
|
+
.gsub(provenance.fetch('callbackUri', '').downcase, '')
|
238
|
+
.gsub(provenance.fetch('homepage', '').downcase, '')
|
239
|
+
val = val.gsub(%r{https?://}, '')
|
240
|
+
val = val[1..val.length] if val.start_with?('/')
|
241
|
+
id = provenance['PK']&.gsub('PROVENANCE#', '')
|
242
|
+
"#{id}##{val}"
|
243
|
+
end
|
244
|
+
# rubocop:enable Metrics/AbcSize
|
216
245
|
end
|
217
246
|
end
|
218
247
|
end
|
data/lib/uc3-dmp-id/updater.rb
CHANGED
@@ -17,7 +17,7 @@ module Uc3DmpId
|
|
17
17
|
raise DeleterError, errs if errs.is_a?(Array) && errs.any?
|
18
18
|
|
19
19
|
# Add the DMPHub specific attributes
|
20
|
-
annotated = Helper.annotate_dmp(provenance: provenance, json: dmp, p_key: p_key)
|
20
|
+
annotated = Helper.annotate_dmp(provenance: provenance, json: dmp['dmp'], p_key: p_key)
|
21
21
|
|
22
22
|
# fetch the existing latest version of the DMP ID
|
23
23
|
client = Uc3DmpDynamo::Client.new(debug: debug)
|
data/lib/uc3-dmp-id/version.rb
CHANGED