zenodo 0.0.1 → 0.0.2
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/.gitignore +1 -0
 - data/lib/zenodo/client.rb +10 -1
 - data/lib/zenodo/dsl.rb +1 -0
 - data/lib/zenodo/dsl/deposition_actions.rb +16 -0
 - data/lib/zenodo/dsl/deposition_files.rb +70 -0
 - data/lib/zenodo/resources.rb +1 -0
 - data/lib/zenodo/resources/deposition_file.rb +9 -0
 - data/lib/zenodo/version.rb +1 -1
 - data/spec/fixtures/test_file_upload.txt +1 -0
 - data/spec/zenodo/dsl/deposition_actions_spec.rb +16 -0
 - data/spec/zenodo/dsl/deposition_files_spec.rb +100 -0
 - data/zenodo.gemspec +1 -0
 - metadata +19 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 760bbc73a127edd08e6a2d032397e17926e56763
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: dfda00d95a5a1eba199f094968903ad76e468bb3
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 5f86205fdf020b77ee74fd7ade072c3ad7f24d95918daf83439984045cefaa3de92d15ef302ee3bec3d3ef3725a07c746337fa5f2eefe5fae06b65fab8f4333f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 1af5d9ada62fb6f04e70d36ea57aa97c28d006eef252038701aee39a821a12f1d20c8ce5242552cfe238ecb919c395f65ef8d03941f0975ee1a2d0ff5f8c0072
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/lib/zenodo/client.rb
    CHANGED
    
    | 
         @@ -22,6 +22,7 @@ module Zenodo 
     | 
|
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
                  # Setup HTTP request connection to Zenodo.
         
     | 
| 
       24 
24 
     | 
    
         
             
                  @connection ||= Faraday.new do |builder|
         
     | 
| 
      
 25 
     | 
    
         
            +
                    builder.request :multipart
         
     | 
| 
       25 
26 
     | 
    
         
             
                    builder.request :url_encoded
         
     | 
| 
       26 
27 
     | 
    
         
             
                    builder.response :logger if Zenodo.logger
         
     | 
| 
       27 
28 
     | 
    
         
             
                    builder.adapter Faraday.default_adapter
         
     | 
| 
         @@ -40,7 +41,15 @@ module Zenodo 
     | 
|
| 
       40 
41 
     | 
    
         
             
                  raise ArgumentError, "Unsupported method #{method.inspect}. Only :get, :post, :put, :delete are allowed" unless REQUESTS.include?(method)
         
     | 
| 
       41 
42 
     | 
    
         | 
| 
       42 
43 
     | 
    
         
             
                  token_url = UrlHelper.build_url(path: "#{URL}#{path}", params: {access_token: @api_key})
         
     | 
| 
       43 
     | 
    
         
            -
                  payload =  
     | 
| 
      
 44 
     | 
    
         
            +
                  payload = nil
         
     | 
| 
      
 45 
     | 
    
         
            +
                  if query.present?
         
     | 
| 
      
 46 
     | 
    
         
            +
                    accept = headers.present? ? headers['Accept'] : nil
         
     | 
| 
      
 47 
     | 
    
         
            +
                    if accept.present? && accept == 'application/json'
         
     | 
| 
      
 48 
     | 
    
         
            +
                      payload = JSON.generate(query)
         
     | 
| 
      
 49 
     | 
    
         
            +
                    else
         
     | 
| 
      
 50 
     | 
    
         
            +
                      payload = query
         
     | 
| 
      
 51 
     | 
    
         
            +
                    end
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
       44 
53 
     | 
    
         
             
                  response = @connection.run_request(method, token_url, payload, headers)
         
     | 
| 
       45 
54 
     | 
    
         | 
| 
       46 
55 
     | 
    
         
             
                  case response.status.to_i
         
     | 
    
        data/lib/zenodo/dsl.rb
    CHANGED
    
    
| 
         @@ -13,7 +13,23 @@ module Zenodo 
     | 
|
| 
       13 
13 
     | 
    
         
             
                end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                # Edit POST deposit/depositions/:id/actions/edit
         
     | 
| 
      
 16 
     | 
    
         
            +
                # Unlock already submitted deposition for editing.
         
     | 
