Skip to content

SpeciesFileGroup/bark

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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:https://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.

About

A Ruby Gem wrapper on the Open Tree of Life API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages