GithubHelp home page GithubHelp logo

ebarra / oai_repository Goto Github PK

View Code? Open in Web Editor NEW

This project forked from intersectaustralia/oai_repository

0.0 2.0 0.0 166 KB

An engine for Rails 3.1+ that enables you provide an OAI repository.

License: MIT License

Ruby 91.65% JavaScript 4.51% CSS 3.85%

oai_repository's Introduction

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.

oai_repository's People

Contributors

przemyslawp avatar seandmccarthy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.