| 
      
 17 
     | 
    
         
            +
                # @param [String, Fixnum] id A deposition's ID.
         
     | 
| 
      
 18 
     | 
    
         
            +
                # @raise [ArgumentError] If the method arguments are blank.
         
     | 
| 
      
 19 
     | 
    
         
            +
                # @return [Zenodo::Resources::deposition, nil].
         
     | 
| 
      
 20 
     | 
    
         
            +
                def edit_deposition(id:)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  raise ArgumentError, "ID cannot be blank" if id.blank?
         
     | 
| 
      
 22 
     | 
    
         
            +
                  Resources::Deposition.parse(request(:post, "deposit/depositions/#{id}/actions/edit", nil, nil))
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
       16 
24 
     | 
    
         | 
| 
       17 
25 
     | 
    
         
             
                # Discard POST deposit/depositions/:id/actions/discard
         
     | 
| 
      
 26 
     | 
    
         
            +
                # Discard changes in the current editing session.
         
     | 
| 
      
 27 
     | 
    
         
            +
                # @param [String, Fixnum] id A deposition's ID.
         
     | 
| 
      
 28 
     | 
    
         
            +
                # @raise [ArgumentError] If the method arguments are blank.
         
     | 
| 
      
 29 
     | 
    
         
            +
                # @return [Zenodo::Resources::deposition, nil].
         
     | 
| 
      
 30 
     | 
    
         
            +
                def discard_deposition(id:)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  raise ArgumentError, "ID cannot be blank" if id.blank?
         
     | 
| 
      
 32 
     | 
    
         
            +
                  Resources::Deposition.parse(request(:post, "deposit/depositions/#{id}/actions/discard", nil, nil))
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
       18 
34 
     | 
    
         
             
              end
         
     | 
| 
       19 
35 
     | 
    
         
             
            end
         
     | 
| 
         @@ -3,15 +3,85 @@ require 'zenodo/dsl' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module Zenodo
         
     | 
| 
       4 
4 
     | 
    
         
             
              module DSL::DepositionFiles
         
     | 
| 
       5 
5 
     | 
    
         
             
                # List GET deposit/depositions/:id/files
         
     | 
| 
      
 6 
     | 
    
         
            +
                # List all deposition files for a given deposition.
         
     | 
| 
      
 7 
     | 
    
         
            +
                # @param [String, Fixnum] id A deposition's ID.
         
     | 
| 
      
 8 
     | 
    
         
            +
                # @raise [ArgumentError] If the method arguments are blank.
         
     | 
| 
      
 9 
     | 
    
         
            +
                # @return [Array, nil].
         
     | 
| 
      
 10 
     | 
    
         
            +
                def get_deposition_files(id:)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  raise ArgumentError, "ID cannot be blank" if id.blank?
         
     | 
| 
      
 12 
     | 
    
         
            +
                  Resources::DepositionFile.parse(request(:get, "deposit/depositions/#{id}/files", nil))
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
       6 
14 
     | 
    
         | 
| 
       7 
15 
     | 
    
         
             
                # Create (upload) POST deposit/depositions/:id/files
         
     | 
| 
      
 16 
     | 
    
         
            +
                # Upload a new file.
         
     | 
| 
      
 17 
     | 
    
         
            +
                # Note the upload will fail if the filename already exists.
         
     | 
| 
      
 18 
     | 
    
         
            +
                # @param [String, Fixnum] id A deposition's ID.
         
     | 
| 
      
 19 
     | 
    
         
            +
                # @param [String] file The file to upload.
         
     | 
| 
      
 20 
     | 
    
         
            +
                # @param [String] filename The name of the file (optional).
         
     | 
| 
      
 21 
     | 
    
         
            +
                # @raise [ArgumentError] If the method arguments are blank.
         
     | 
| 
      
 22 
     | 
    
         
            +
                # @return [Zenodo::Resources::DepositionFile].
         
     | 
| 
      
 23 
     | 
    
         
            +
                def create_deposition_file(id:, file:, filename: '')
         
     | 
| 
      
 24 
     | 
    
         
            +
                  raise ArgumentError, "ID cannot be blank" if id.blank?
         
     | 
| 
      
 25 
     | 
    
         
            +
                  raise ArgumentError, "File cannot be blank" if file.blank?
         
     | 
| 
      
 26 
     | 
    
         
            +
                  content_type = MIME::Types.type_for(file).first.content_type
         
     | 
| 
      
 27 
     | 
    
         
            +
                  io = Faraday::UploadIO.new(file, content_type)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  filename = File.basename(file) if filename.blank?
         
     | 
| 
      
 29 
     | 
    
         
            +
                  Resources::DepositionFile.parse(
         
     | 
| 
      
 30 
     | 
    
         
            +
                    request(:post, "deposit/depositions/#{id}/files", { name: filename, file: io },
         
     | 
| 
      
 31 
     | 
    
         
            +
                      "Content-Type" => "multipart/form-data")
         
     | 
| 
      
 32 
     | 
    
         
            +
                  )
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
       8 
34 
     | 
    
         | 
| 
       9 
35 
     | 
    
         
             
                # Sort PUT deposit/depositions/:id/files
         
     | 
| 
      
 36 
     | 
    
         
            +
                # Sort the files for a deposition. By default, the first file is shown in the file preview.
         
     | 
| 
      
 37 
     | 
    
         
            +
                # @param [String, Fixnum] id A deposition's ID.
         
     | 
| 
      
 38 
     | 
    
         
            +
                # @param [Array] deposition_files The deposition files to sort.
         
     | 
| 
      
 39 
     | 
    
         
            +
                # @raise [ArgumentError] If the method arguments are blank.
         
     | 
| 
      
 40 
     | 
    
         
            +
                # @return [Array, nil].
         
     | 
| 
      
 41 
     | 
    
         
            +
                def sort_deposition_files(id:, deposition_files:)
         
     | 
| 
      
 42 
     | 
    
         
            +
                  raise ArgumentError, "ID cannot be blank" if id.blank?
         
     | 
| 
      
 43 
     | 
    
         
            +
                  raise ArgumentError, "Deposition files cannot be blank" if deposition_files.blank?
         
     | 
| 
      
 44 
     | 
    
         
            +
                  Resources::DepositionFile.parse(request(:put, "deposit/depositions/#{id}/files", deposition_files))
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
       10 
46 
     | 
    
         | 
| 
       11 
47 
     | 
    
         
             
                # Retrieve GET deposit/depositions/:id/files/:file_id
         
     | 
| 
      
 48 
     | 
    
         
            +
                # Retrieve a single deposition file.
         
     | 
| 
      
 49 
     | 
    
         
            +
                # @param [String, Fixnum] id A deposition's ID.
         
     | 
| 
      
 50 
     | 
    
         
            +
                # @param [String] file_id A deposition file ID.
         
     | 
| 
      
 51 
     | 
    
         
            +
                # @raise [ArgumentError] If the method arguments are blank.
         
     | 
| 
      
 52 
     | 
    
         
            +
                # @return [Zenodo::Resources::DepositionFile].
         
     | 
| 
      
 53 
     | 
    
         
            +
                def get_deposition_file(id:, file_id:)
         
     | 
| 
      
 54 
     | 
    
         
            +
                  raise ArgumentError, "ID cannot be blank" if id.blank?
         
     | 
| 
      
 55 
     | 
    
         
            +
                  raise ArgumentError, "File ID cannot be blank" if file_id.blank?
         
     | 
| 
      
 56 
     | 
    
         
            +
                  Resources::DepositionFile.parse(request(:get, "deposit/depositions/#{id}/files/#{file_id}", nil))
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
       12 
58 
     | 
    
         | 
| 
       13 
59 
     | 
    
         
             
                # Update PUT deposit/depositions/:id/files/:file_id
         
     | 
| 
      
 60 
     | 
    
         
            +
                # Update a deposition file resource. Currently the only use is renaming an already uploaded file.
         
     | 
| 
      
 61 
     | 
    
         
            +
                # If you one to replace the actual file, please delete the file and upload a new file.
         
     | 
| 
      
 62 
     | 
    
         
            +
                # @param [String, Fixnum] id A deposition's ID.
         
     | 
