0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
An Engine for Rails (3.1+) that allows you to make your application an OAI-PMH Data Provider. See http://www.openarchives.org/pmh/ and http://www.openarchives.org/OAI/openarchivesprotocol.html#Repository
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
~> 3.1
 Project Readme

OAI Repository¶ ↑

A Rails (3.1+) engine that allows you to expose your models through an OAI-PHM Data Provider interface.

See www.oaforum.org/tutorial/ and www.openarchives.org/OAI/openarchivesprotocol.html#Repository

Installation¶ ↑

If you are using Bundler with your Rails application, then simply add

gem "oai_repository"

and then run bundle install as usual.

Then run the generator

$ rails g oai_repository:install

Configuration¶ ↑

The generator installs a configuration file at config/initializers/oai_repository.rb

The following settings should be edited appropriately:

config.repository_name = 'Test repository'
config.repository_url = 'http://localhost:3000/oai_repository'
config.record_prefix = 'http://localhost:3000/'
config.admin_email = 'root@localhost'
config.limit = 100
config.models = [ Person, Instrument ]

The values for config.models should be the class name of the ActiveRecord model class that is being identified with the given set. It doesn’t actually have to be an ActiveRecord model class, but it should act like one. You must supply at least one model.

The following settings are optional:

config.sets = []
config.additional_formats = []

The items of the sets list should be hash with value for spec, name, model, and optionally description. E.g.

config.sets = [
  {
    spec: 'class:party',
    name: 'Parties',
    model: Person
  },
  {
    spec: 'class:service',
    name: 'Services',
    model: Instrument,
    description: 'Things that are services'
  }
]

By default, an OAI repository must be able to emit its records in OAI_DC (Dublin Core) format. If you want to provide other output formats for your repository (and those formats are subclasses of OAI::Provider::Metadata.Format) then you can specify them here. E.g.

require 'rifcs_format'

config.additional_formats = [
  OAI::Provider::Metadata::RIFCS
]

Instrumenting your Models¶ ↑

OAI DC Format¶ ↑

As a bare minimum, your model classes must implement the following method (or readable attribute)

oai_dc_identifier

This must return a unique value for the whole repository. The format of the unique identifier must correspond to that of the URI (Uniform Resource Identifier) syntax. See www.openarchives.org/OAI/openarchivesprotocol.html#UniqueIdentifier for more details.

You may also supply oai_dc_<value> where <value> is any of

title
creator
subject
description
publisher
contributor
date
type
format
source
language
relation
coverage
rights

See www.openarchives.org/OAI/openarchivesprotocol.html#dublincore for a bit more information on the Dublin Core metadata format.

OAI Sets¶ ↑

A set is an optional construct for grouping items for the purpose of selective harvesting.

You must fill the configuration item config.sets to list the sets your repository uses. This list will be shown in the output of a ListSets request.

If you are grouping your records by set you have two implementation options in your model(s).

If all records from a model will belong to a given set, then simply

include OaiRepository::Set

in your model and all records will belong to the sets from your config.sets mapping.

If you want to be selective about set membership, implement a sets method in your model that responds with the set that a record belongs to. E.g.

def sets
  oai_sets = [ OAI::Set.new({name: 'Tools', spec: 'tools'}) ]
  if name.match('multimeter')
    oai_sets << OAI::Set.new({name: 'Meters', spec: 'meters'})
  end
  oai_sets
end

Mounting the Engine¶ ↑

In your config/routes.rb add

mount OaiRepository::Engine => "/oai_repository"

changing the path as desired.