uc3-dmp-provenance 0.0.11 → 0.0.13
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: '085e7cad87be83e14f9a1b3e2126b8bc252f50bd70e42b81b4c6a6ba8d54b2e0'
|
4
|
+
data.tar.gz: 6d768084f7f5662a46d885b58dd682dc67deb723ea32eb6c0c42648af235bde1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43cd0fadd767cb64d614ca5e179cf3ef0e355f848a1e10cdb840eaaa76c4a6d6ed8d074148df24ff2f03b58f607cb88880d5e2fb7e463e932762b459626c24f2
|
7
|
+
data.tar.gz: e3f59a2d7ef8483edf0bd461b656a7f2187ea1287848fa7908f4c6c33c2cbf14c3738fdef154095937231db3378628430a71e735d2ce38a03d6ee5950f91f4c9
|
@@ -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.13
|
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:
|
11
|
+
date: 2024-05-29 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.22
|
145
|
+
signing_key:
|
146
146
|
specification_version: 4
|
147
147
|
summary: DMPTool gem that provides support for Provenance records
|
148
148
|
test_files: []
|