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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6a82bbb7e1b2b0e5e6e7a917a1d5356cdf0d73b63f5c9a61b3423093aa09c2d
4
- data.tar.gz: 682482122e0cd16c5ec9dd1d15656c9107dc50af912d33aeef6232af6e9d5bf3
3
+ metadata.gz: '085e7cad87be83e14f9a1b3e2126b8bc252f50bd70e42b81b4c6a6ba8d54b2e0'
4
+ data.tar.gz: 6d768084f7f5662a46d885b58dd682dc67deb723ea32eb6c0c42648af235bde1
5
5
  SHA512:
6
- metadata.gz: 0a51d2021d22d798d024a23b7c88a7f6142afaf163d68b296e0237d7d6fe486400cca32876c2250beef798439fff547ef38c85caa1737c82a35de16c6e2031a2
7
- data.tar.gz: ae852a0a5d87de997f9b76e293fa225c00fa4eba0e358f2aca62d69344cd6acb6038fdef250dba5d55746432571bd3b64227712080faa40bbbbcd0289c2c6e43
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: 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: 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(pk:, logger: nil)
47
- return nil if pk.nil?
46
+ def from_pk(p_key:, logger: nil)
47
+ return nil if p_key.nil?
48
48
 
49
- pk = Helper.append_pk_prefix(provenance: pk)
49
+ p_key = Helper.append_pk_prefix(provenance: p_key)
50
50
  resp = client.get_item(
51
- key: { PK: Helper.append_pk_prefix(provenance: pk), SK: Helper::SK_PROVENANCE_PREFIX },
52
- logger: 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.debug(message: "Cognito User Pool: #{user_pool_id}, ClientId: #{claim['client_id']}") if logger.respond_to?(:debug)
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/_.-]+}.freeze
12
- URL_REGEX = %r{(https?://)?([a-zA-Z0-9\-_]\.)+[a-zA-Z0-9\-_]{2,3}(:[0-9]+)?/?}.freeze
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: provenance)}" : nil
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
- .gsub(provenance.fetch('callbackUri', '').downcase, '')
48
- .gsub(provenance.fetch('homepage', '').downcase, '')
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, '')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpProvenance
4
- VERSION = '0.0.11'
4
+ VERSION = '0.0.13'
5
5
  end
@@ -9,6 +9,7 @@ require 'uc3-dmp-dynamo'
9
9
  require 'uc3-dmp-provenance/finder'
10
10
  require 'uc3-dmp-provenance/helper'
11
11
 
12
+ # Entrypoint for the uc3-dmp-provenance gem
12
13
  module Uc3DmpProvenance
13
14
  MSG_PROVENANCE_NOT_FOUND = 'Provenance does not exist.'
14
15
  end
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.11
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: 2023-07-07 00:00:00.000000000 Z
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.7'
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.1.6
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: []