idigbio_client
is a Ruby wrapper for iDigBio API
Add this line to your application's Gemfile:
gem 'idigbio_client'
And then execute:
$ bundle
Or install it yourself as:
$ gem install idigbio_client
Client functions can be grouped in 4 categories
- inspect - introspective methods
- search - search by provided parameters
- show - show any one object based on its UUID
- stats - various statistical data
Methods in this section supply meta-information important for effective use of the client.
Returns an array of types (resources) available via API.
require "idigbio_client"
IdigbioClient.types
# returns ["records", "mediarecords", "recordsets", "publishers"]
Returns a hash with description of fields associated with a resource. Takes one
optional parameter type
. If type is not given it returns fields to all types
in a hash.
Parameter | Type | Description |
---|---|---|
type | String or Symbol | indicates which type to query for its fields; default nil |
require "idigbio_client"
IdigbioClient.fields
# fields of a specific type
IdigbioClient.fields(:mediarecords)
IdigbioClient.fields("records")
Takes a hash of opts, returns a hash with results of a search.
opts.keys | Type | Description |
---|---|---|
:type | String or Symbol | resource type; default :records |
:params | search options hash; default {} |
params.keys | Description |
---|---|
:rq | search query hash; default {} |
:limit | how many records to return in total; default 100 |
:offset | from which record to start; default 0 |
require "idigbio_client"
# specimen records search
params = { rq: { genus: "acer" }, limit: 15 }
IdigbioClient.search(params: params)
# setting offset: will start count for 15 records from 11th result
params = { rq: { genus: "acer" }, limit: 15, offset: 10 }
IdigbioClient.search(params: params)
# using non-default type
IdigbioClient.search(type: :mediarecords, params: params)
Takes uuid, returns record associated with UUID. Record can be of any type.
Parameters | Type | Description |
---|---|---|
uuid | String | UUID |
require "idigbio_client"
IdigbioClient.show("1c29be70-24e7-480b-aab1-61224ded0f34")
Returns the number of records of a specified type
opts.keys | Type | Description |
---|---|---|
:type | String or Symbol | resource type; default :records |
:params | Hash | search options hash; default {} |
require "idigbio_client"
IdigbioClient.count
IdigbioClient.count(type: :recordsets)
IdigbioClient.count(type: :mediarecords, params: { rq: { genus: "acer" } })
After checking out the repo, run bin/setup
to install dependencies. Then, run
bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To
release a new version, update the version number in version.rb
, and then run
bundle exec rake release
to create a git tag for the version, push git
commits and tags, and push the .gem
file to
rubygems.org.
- Fork it ( https://github.com/[my-github-username]/idigbio_client/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Authors -- Greg Traub, Dmitry Mozzherin
Copyright (c) 2015 Greg Traub, Dmitry Mozzherin See LICENSE for details.