uc3-dmp-dynamo 0.0.2 → 0.0.4

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: 931c83483fd3fab4e5a82c3bcf082fb061ac7a5480711207d338ef7a1d4c47e9
4
- data.tar.gz: 38f70ff121f7a86de6e7ef8575b9e9764021ea0e14cf630f6061dc75ceb45653
3
+ metadata.gz: 8a3537f8c5fd1ccbf238e6f1229eba643ae138e5e2c5c0231a77bd04981a4e11
4
+ data.tar.gz: a62767c144ff42c1c1b8e07b526fb6bb804d1a23a58aaa7585ec0c5a4444b4e7
5
5
  SHA512:
6
- metadata.gz: 4eec21772847d22cee60f0a1a42b84d7e7d038ba77aeb598e6a496af8b777524a41ae925f272896ad879f8bbceb435be773156ea1ec3da6b1a1c1a65ccd9e1f1
7
- data.tar.gz: 90ff1b4ea36e4acce0cd16d9813f1902ead32663eab4974f4b42860c783c2478056531a99e85e39654a5a00b947f750d2702f355d5b88deb3db677704b005f47
6
+ metadata.gz: c0bd6548948a7171ad141987d0826b20af106d796ac42ff3ef2327ddb1acf6fd9003e8cdd9abecbf23f791d2ea4387fd169294cbf1582cb7fa72a7bc8c6e7846
7
+ data.tar.gz: 69578c3575ba0984ad86330c2179086f7ce930ba2bb05a0e158241796733a112d3099b0b0a2ab12e49ee4f150ebcb9b112eee1f345bde45e6cf1e586c0df0768
@@ -16,21 +16,20 @@ module Uc3DmpDynamo
16
16
  MSG_MISSING_TABLE = 'No Dynamo Table defined! Looking for `ENV[\'DYNAMO_TABLE\']`'
17
17
  MSG_DYNAMO_ERROR = 'Dynamo DB Table Error - %{msg} - %{trace}'
18
18
 
19
- attr_accessor: :connection, :table, :log_writer
19
+ attr_accessor :connection, :table
20
20
 
21
21
  def initialize(**args)
22
22
  @table = ENV['DYNAMO_TABLE']
23
23
  raise Uc3DmpDynamoError, MSG_MISSING_TABLE if @table.nil?
24
24
 
25
- @log_writer = args[:log_writer]
26
- @connection = args.fetch(:client, Aws::DynamoDB::Client.new(region: ENV.fetch('AWS_REGION', 'us-west-2')))
25
+ @connection = Aws::DynamoDB::Client.new(region: ENV.fetch('AWS_REGION', 'us-west-2'))
27
26
  end
28
27
 
29
28
  # Fetch a single item
30
29
  def get_item(key:, debug: false)
31
30
  raise Uc3DmpDynamoError, MSG_INVALID_KEY unless key.is_a?(Hash)
32
31
 
33
- resp = @client.get_item(
32
+ resp = @connection.get_item(
34
33
  { table_name: @table,
35
34
  key: key,
36
35
  consistent_read: false,
@@ -38,8 +37,9 @@ module Uc3DmpDynamo
38
37
  }
39
38
  )
40
39
  # If debug is enabled then write the response to the LogWriter
41
- if debug && @log_writer
42
- @log_writer.log_message(source: SOURCE, message: "get_item - #{key}", details: resp[:item].first)
40
+ if debug
41
+ puts "#{SOURCE} => get_item - #{key}"
42
+ puts resp[:item].first.inspect
43
43
  end
44
44
  resp[:item].first
45
45
  rescue Aws::Errors::ServiceError => e
@@ -69,11 +69,12 @@ module Uc3DmpDynamo
69
69
  hash[key.to_sym] = args[key.to_sym]
70
70
  end
71
71
 
72
- resp = @client.query(hash)
72
+ resp = @connection.query(hash)
73
73
  # If debug is enabled then write the response to the LogWriter
74
- if debug && @log_writer
75
- msg = "query - key_conditions: #{key_conditions}, projection_expression: #{projection_expression}"
76
- @log_writer.log_message(source: SOURCE, message: msg, details: resp.items)
74
+ if debug
75
+ msg = "query - args: #{args}"
76
+ puts "#{SOURCE} => query - args: #{args.inspect}"
77
+ puts resp.items.inspect
77
78
  end
78
79
  resp.items
79
80
  rescue Aws::Errors::ServiceError => e
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpDynamo
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-dynamo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley