uc3-dmp-provenance 0.0.11 → 0.0.12
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-provenance/finder.rb +10 -10
- data/lib/uc3-dmp-provenance/helper.rb +5 -5
- data/lib/uc3-dmp-provenance/version.rb +1 -1
- data/lib/uc3-dmp-provenance.rb +1 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 453eb4ad07288ccd9ad6311160d2fe231af0655167d4156cb7139699ad31d302
|
4
|
+
data.tar.gz: 60527fa8a203482bc5e38a1d8d731dca514c0cc4a9f578123a95164530a83284
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f4b522b6575def616403c0fbe399614418882bc6180bfc8a48293a03345470d6628ea80feaca7c495bdb023ecb8cfb017ad80b5e5510650405ad991a6a6328f
|
7
|
+
data.tar.gz: 42f2c2487bbcc7c22d4711ad49708268367608a7f30acc24188467c0fcbd97ff9107eb251910237fbbfe354139ad3642dd9ce810d08531de5e5a0d68b5c7c8f2
|
@@ -27,15 +27,15 @@ module Uc3DmpProvenance
|
|
27
27
|
# "client_id": "abcdefghijklmnopqrstuvwxyz"
|
28
28
|
# }
|
29
29
|
# -------------------------------------------------------------------------------------------
|
30
|
-
def from_lambda_cotext(identity:, logger: nil)
|
30
|
+
def from_lambda_cotext(identity:, client: nil, logger: nil)
|
31
31
|
return nil unless identity.is_a?(Hash) && !identity['iss'].nil? && !identity['client_id'].nil?
|
32
32
|
|
33
|
-
client = Uc3DmpDynamo::Client.new
|
34
|
-
client_name = _cognito_client_id_to_name(claim: identity, logger:
|
33
|
+
client = client.nil? ? Uc3DmpDynamo::Client.new : client
|
34
|
+
client_name = _cognito_client_id_to_name(claim: identity, logger:)
|
35
35
|
|
36
36
|
resp = client.get_item(
|
37
37
|
key: { PK: Helper.append_pk_prefix(provenance: client_name), SK: Helper::SK_PROVENANCE_PREFIX },
|
38
|
-
logger:
|
38
|
+
logger:
|
39
39
|
)
|
40
40
|
resp.nil? || resp.empty? ? nil : resp
|
41
41
|
end
|
@@ -43,13 +43,13 @@ module Uc3DmpProvenance
|
|
43
43
|
# Fetch the Provenance by it's PK.
|
44
44
|
#
|
45
45
|
# Expecting either the name (e.g. `dmptool` or the qualified PK (e.g. `PROVENANCE#dmptool`)
|
46
|
-
def from_pk(
|
47
|
-
return nil if
|
46
|
+
def from_pk(p_key:, logger: nil)
|
47
|
+
return nil if p_key.nil?
|
48
48
|
|
49
|
-
|
49
|
+
p_key = Helper.append_pk_prefix(provenance: p_key)
|
50
50
|
resp = client.get_item(
|
51
|
-
key: { PK: Helper.append_pk_prefix(provenance:
|
52
|
-
logger:
|
51
|
+
key: { PK: Helper.append_pk_prefix(provenance: p_key), SK: Helper::SK_PROVENANCE_PREFIX },
|
52
|
+
logger:
|
53
53
|
)
|
54
54
|
resp.nil? || resp.empty? ? nil : resp
|
55
55
|
end
|
@@ -61,7 +61,7 @@ module Uc3DmpProvenance
|
|
61
61
|
return nil if claim.nil? || !claim.is_a?(Hash) || claim['iss'].nil? || claim['client_id'].nil?
|
62
62
|
|
63
63
|
user_pool_id = claim['iss'].split('/').last
|
64
|
-
logger
|
64
|
+
logger&.debug(message: "Cognito User Pool: #{user_pool_id}, ClientId: #{claim['client_id']}")
|
65
65
|
Uc3DmpCognito::Client.get_client_name(client_id: claim['client_id'])
|
66
66
|
end
|
67
67
|
end
|
@@ -8,14 +8,14 @@ module Uc3DmpProvenance
|
|
8
8
|
PK_PROVENANCE_PREFIX = 'PROVENANCE#'
|
9
9
|
SK_PROVENANCE_PREFIX = 'PROFILE'
|
10
10
|
|
11
|
-
DOI_REGEX = %r{[0-9]{2}\.[0-9]{5}/[a-zA-Z0-9/_.-]+}
|
12
|
-
URL_REGEX = %r{(https?://)?([a-zA-Z0-9\-_]\.)+[a-zA-Z0-9\-_]{2,3}(:[0-9]+)?/?}
|
11
|
+
DOI_REGEX = %r{[0-9]{2}\.[0-9]{5}/[a-zA-Z0-9/_.-]+}
|
12
|
+
URL_REGEX = %r{(https?://)?([a-zA-Z0-9\-_]\.)+[a-zA-Z0-9\-_]{2,3}(:[0-9]+)?/?}
|
13
13
|
|
14
14
|
class << self
|
15
15
|
# Append the PK prefix for the object
|
16
16
|
# -------------------------------------------------------------------------------------
|
17
17
|
def append_pk_prefix(provenance:)
|
18
|
-
provenance.is_a?(String) ? "#{PK_PROVENANCE_PREFIX}#{remove_pk_prefix(provenance:
|
18
|
+
provenance.is_a?(String) ? "#{PK_PROVENANCE_PREFIX}#{remove_pk_prefix(provenance:)}" : nil
|
19
19
|
end
|
20
20
|
|
21
21
|
# Strip off the PK prefix
|
@@ -44,8 +44,8 @@ module Uc3DmpProvenance
|
|
44
44
|
|
45
45
|
# Remove the homepage or callbackUri because we will add this when needed. we just want the id
|
46
46
|
val = value.downcase
|
47
|
-
|
48
|
-
|
47
|
+
.gsub(provenance.fetch('callbackUri', '').downcase, '')
|
48
|
+
.gsub(provenance.fetch('homepage', '').downcase, '')
|
49
49
|
val = val.gsub(%r{https?://}, '')
|
50
50
|
val = val[1..val.length] if val.start_with?('/')
|
51
51
|
id = provenance['PK']&.gsub(PK_PROVENANCE_PREFIX, '')
|
data/lib/uc3-dmp-provenance.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uc3-dmp-provenance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Riley
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -126,7 +126,7 @@ licenses:
|
|
126
126
|
- MIT
|
127
127
|
metadata:
|
128
128
|
rubygems_mfa_required: 'false'
|
129
|
-
post_install_message:
|
129
|
+
post_install_message:
|
130
130
|
rdoc_options: []
|
131
131
|
require_paths:
|
132
132
|
- lib
|
@@ -134,15 +134,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
134
|
requirements:
|
135
135
|
- - ">="
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: '2
|
137
|
+
version: '3.2'
|
138
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
139
|
requirements:
|
140
140
|
- - ">="
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
|
-
rubygems_version: 3.
|
145
|
-
signing_key:
|
144
|
+
rubygems_version: 3.4.10
|
145
|
+
signing_key:
|
146
146
|
specification_version: 4
|
147
147
|
summary: DMPTool gem that provides support for Provenance records
|
148
148
|
test_files: []
|