uc3-dmp-id 0.0.47 → 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 +4 -4
- data/lib/uc3-dmp-id/helper.rb +29 -0
- 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/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/version.rb
CHANGED