uc3-dmp-provenance 0.0.10 → 0.0.12

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: 7f3c04c49849d18304637068691a2f26810e166ab70b7ea737c022eaf0f75b55
4
- data.tar.gz: 433da4633800604a21914bacf6d1eac8504fd58ae6a32db03f6a5e752f38e4b0
3
+ metadata.gz: 453eb4ad07288ccd9ad6311160d2fe231af0655167d4156cb7139699ad31d302
4
+ data.tar.gz: 60527fa8a203482bc5e38a1d8d731dca514c0cc4a9f578123a95164530a83284
5
5
  SHA512:
6
- metadata.gz: d765064e920be446870ef106e514db1906e08d85436abeb44431d73ff9aa4076c8aac9813637424a2ef5032ea153eb2b38ac5b86d2b6217e8f3953c2ebff758e
7
- data.tar.gz: 90eadd20dd60a51b6d11e58fef2b1590b2a80fcc4d00a4db1e3807c61e04de4d0a515df36da8bb816a618a1fd3b65ae08886cb0ba7526cc45fedee870a222b38
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: 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: logger)
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.10'
4
+ VERSION = '0.0.12'
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.10
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-07-07 00:00:00.000000000 Z
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.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.10
145
+ signing_key:
146
146
  specification_version: 4
147
147
  summary: DMPTool gem that provides support for Provenance records
148
148
  test_files: []