Purée

Metadata extraction from the Pure Research Information System.

Status

Gem Version Build Status Code Climate Dependency Status GitPitch

Installation

Add this line to your application's Gemfile:

gem 'puree'

And then execute:

$ bundle

Or install it yourself as:

$ gem install puree

Usage

The following examples are for the Dataset resource type.

Configuration

Create a hash for passing to an extractor.

# Pure host with authentication.
config = {
  url:      ENV['PURE_URL'],
  username: ENV['PURE_USERNAME'],
  password: ENV['PURE_PASSWORD']
}
# Pure host without authentication.
config = {
  url: ENV['PURE_URL']
}

Resource

Configure an extractor to retrieve data from a Pure host.

dataset_extractor = Puree::Extractor::Dataset.new config

Fetch the metadata for a resource with a particular identifier.

dataset = dataset_extractor.find uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
# =>
#<Puree::Model::Dataset:0x987f7a4>

Access specific metadata e.g. an internal person's name.

dataset.persons_internal[0].name
# =>
#<Puree::Model::PersonName:0x9add67c @first="Foo", @last="Bar">

Select a formatting style for a person's name.

dataset.persons_internal[0].name.last_initial
# =>
# "Bar, F."

Collection

Configure a collection extractor to retrieve data from a Pure host.

collection_extractor = Puree::Extractor::Collection.new config:   config,
                                                        resource: :dataset

Fetch a bunch of resources.

dataset_collection = collection_extractor.find limit: 2
# =>
#<Puree::Model::Dataset:0xa62fd90>
#<Puree::Model::Dataset:0xa5e8c24>

Fetch a random resource from the entire collection.

random_dataset = collection_extractor.random_resource
# =>
#<Puree::Model::Dataset:0x97998bc>