dina 3.1.3.0 → 3.2.0.0
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/dina/models/object_store/file.rb +2 -0
- data/lib/dina/models/object_store/file_connection.rb +37 -26
- data/lib/dina/version.rb +2 -2
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b352cf3c52493540a1f8089e292d1eb5a24e178330796c9d8548ea2fd04a555e
         | 
| 4 | 
            +
              data.tar.gz: 592c57a9d91d6853b5ebf4bf10502f316a31f40c660e9525c83f6f31ab6ec8a4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 42f07765799ef8bfdf9d04b01b2fea2623f41ded4298e42ab7e53996ba8ed4d30d625c2a23160b4bab7cfe9e63c16498ad04d54d0d7428d4be907489a8a9405c
         | 
| 7 | 
            +
              data.tar.gz: 72d908349ce9f90f07f52135fe44fcb2f2f960bc87cd2acb1f81233508bac9206593568a0a0adf2534586995b0386bfb6dcb79ad6547714c1ac35441a0b9f3c6
         | 
| @@ -5,6 +5,8 @@ module Dina | |
| 5 5 | 
             
              class File < BaseModel
         | 
| 6 6 | 
             
                self.connection_class = FileConnection
         | 
| 7 7 |  | 
| 8 | 
            +
                custom_endpoint :download, on: :collection, request_method: :get
         | 
| 9 | 
            +
             | 
| 8 10 | 
             
                property :id, type: :string, default: SecureRandom.uuid_v7
         | 
| 9 11 | 
             
                property :group, type: :string
         | 
| 10 12 | 
             
                property :filePath, type: :string
         | 
| @@ -17,33 +17,44 @@ module Dina | |
| 17 17 | 
             
                end
         | 
| 18 18 |  | 
| 19 19 | 
             
                def run(request_method, path, params: nil, headers: {}, body: nil)
         | 
| 20 | 
            -
                   | 
| 21 | 
            -
             | 
| 22 | 
            -
                     | 
| 20 | 
            +
                  if request_method == :get && path == "file/download"
         | 
| 21 | 
            +
                    path = "file" + "/#{params[:group]}/#{params[:fileId]}"
         | 
| 22 | 
            +
                    if params[:isDerivative]
         | 
| 23 | 
            +
                      path = "file" + "/#{params[:group]}/derivative/#{params[:fileId]}"
         | 
| 24 | 
            +
                    end
         | 
| 25 | 
            +
                    headers[:content_type] = "application/octet-stream"
         | 
| 26 | 
            +
                    response = @faraday.run_request(request_method, path, body, headers) do |request|
         | 
| 27 | 
            +
                    end
         | 
| 28 | 
            +
                    response
         | 
| 29 | 
            +
                  else
         | 
| 30 | 
            +
                    path = path + "/#{body[:data]["attributes"]["group"].downcase}"
         | 
| 31 | 
            +
                    if body[:data]["attributes"].key?("isDerivative")
         | 
| 32 | 
            +
                      path = path + "/derivative"
         | 
| 33 | 
            +
                    end
         | 
| 34 | 
            +
                    file_path = body[:data]["attributes"]["filePath"]
         | 
| 35 | 
            +
                    mime_type = body[:data]["attributes"]["dcFormat"]
         | 
| 36 | 
            +
                    file_name = body[:data]["attributes"]["fileName"]
         | 
| 37 | 
            +
                    
         | 
| 38 | 
            +
                    body[:file] = Faraday::Multipart::FilePart.new(
         | 
| 39 | 
            +
                      file_path,
         | 
| 40 | 
            +
                      mime_type,
         | 
| 41 | 
            +
                      file_name
         | 
| 42 | 
            +
                    )
         | 
| 43 | 
            +
              
         | 
| 44 | 
            +
                    response = @faraday.run_request(request_method, path, body, headers) do |request|
         | 
| 45 | 
            +
                      request.params.update(params) if params
         | 
| 46 | 
            +
                    end
         | 
| 47 | 
            +
                    attributes = response.body.dup
         | 
| 48 | 
            +
                    response.body["meta"] = {}
         | 
| 49 | 
            +
                    response.body["errors"] = []
         | 
| 50 | 
            +
                    response.body["data"] = { 
         | 
| 51 | 
            +
                      "id" => attributes["uuid"],
         | 
| 52 | 
            +
                      "type" => "file",
         | 
| 53 | 
            +
                      "relationships" => {},
         | 
| 54 | 
            +
                      "attributes" => attributes
         | 
| 55 | 
            +
                    }
         | 
| 56 | 
            +
                    response
         | 
| 23 57 | 
             
                  end
         | 
| 24 | 
            -
                  file_path = body[:data]["attributes"]["filePath"]
         | 
| 25 | 
            -
                  mime_type = body[:data]["attributes"]["dcFormat"]
         | 
| 26 | 
            -
                  file_name = body[:data]["attributes"]["fileName"]
         | 
| 27 | 
            -
                  
         | 
| 28 | 
            -
                  body[:file] = Faraday::Multipart::FilePart.new(
         | 
| 29 | 
            -
                    file_path,
         | 
| 30 | 
            -
                    mime_type,
         | 
| 31 | 
            -
                    file_name
         | 
| 32 | 
            -
                  )
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                  response = @faraday.run_request(request_method, path, body, headers) do |request|
         | 
| 35 | 
            -
                    request.params.update(params) if params
         | 
| 36 | 
            -
                  end
         | 
| 37 | 
            -
                  attributes = response.body.dup
         | 
| 38 | 
            -
                  response.body["meta"] = {}
         | 
| 39 | 
            -
                  response.body["errors"] = []
         | 
| 40 | 
            -
                  response.body["data"] = { 
         | 
| 41 | 
            -
                    "id" => attributes["uuid"],
         | 
| 42 | 
            -
                    "type" => "file",
         | 
| 43 | 
            -
                    "relationships" => {},
         | 
| 44 | 
            -
                    "attributes" => attributes
         | 
| 45 | 
            -
                  }
         | 
| 46 | 
            -
                  response
         | 
| 47 58 | 
             
                end
         | 
| 48 59 |  | 
| 49 60 | 
             
              end
         | 
    
        data/lib/dina/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: dina
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 3. | 
| 4 | 
            +
              version: 3.2.0.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - David P. Shorthouse
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire:
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2025-03-24 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: json_api_client
         | 
| @@ -230,7 +230,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 230 230 | 
             
              requirements:
         | 
| 231 231 | 
             
              - - ">="
         | 
| 232 232 | 
             
                - !ruby/object:Gem::Version
         | 
| 233 | 
            -
                  version: '3. | 
| 233 | 
            +
                  version: '3.1'
         | 
| 234 234 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 235 235 | 
             
              requirements:
         | 
| 236 236 | 
             
              - - ">="
         |