| 
      
 63 
     | 
    
         
            +
                # @param [String] file_id A deposition file ID.
         
     | 
| 
      
 64 
     | 
    
         
            +
                # @param [Hash] deposition_file The deposition file to update.
         
     | 
| 
      
 65 
     | 
    
         
            +
                # @raise [ArgumentError] If the method arguments are blank.
         
     | 
| 
      
 66 
     | 
    
         
            +
                # @return [Zenodo::Resources::DepositionFile].
         
     | 
| 
      
 67 
     | 
    
         
            +
                def update_deposition_file(id:, file_id:, deposition_file:)
         
     | 
| 
      
 68 
     | 
    
         
            +
                  raise ArgumentError, "ID cannot be blank" if id.blank?
         
     | 
| 
      
 69 
     | 
    
         
            +
                  raise ArgumentError, "File ID cannot be blank" if file_id.blank?
         
     | 
| 
      
 70 
     | 
    
         
            +
                  raise ArgumentError, "Deposition file cannot be blank" if deposition_file.blank?
         
     | 
| 
      
 71 
     | 
    
         
            +
                  Resources::DepositionFile.parse(request(:put, "deposit/depositions/#{id}/files/#{file_id}", deposition_file))
         
     | 
| 
      
 72 
     | 
    
         
            +
                end
         
     | 
| 
       14 
73 
     | 
    
         | 
| 
       15 
74 
     | 
    
         
             
                # Delete DELETE deposit/depositions/:id/files/:file_id
         
     | 
| 
      
 75 
     | 
    
         
            +
                # Delete an existing deposition file resource.
         
     | 
| 
      
 76 
     | 
    
         
            +
                # Note, only deposition files for unpublished depositions may be deleted.
         
     | 
| 
      
 77 
     | 
    
         
            +
                # @param [String, Fixnum] id A deposition's ID.
         
     | 
| 
      
 78 
     | 
    
         
            +
                # @param [String] file_id A deposition file ID.
         
     | 
| 
      
 79 
     | 
    
         
            +
                # @raise [ArgumentError] If the method arguments are blank.
         
     | 
| 
      
 80 
     | 
    
         
            +
                # @return [Faraday::Response].
         
     | 
| 
      
 81 
     | 
    
         
            +
                def delete_deposition_file(id:, file_id:)
         
     | 
| 
      
 82 
     | 
    
         
            +
                  raise ArgumentError, "ID cannot be blank" if id.blank?
         
     | 
| 
      
 83 
     | 
    
         
            +
                  raise ArgumentError, "File ID cannot be blank" if file_id.blank?
         
     | 
| 
      
 84 
     | 
    
         
            +
                  request(:delete, "deposit/depositions/#{id}/files/#{file_id}", nil, nil)
         
     | 
| 
      
 85 
     | 
    
         
            +
                end
         
     | 
| 
       16 
86 
     | 
    
         
             
              end
         
     | 
| 
       17 
87 
     | 
    
         
             
            end
         
     | 
    
        data/lib/zenodo/resources.rb
    CHANGED
    
    
    
        data/lib/zenodo/version.rb
    CHANGED
    
    
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Hello world
         
     | 
| 
         @@ -29,6 +29,22 @@ describe Zenodo::DSL::DepositionActions do 
     | 
|
| 
       29 
29 
     | 
    
         
             
              end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
              # Edit POST deposit/depositions/:id/actions/edit
         
     | 
| 
      
 32 
     | 
    
         
            +
              describe '#edit_deposition' do
         
     | 
| 
      
 33 
     | 
    
         
            +
                it 'allows editing of a deposition' do
         
     | 
| 
      
 34 
     | 
    
         
            +
                  VCR.use_cassette('edit_deposition') do
         
     | 
| 
      
 35 
     | 
    
         
            +
                    response = Zenodo.client.edit_deposition(id: deposition_id)
         
     | 
| 
      
 36 
     | 
    
         
            +
                    expect(response).to be_a(Deposition)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
       32 
40 
     | 
    
         | 
| 
       33 
41 
     | 
    
         
             
              # Discard POST deposit/depositions/:id/actions/discard
         
     | 
