uc3-dmp-s3 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/uc3-dmp-s3/client.rb +5 -7
- data/lib/uc3-dmp-s3/version.rb +1 -1
- metadata +7 -7
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: c92a65afbb3240d8b8f8c743335c59f39251d969c9b4a68b2181af490fb08b62
         | 
| 4 | 
            +
              data.tar.gz: 39ea2a070012dac95f25a22e02941037fbc699e61705c5c0f277d1d70659f68d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 36e24653e806818a64ec7cee55eb97b95697e7aa277305ccb33cc6efe6c022fe04588c3d861669f021145264fc24175c7968e4b0b815662c6b2ed741a5430db9
         | 
| 7 | 
            +
              data.tar.gz: 9f834984c644f01f5a2c1b011ad49bdbe9c4a19889ebef49147c481795e7af34ee23788e441e40fc9bd1db789e3e954e98a2c6190779b579d410f37947dec122
         | 
    
        data/lib/uc3-dmp-s3/client.rb
    CHANGED
    
    | @@ -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 =  | 
| 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 | 
| 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 | 
| 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 | 
| 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 | 
| 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
         | 
    
        data/lib/uc3-dmp-s3/version.rb
    CHANGED
    
    
    
        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. | 
| 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- | 
| 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 | 
| 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. | 
| 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: []
         |