uc3-dmp-id 0.0.46 → 0.0.48

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d478a33716920d1d91f8e933febebe7ec8e7a40a3d0bb50d4c50f1e764cf5aec
4
- data.tar.gz: a073a32740da380be957b1af0061df437640e4126d79518d23b1a366e038f7dc
3
+ metadata.gz: f184f47843a41741118c64764999e2e63e66bf8092c8052d00f75bf7b5a04063
4
+ data.tar.gz: 44b5cafd4ef3f6043a4b1873d66fa3f9b9dde2f328203b8dd0c5537a042a245c
5
5
  SHA512:
6
- metadata.gz: bb614d60d8ba75fd46e8316d39d27f27fc5f7ae3bdd8a91a632951b0abd947a29b075624f7ee211dc65975d6d162d873b949c5a247d2db78f1893e59cdaaaa7a
7
- data.tar.gz: 6efc441c6c5f74c284d94a476b095eabe35f23b0995cecf8debf27d95a1f7e0f22d8307386a35c6322da045bfa099774f2536ea22010bf5e131420f2a009b275
6
+ metadata.gz: b6923c6148a6b347efbf00955d7aaafb810edbc42c38818191a9e440faaf648555753fc271a47f520d6ef489a135b5b9d65b468311c24da9feb22e7aa256660b
7
+ data.tar.gz: 0d54dc2c84c8a74dc0edf02a88971939fd307940837a0edd9ec1fae4144c3dcf5675e89dcb9b9cf08a2a6072eb44cae9bb14ad82e6343ea0b4676e0904f3970c
@@ -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
 
@@ -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
@@ -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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.46'
4
+ VERSION = '0.0.48'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.46
4
+ version: 0.0.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley