uc3-dmp-id 0.0.6 → 0.0.8

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: ab1c5afc33fa7cf9bafbc4a62a282a0674cdbe81c47566865789db74fc411ea3
4
- data.tar.gz: 16521d303406e294953b43108abb65b8e7af94d635a782e8008db91cae6e4c96
3
+ metadata.gz: 4246dcd22bffa17f20b22217a7b2dbd5cf205bf6e062197bbc179d8bd15663df
4
+ data.tar.gz: 1427526f7079ee63b3b0ea769557bf28b0c680124860a31e3c4ec36255b1fd11
5
5
  SHA512:
6
- metadata.gz: fbf1707d4052898f39ad30f06979f1218951f02bf24833669ff4743957a4e404278fe8112b791a5bef9f27d99e9081a267ee135a283467e77ea894143607ac43
7
- data.tar.gz: bfc2e024b3f73980302f2d8e3a15d945a541129ed02286b6f052371489f48a97e6af4eec31e46669169157035bacc28acd89954db1e5b3ea407647f35c907b5c
6
+ metadata.gz: 5a110c35c6fb293ff7e4ad7d47e21fc1fe20ca9f21a5830f3fb151af13c9e3c30e6caf9c7412802736d7909c53d43fade84c00d175228698ff65f2cadc23a1e6
7
+ data.tar.gz: cdb727bf7a72f06d0cf9310bbf7c8710a8ce27b4bb3b1d57eed932d50e4620edfd65d318acd673e448d733fd3bcef75b7496cc49493f01f72ffd7d04264c2722
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- class Uc3DmpIdCreatorError << StandardError; end
4
+ class Uc3DmpIdCreatorError < StandardError; end
5
5
 
6
6
  class Creator
7
7
  class << self
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- class Uc3DmpIdDeleterError << StandardError; end
4
+ class Uc3DmpIdDeleterError < StandardError; end
5
5
 
6
6
  class Deleter
7
7
  class << self
@@ -3,7 +3,7 @@
3
3
  require 'uc3-dmp-dynamo'
4
4
 
5
5
  module Uc3DmpId
6
- class Uc3DmpIdFinderError << StandardError; end
6
+ class Uc3DmpIdFinderError < StandardError; end
7
7
 
8
8
  # Methods to find/search for DMP IDs
9
9
  class Finder
@@ -23,7 +23,7 @@ module Uc3DmpId
23
23
 
24
24
  # Find the DMP's versions
25
25
  # -------------------------------------------------------------------------
26
- def versions(p_key:, client: nil, log_writer: nil, debug: false)
26
+ def versions(p_key:, client: nil, debug: false)
27
27
  raise Uc3DmpIdFinderError, MSG_MISSING_PK if p_key.nil?
28
28
 
29
29
  args = {
@@ -33,36 +33,36 @@ module Uc3DmpId
33
33
  projection_expression: 'modified',
34
34
  scan_index_forward: false
35
35
  }
36
- client = client.nil? ? Uc3DmpDynamo::Client.new(log_writer: log_writer, debug: debug) : client
36
+ client = client.nil? ? Uc3DmpDynamo::Client.new(debug: debug) : client
37
37
  client.query(**args)
38
38
  end
39
39
 
40
40
  # Find a DMP based on the contents of the incoming JSON
41
41
  # -------------------------------------------------------------------------
42
- def by_json(json:, log_writer: nil, debug: false)
42
+ def by_json(json:, debug: false)
43
43
  json = Validator.parse_json(json: json)&.fetch('dmp', {})
44
44
  raise Uc3DmpIdFinderError, MSG_INVALID_ARGS if json.nil? || (json['PK'].nil? && json['dmp_id'].nil?)
45
45
 
46
46
  p_key = json['PK']
47
47
  # Translate the incoming :dmp_id into a PK
48
48
  p_key = Helper.dmp_id_to_pk(json: json.fetch('dmp_id', {})) if p_key.nil?
49
- client = client.nil? ? Uc3DmpDynamo::Client.new(log_writer: log_writer, debug: debug) : client
49
+ client = client.nil? ? Uc3DmpDynamo::Client.new(debug: debug) : client
50
50
 
51
51
  # find_by_dmphub_provenance_id -> if no PK and no dmp_id result
52
- return by_provenance_identifier(json: json, client: client, log_writer: log_writer, debug: debug) if p_key.nil?
52
+ return by_provenance_identifier(json: json, client: client, debug: debug) if p_key.nil?
53
53
 