| 
      
 42 
     | 
    
         
            +
              describe '#discard_deposition' do
         
     | 
| 
      
 43 
     | 
    
         
            +
                it 'discards proposed edits of a deposition' do
         
     | 
| 
      
 44 
     | 
    
         
            +
                  VCR.use_cassette('discard_deposition') do
         
     | 
| 
      
 45 
     | 
    
         
            +
                    response = Zenodo.client.discard_deposition(id: deposition_id)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    expect(response).to be_a(Deposition)
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
       34 
50 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,5 +1,105 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe Zenodo::DSL::DepositionFiles do
         
     | 
| 
      
 4 
     | 
    
         
            +
              let(:deposition_attributes) do
         
     | 
| 
      
 5 
     | 
    
         
            +
                {
         
     | 
| 
      
 6 
     | 
    
         
            +
                  'metadata' => {
         
     | 
| 
      
 7 
     | 
    
         
            +
                    'title' => 'My first upload',
         
     | 
| 
      
 8 
     | 
    
         
            +
                    'upload_type' => 'poster',
         
     | 
| 
      
 9 
     | 
    
         
            +
                    'description' => 'This is my first upload',
         
     | 
| 
      
 10 
     | 
    
         
            +
                    'creators' =>[{'name' => 'Doe, John','affiliation' => 'ZENODO'}]
         
     | 
| 
      
 11 
     | 
    
         
            +
                  }
         
     | 
| 
      
 12 
     | 
    
         
            +
                }
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
              let(:deposition_file_attributes) do
         
     | 
| 
      
 15 
     | 
    
         
            +
                {
         
     | 
| 
      
 16 
     | 
    
         
            +
                  'filename' => 'test_file_upload.txt'
         
     | 
| 
      
 17 
     | 
    
         
            +
                }
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
              let!(:file) { File.join(APP_ROOT, 'spec/fixtures/test_file_upload.txt') }
         
     | 
| 
      
 20 
     | 
    
         
            +
              let!(:deposition_id) do
         
     | 
| 
      
 21 
     | 
    
         
            +
                VCR.use_cassette('create_deposition_with_files') do
         
     | 
| 
      
 22 
     | 
    
         
            +
                  deposition = Zenodo.client.create_deposition(deposition: deposition_attributes)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  deposition['id']
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
              let!(:deposition_file_id) do
         
     | 
| 
      
 27 
     | 
    
         
            +
                VCR.use_cassette('create_deposition_file') do
         
     | 
| 
      
 28 
     | 
    
         
            +
                  deposition_file = Zenodo.client.create_deposition_file(
         
     | 
| 
      
 29 
     | 
    
         
            +
                    id: deposition_id, file: file)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  deposition_file['id']
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
              # let!(:deleted_deposition_file_id) do
         
     | 
| 
      
 34 
     | 
    
         
            +
              #   VCR.use_cassette('create_deposition_file_for_deletion') do
         
     | 
| 
      
 35 
     | 
    
         
            +
              #     deposition_file = Zenodo.client.create_deposition_file(
         
     | 
| 
      
 36 
     | 
    
         
            +
              #       id: deposition_id, file: file, filename: 'foobar.txt')
         
     | 
| 
      
 37 
     | 
    
         
            +
              #     deposition_file['id']
         
     | 
| 
      
 38 
     | 
    
         
            +
              #   end
         
     | 
| 
      
 39 
     | 
    
         
            +
              # end
         
     | 
| 
       4 
40 
     | 
    
         | 
| 
      
 41 
     | 
    
         
            +
              # List GET deposit/depositions/:id/files
         
     | 
| 
      
 42 
     | 
    
         
            +
              # describe '#get_deposition_files' do
         
     | 
| 
      
 43 
     | 
    
         
            +
              #   it 'returns a array of files for a deposition' do
         
     | 
| 
      
 44 
     | 
    
         
            +
              #     VCR.use_cassette('get_deposition_files') do
         
     | 
| 
      
 45 
     | 
    
         
            +
              #       deposition_files = Zenodo.client.get_deposition_files(id: deposition_id)
         
     | 
| 
      
 46 
     | 
    
         
            +
              #       expect(deposition_files).to be_a(Array)
         
     | 
| 
      
 47 
     | 
    
         
            +
              #       expect(deposition_files.first).to be_a(DepositionFile)
         
     | 
| 
      
 48 
     | 
    
         
            +
              #     end
         
     | 
| 
      
 49 
     | 
    
         
            +
              #   end
         
     | 
| 
      
 50 
     | 
    
         
            +
              # end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              # Create (upload) POST deposit/depositions/:id/files
         
     | 
| 
      
 53 
     | 
    
         
            +
              describe '#create_deposition_file' do
         
     | 
| 
      
 54 
     | 
    
         
            +
                it 'uploads a file for a deposition' do
         
     | 
| 
      
 55 
     | 
    
         
            +
                  VCR.use_cassette('create_deposition_file') do
         
     | 
| 
      
 56 
     | 
    
         
            +
                    deposition_file = Zenodo.client.create_deposition_file(id: deposition_id, file: file)
         
     | 
| 
      
 57 
     | 
    
         
            +
                    expect(deposition_file).to be_a(DepositionFile)
         
     | 
| 
      
 58 
     | 
    
         
            +
                  end
         
     | 
| 
      
 59 
     | 
    
         
            +
                end
         
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
              # # Sort PUT deposit/depositions/:id/files
         
     | 
| 
      
 63 
     | 
    
         
            +
              # describe '#sort_deposition_files' do
         
     | 
| 
      
 64 
     | 
    
         
            +
              #   it 'sorts files for a deposition' do
         
     | 
| 
      
 65 
     | 
    
         
            +
              #     # VCR.use_cassette('sort_deposition_files') do
         
     | 
| 
      
 66 
     | 
    
         
            +
              #     #   deposition_files = Zenodo.client.sort_deposition_files(
         
     | 
| 
      
 67 
     | 
    
         
            +
              #     #     id: deposition_id, deposition_files: deposition_file_attributes)
         
     | 
| 
      
 68 
     | 
    
         
            +
              #     #   expect(deposition_files).to be_a(Array)
         
     | 
| 
      
 69 
     | 
    
         
            +
              #     #   expect(deposition_files.first).to be_a(DepositionFile)
         
     | 
| 
      
 70 
     | 
    
         
            +
              #     # end
         
     | 
| 
      
 71 
     | 
    
         
            +
              #   end
         
     | 
| 
      
 72 
     | 
    
         
            +
              # end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
              # Retrieve GET deposit/depositions/:id/files/:file_id
         
     | 
| 
      
 75 
     | 
    
         
            +
              describe '#get_deposition_file' do
         
     | 
| 
      
 76 
     | 
    
         
            +
                it 'gets a deposition file' do
         
     | 
| 
      
 77 
     | 
    
         
            +
                  VCR.use_cassette('get_deposition_file') do
         
     | 
| 
      
 78 
     | 
    
         
            +
                    deposition_file = Zenodo.client.get_deposition_file(id: deposition_id, file_id: deposition_file_id)
         
     | 
| 
      
 79 
     | 
    
         
            +
                    expect(deposition_file).to be_a(DepositionFile)
         
     | 
| 
      
 80 
     | 
    
         
            +
                  end
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
              # # Update PUT deposit/depositions/:id/files/:file_id
         
     | 
| 
      
 85 
     | 
    
         
            +
              # describe '#update_deposition_file' do
         
     | 
| 
      
 86 
     | 
    
         
            +
              #   it 'updates a deposition file' do
         
     | 
| 
      
 87 
     | 
    
         
            +
              #     # VCR.use_cassette('update_deposition_file') do
         
     | 
| 
      
 88 
     | 
    
         
            +
              #     #   deposition_file = Zenodo.client.update_deposition_file(
         
     | 
| 
      
 89 
     | 
    
         
            +
              #     #     id: deposition_id, deposition_file_id: deposition_file_id,
         
     | 
| 
      
 90 
     | 
    
         
            +
              #     #     deposition_file: deposition_file_attributes)
         
     | 
| 
      
 91 
     | 
    
         
            +
              #     #   expect(deposition_file).to be_a(DepositionFile)
         
     | 
