IdigbioClient
idigbio_client
is a Ruby wrapper for iDigBio API
Installation
Add this line to your application's Gemfile:
gem 'idigbio_client'
And then execute:
$ bundle
Or install it yourself as:
$ gem install idigbio_client
Usage
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
Inspect
Methods in this section supply meta-information important for effective use of the client.
Method IdigbioClient.types
Returns an array of types (resources) available via API.
require "idigbio_client"
IdigbioClient.types
# returns ["records", "mediarecords", "recordsets", "publishers"]
Method IdigbioClient.fields(type)
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")
Search
Method IdigbioClient.search(opts)
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
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)
Show
Method: IdigbioClient.show(uuid)
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")
Stats
Method: IdigbioClient.count(opts)
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" } })
Development
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.
Contributing
- 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
Copyright
Authors -- Greg Traub, Dmitry Mozzherin
Copyright (c) 2015 Greg Traub, Dmitry Mozzherin See LICENSE for details.