Giter Club home page Giter Club logo

zenodo's Introduction

NOT ACTIVELY MAINTAINED

Zenodo

A Ruby wrapper for the Zenodo API.

Installation

Add this line to your application's Gemfile:

gem 'zenodo'

And then execute:

$ bundle

Or install it yourself as:

$ gem install zenodo

Due to the use of keyword arguments this gem requires Ruby 2.0 and above.

Configuration

This gem uses VCR for testing. https://github.com/vcr/vcr

To run gem tests complete the following:

  1. Obtain a Zenodo API token from their site. https://zenodo.org.
  2. Create file gem_secret.yml in the gems config folder.
  3. Add the following to your gem_secret.yml file. zenodo_api_key: '<YOUR API TOKEN>'
  4. Run rspec as normal.

VCR will create fixtures in the spec/fixtures/vcr_cassettes folder.

Usage

Set the client API key.

Zenodo.api_key = <your API key>

Get depositions.

depositions = Zenodo.client.get_depositions

Get a deposition.

deposition = Zenodo.client.get_deposition(id: 1)

Create a deposition.

# Build JSON serialized attributes.
# The gem won't do this for you. You need to build a serializer that meets your needs."
deposition_attributes = {
  'metadata' => {
    'title' => 'My first upload',
    'upload_type' => 'poster',
    'description' => 'This is my first upload',
    'creators' =>[{'name' => 'Doe, John','affiliation' => 'ZENODO'}]
  }
}

# Create the deposition.
deposition = Zenodo.client.create_deposition(deposition: deposition_attributes)

Update a deposition.

# Build JSON serialized attributes.
# The gem won't do this for you. You need to build a serializer that meets your needs."
# deposition_attributes = <same as create>

# Update the deposition.
deposition = Zenodo.client.update_deposition(id: 1, deposition: deposition_attributes)

Delete a deposition.

Zenodo.client.delete_deposition(id: 1)

Contributing

  1. Fork it ( https://github.com/sprotocols/zenodo/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

zenodo's People

Contributors

dior001 avatar zdennis avatar

Stargazers

 avatar

zenodo's Issues

Issues running specs

The spec suite seems to be finicky based on Zenodo API behavior which may have changed since this gem was authored, I'm not sure.

For example, deposition_actions_spec.rb#L40-L47 routinely fails because Zenodo has marked the deposition as being in the inprogress state. Trying to edit an inprogress Deposition results in a HTTP 400 Error. I'd link to the section on Zenodo's API but there is no way to link to that particular section). From Zenodo's API this means:

400 Bad Request: Deposition state does not allow for editing (e.g. depositions in state inprogress).

It seems that a Deposition that never gets a file and is never published will always be in the inprogress state. I don't know if this is for certain since it isn't documented, but it's what I've been seeing over the past few days. I have asked the question on Zenodo's Github issue 348.

Related, if you publish a Deposition with a file it will be moved to the done state. This means you should be able to run the "editing of a deposition" example at deposition_actions_spec.rb#L40-L47, and this works intermittently. Quite frequently the example will fail now with a HTTP 409 Conflict error from Zenodo which seems to be:

409 Conflict: Deposition is in the process of being integrated, please wait 5 minutes before trying again.

In order to have green spec suite it seems you need to remove the entire spec/fixtures/vcr_cassettes/ directory (or the specific cassette in question) and re-run the specs until you get lucky and they all pass.

I know this a bit tricky to protect against as this gem is an API wrapper for the Zenodo API and any oddities Zenodo itself has will have a cascading affect on tools that interface with it.

Zenodo::Resources::Object::Attributes lookup is broken

Zenodo::Resources::Object::Attributes lookup is broken, e.g.:

irb> attributes =     {
      'metadata' => {
        'title' => 'My first upload',
        'upload_type' => 'poster',
        'description' => 'This is my first upload',
        'creators' =>[{'name' => 'Doe, Jane','affiliation' => 'ZENODO'}]
      }
    }
irb> deposition = Zenodo.client.create_deposition(deposition:attributes)
(Object doesn't support #inspect)
=>
irb> deposition.inspect
NoMethodError: undefined method `files' for #<Zenodo::Resources::Deposition:0x007fb6f59ce9c0>
    from /Users/zdennis/.rvm/gems/ruby-2.2.1/gems/zenodo-0.0.6/lib/zenodo/resources/object/attributes.rb:55:in `method_missing'
    from /Users/zdennis/.rvm/gems/ruby-2.2.1/gems/zenodo-0.0.6/lib/zenodo/resources/object/attributes.rb:44:in `public_send'
    from /Users/zdennis/.rvm/gems/ruby-2.2.1/gems/zenodo-0.0.6/lib/zenodo/resources/object/attributes.rb:44:in `block (2 levels) in attributes'
    from /Users/zdennis/.rvm/gems/ruby-2.2.1/gems/zenodo-0.0.6/lib/zenodo/resources/object/attributes.rb:42:in `each'
    from /Users/zdennis/.rvm/gems/ruby-2.2.1/gems/zenodo-0.0.6/lib/zenodo/resources/object/attributes.rb:42:in `block in attributes'
    from /Users/zdennis/.rvm/gems/ruby-2.2.1/gems/zenodo-0.0.6/lib/zenodo/resources/object/attributes.rb:41:in `tap'
    from /Users/zdennis/.rvm/gems/ruby-2.2.1/gems/zenodo-0.0.6/lib/zenodo/resources/object/attributes.rb:41:in `attributes'
    from /Users/zdennis/.rvm/gems/ruby-2.2.1/gems/zenodo-0.0.6/lib/zenodo/resources/object.rb:25:in `inspect_attributes'
    from /Users/zdennis/.rvm/gems/ruby-2.2.1/gems/zenodo-0.0.6/lib/zenodo/resources/object.rb:19:in `inspect'
    from (irb):75

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.