| 
      
 92 
     | 
    
         
            +
              #     # end
         
     | 
| 
      
 93 
     | 
    
         
            +
              #   end
         
     | 
| 
      
 94 
     | 
    
         
            +
              # end
         
     | 
| 
      
 95 
     | 
    
         
            +
              #
         
     | 
| 
      
 96 
     | 
    
         
            +
              # # Delete DELETE deposit/depositions/:id/files/:file_id
         
     | 
| 
      
 97 
     | 
    
         
            +
              # describe '#delete_deposition_file' do
         
     | 
| 
      
 98 
     | 
    
         
            +
              #   it 'returns a response with code 204' do
         
     | 
| 
      
 99 
     | 
    
         
            +
              #     VCR.use_cassette('delete_deposition_file') do
         
     | 
| 
      
 100 
     | 
    
         
            +
              #       response = Zenodo.client.delete_deposition_file(id: deposition_id, deposition_file_id: deleted_deposition_file_id)
         
     | 
| 
      
 101 
     | 
    
         
            +
              #       expect(response.status).to eq(204)
         
     | 
| 
      
 102 
     | 
    
         
            +
              #     end
         
     | 
| 
      
 103 
     | 
    
         
            +
              #   end
         
     | 
| 
      
 104 
     | 
    
         
            +
              # end
         
     | 
| 
       5 
105 
     | 
    
         
             
            end
         
     | 
    
        data/zenodo.gemspec
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: zenodo
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - David Iorns
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2014-11- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-11-16 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: faraday
         
     | 
| 
         @@ -38,6 +38,20 @@ dependencies: 
     | 
|
| 
       38 
38 
     | 
    
         
             
                - - ">="
         
     | 
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
40 
     | 
    
         
             
                    version: '0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: mime-types
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       41 
55 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
56 
     | 
    
         
             
              name: bundler
         
     | 
| 
       43 
57 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -132,12 +146,14 @@ files: 
     | 
|
| 
       132 
146 
     | 
    
         
             
            - lib/zenodo/errors/resource_not_found_error.rb
         
     | 
| 
       133 
147 
     | 
    
         
             
            - lib/zenodo/resources.rb
         
     | 
| 
       134 
148 
     | 
    
         
             
            - lib/zenodo/resources/deposition.rb
         
     | 
| 
      
 149 
     | 
    
         
            +
            - lib/zenodo/resources/deposition_file.rb
         
     | 
| 
       135 
150 
     | 
    
         
             
            - lib/zenodo/resources/object.rb
         
     | 
| 
       136 
151 
     | 
    
         
             
            - lib/zenodo/resources/object/attributes.rb
         
     | 
| 
       137 
152 
     | 
    
         
             
            - lib/zenodo/resources/object/serializers.rb
         
     | 
| 
       138 
153 
     | 
    
         
             
            - lib/zenodo/utils.rb
         
     | 
| 
       139 
154 
     | 
    
         
             
            - lib/zenodo/utils/url_helper.rb
         
     | 
| 
       140 
155 
     | 
    
         
             
            - lib/zenodo/version.rb
         
     | 
| 
      
 156 
     | 
    
         
            +
            - spec/fixtures/test_file_upload.txt
         
     | 
| 
       141 
157 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       142 
158 
     | 
    
         
             
            - spec/zenodo/client_spec.rb
         
     | 
| 
       143 
159 
     | 
    
         
             
            - spec/zenodo/dsl/deposition_actions_spec.rb
         
     | 
| 
         @@ -169,6 +185,7 @@ signing_key: 
     | 
|
| 
       169 
185 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       170 
186 
     | 
    
         
             
            summary: A Ruby wrapper for the Zenodo API.
         
     | 
| 
       171 
187 
     | 
    
         
             
            test_files:
         
     | 
| 
      
 188 
     | 
    
         
            +
            - spec/fixtures/test_file_upload.txt
         
     | 
| 
       172 
189 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       173 
190 
     | 
    
         
             
            - spec/zenodo/client_spec.rb
         
     | 
| 
       174 
191 
     | 
    
         
             
            - spec/zenodo/dsl/deposition_actions_spec.rb
         
     |