uc3-dmp-s3 0.0.2 → 0.0.3

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: 03efe791449211289f51da782f9dacf96b17603806b43bafd196c6d9ce8ddf90
4
- data.tar.gz: 6a43ca699de4458f0090420886192bf3b7627241875a463d9e6c093bb135d4e6
3
+ metadata.gz: c92a65afbb3240d8b8f8c743335c59f39251d969c9b4a68b2181af490fb08b62
4
+ data.tar.gz: 39ea2a070012dac95f25a22e02941037fbc699e61705c5c0f277d1d70659f68d
5
5
  SHA512:
6
- metadata.gz: c14bbf7a03c2476e1521a5c47499edf2603def467bc24be8309f5ba7aeaf6c67e9023a0b6419c5e8561608c97b4c826234869b80736219e26347b98f414c4567
7
- data.tar.gz: 2c01db4e521000aadb18285830d2007642310d4d882b9acda8454c071792c9e4a87cab6ce9528fca22eba1f8a194d0b5e753d0c38d864f74fbe71ad488851792
6
+ metadata.gz: 36e24653e806818a64ec7cee55eb97b95697e7aa277305ccb33cc6efe6c022fe04588c3d861669f021145264fc24175c7968e4b0b815662c6b2ed741a5430db9
7
+ data.tar.gz: 9f834984c644f01f5a2c1b011ad49bdbe9c4a19889ebef49147c481795e7af34ee23788e441e40fc9bd1db789e3e954e98a2c6190779b579d410f37947dec122
@@ -24,20 +24,18 @@ module Uc3DmpS3
24
24
 
25
25
  class << self
26
26
  # Put the narrative file into the S3 bucket
27
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
28
27
  def put_narrative(document:, dmp_id: nil, base64: false)
29
28
  return nil if !document.is_a?(String) || document.strip.empty? || ENV['S3_BUCKET'].nil?
30
29
 
31
30
  key = "#{NARRATIVE_KEY_PREFIX}#{SecureRandom.hex(8)}.pdf"
32
- tg = dmp_id.nil? ? "PRE-DMP_ID=#{Time.now.strftime('%Y-%m-%d')}" : "DMP_ID=#{CGI.escape(dmp_id)}"
31
+ tg = "DMP_ID=#{CGI.escape(dmp_id)}" unless dmp_id.nil?
33
32
  body = base64 ? Base64.decode64(document) : document
34
33
 
35
- _put_object(key: key, tags: tg, payload: body)
34
+ _put_object(key:, tags: tg, payload: body)
36
35
  rescue Aws::Errors::ServiceError => e
37
- msg = "Unable to write PDF narrative to S3 bucket (dmp_id: #{dmp_id.nil? ? 'PRE-DMP_ID' : dmp_id})"
36
+ msg = "Unable to write PDF narrative to S3 bucket (dmp_id: #{dmp_id})"
38
37
  raise ClientError, "#{msg} - #{e.message}"
39
38
  end
40
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
41
39
 
42
40
  # Fetch the narrative file from the S3 bucket
43
41
  def get_narrative(key:)
@@ -57,7 +55,7 @@ module Uc3DmpS3
57
55
 
58
56
  client = Aws::S3::Client.new(region: ENV.fetch('AWS_REGION', nil))
59
57
  bucket = ENV['S3_BUCKET'].gsub('arn:aws:s3:::', '')
60
- resp = client.put_object({ body: payload, bucket: bucket, key: key, tagging: tags })
58
+ resp = client.put_object({ body: payload, bucket:, key:, tagging: tags })
61
59
  resp.successful? ? key : nil
62
60
  end
63
61
 
@@ -68,7 +66,7 @@ module Uc3DmpS3
68
66
 
69
67
  client = Aws::S3::Client.new(region: ENV.fetch('AWS_REGION', 'us-west-2'))
70
68
  bucket = ENV['S3_BUCKET'].gsub('arn:aws:s3:::', '')
71
- resp = client.get_object({ bucket: bucket, key: key })
69
+ resp = client.get_object({ bucket:, key: })
72
70
  return nil if resp.nil? || !resp.content_length.positive?
73
71
 
74
72
  resp.body.is_a?(String) ? resp.body : resp.body.read
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpS3
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-05-17 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: aws-sdk-s3
@@ -138,7 +138,7 @@ licenses:
138
138
  - MIT
139
139
  metadata:
140
140
  rubygems_mfa_required: 'false'
141
- post_install_message:
141
+ post_install_message:
142
142
  rdoc_options: []
143
143
  require_paths:
144
144
  - lib
@@ -146,15 +146,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
146
  requirements:
147
147
  - - ">="
148
148
  - !ruby/object:Gem::Version
149
- version: '2.7'
149
+ version: '3.2'
150
150
  required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
152
  - - ">="
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubygems_version: 3.1.6
157
- signing_key:
156
+ rubygems_version: 3.4.10
157
+ signing_key:
158
158
  specification_version: 4
159
159
  summary: DMPTool gem that provides general support for accessing the DMPTool S3 Bucket
160
160
  test_files: []