bark

Continuous Integration Status Dependency Status rubydoc

Bark is a Ruby Gem wrapper on the Open Tree of Life API. It was written over the course of the OpenTree hackathon At present it seeks to provide a simple (level 1 in terms of hackathon speak) wrapper over all of the API calls available, returning a native json object for each response. It also acts as a sanity checker on the API calls themselves, running a suite of unit tests shared by related wrappers in Python and R.

Installation

Bark is written targetting Ruby 2.1.x.

Add this line to your application's Gemfile:

gem 'bark'

And then execute:

$ bundle

Or install it yourself as:

$ gem install bark

Usage

Bark is broken down into Request and Response objects. These are additionally wrapped with a set of helper methods that map 1:1 with the Open Tree URLs. Binding method names follow a convention adopted by the related Python and R frameworks.

In your script:

  require 'bark'  # => true

Simple usage

  Bark.tol_about  # => { big hash }

Pass parameters like so:

  Bark.get_study(params: {:study_id => '2113'})   # => {big json response}

Parameter keys can be symbols or strings. Available methods are listed here.

Request/Response style

    request = Bark::Request::Studies.new(method: :get_study, params: {study_id: '2113'})  # => #<Bark::Request::Studies:0x0000010310d340 @method=:get_study, @params={:study_id=>"2113"}, @uri=#<URI::HTTP:0x0000010310c508 URL:http://devapi.opentreeoflife.org/v2/study/2113>> 

Pre-check the validity of the requst (NOTE: mapping/checking is in development)

    request.valid? # => true 

Get a response:

    response = Bark::Response.new(request: request)  # =>  #<Bark::Response:0x0000010334c138 @json={ ... big response ... }
    response.json   # =>  { ... big response ... }

Documentation

Documentation is autogenerated at RubyDoc.info

Contributing

  1. Fork it ( http://github.com/SpeciesFileGroup/bark/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 new Pull Request

Licence

Bark is open source, it is available under the BSD licence.