54
54
  # find_by_PK
55
- by_pk(p_key: p_key, s_key: json['SK'], client: client, log_writer: log_writer, debug: debug)
55
+ by_pk(p_key: p_key, s_key: json['SK'], client: client, debug: debug)
56
56
  end
57
57
 
58
58
  # Find the DMP by its PK and SK
59
59
  # -------------------------------------------------------------------------
60
- def by_pk(p_key:, s_key: Helper::DMP_LATEST_VERSION, client: nil, log_writer: nil, debug: false)
60
+ def by_pk(p_key:, s_key: Helper::DMP_LATEST_VERSION, client: nil, debug: false)
61
61
  raise Uc3DmpIdFinderError, MSG_MISSING_PK if p_key.nil?
62
62
 
63
63
  s_key = Helper::DMP_LATEST_VERSION if s_key.nil? || s_key.strip.empty?
64
64
 
65
- client = client.nil? ? Uc3DmpDynamo::Client.new(log_writer: log_writer, debug: debug) : client
65
+ client = client.nil? ? Uc3DmpDynamo::Client.new(debug: debug) : client
66
66
  resp = client.get_item(
67
67
  key: {
68
68
  PK: Helper.append_pk_prefix(dmp: p_key),
@@ -71,13 +71,13 @@ module Uc3DmpId
71
71
  )
72
72
  return nil if resp.nil? || resp.fetch('dmp', {})['PK'].nil?
73
73
 
74
- _append_versions(p_key: resp['dmp']['PK'], dmp: resp, client: client)
74
+ _append_versions(p_key: resp['dmp']['PK'], dmp: resp, client: client, debug: debug)
75
75
  end
76
76
 
77
77
  # Attempt to find the DMP item by the provenance system's identifier
78
78
  # -------------------------------------------------------------------------
79
79
  # rubocop:disable Metrics/AbcSize
80
- def by_provenance_identifier(json:, client: nil, log_writer: nil, debug: false)
80
+ def by_provenance_identifier(json:, client: nil, debug: false)
81
81
  raise Uc3DmpIdFinderError, MSG_MISSING_PROV_ID if json.nil? || json.fetch('dmp_id', {})['identifier'].nil?
82
82
 
83
83
  args = {
@@ -90,7 +90,7 @@ module Uc3DmpId
90
90
  filter_expression: 'SK = :version',
91
91
  expression_attribute_values: { ':version': KeyHelper::DMP_LATEST_VERSION }
92
92
  }
93
- client = client.nil? ? Uc3DmpDynamo::Client.new(log_writer: log_writer, debug: debug) : client
93
+ client = client.nil? ? Uc3DmpDynamo::Client.new(debug: debug) : client
94
94
  resp = client.query(**args)
95
95
  return resp if resp.nil? || resp['dmp'].nil?
96
96
 
@@ -103,10 +103,10 @@ module Uc3DmpId
103
103
 
104
104
  # Build the dmphub_versions array and attach it to the dmp
105
105
  # rubocop:disable Metrics/AbcSize
106
- def _append_versions(p_key:, dmp:, client: nil, log_writer: log_writer, debug: false)
106
+ def _append_versions(p_key:, dmp:, client: nil, debug: false)
107
107
  return dmp if p_key.nil? || !dmp.is_a?(Hash) || dmp['dmp'].nil?
108
108
 
109
- results = versions(p_key: p_key, client: client, log_writer: log_writer, debug: debug)
109
+ results = versions(p_key: p_key, client: client, debug: debug)
110
110
  return dmp unless results.length > 1
111
111
 
112
112
  versions = results.map do |version|
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- class Uc3DmpIdUpdaterError << StandardError; end
4
+ class Uc3DmpIdUpdaterError < StandardError; end
5
5
 
6
6
  class Updater
7
7
  class << self
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- class Uc3DmpIdValidatorError << StandardError; end
4
+ class Uc3DmpIdValidatorError < StandardError; end
5
5
 
6
6
  class Validator
7
7
  # Valid Validation modes are:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.0.6'
4
+ VERSION = '0.0.8'
5
5
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- class Uc3DmpIdVersionerError << StandardError; end
4
+ class Uc3DmpIdVersionerError < StandardError; end
5
5
 
6
6
  class Versioner
7
7
  class << self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley