uc3-dmp-id 0.0.47 → 0.0.48

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43c55916e9c3c7e5dffebe207a69de110ff182000a72ae3ea915036653199be0
4
- data.tar.gz: 7eb32abc118b66d38084716f34dd0994043c62421c7cba00ff85353f9442d3a9
3
+ metadata.gz: f184f47843a41741118c64764999e2e63e66bf8092c8052d00f75bf7b5a04063
4
+ data.tar.gz: 44b5cafd4ef3f6043a4b1873d66fa3f9b9dde2f328203b8dd0c5537a042a245c
5
5
  SHA512:
6
- metadata.gz: 0f758910ef012627c05710e6dda80e3c72abdf77f0e7cff64ea46cb93a7697bacf8802ed73e3d455cb98dc245640a45d43f2f3b8ed2945d9b3043d31ec83e203
7
- data.tar.gz: 45737a59db0d8e2a5e9a59ddadbccb7a36af9513a91ba04ba04f1919bef867060ba6139c8abdb55c4c1bb1452a599a35bce23cad8a59aab1037c522486c72dde
6
+ metadata.gz: b6923c6148a6b347efbf00955d7aaafb810edbc42c38818191a9e440faaf648555753fc271a47f520d6ef489a135b5b9d65b468311c24da9feb22e7aa256660b
7
+ data.tar.gz: 0d54dc2c84c8a74dc0edf02a88971939fd307940837a0edd9ec1fae4144c3dcf5675e89dcb9b9cf08a2a6072eb44cae9bb14ad82e6343ea0b4676e0904f3970c
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.47'
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.47
4
+ version: 0.0.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley