# = README # # Copyright © 2006 William Groppe # # Will Groppe [email protected] # # Open Archives Initiative - Protocol for Metadata Harvesting see # www.openarchives.org/ # # === Features # * Easily setup a simple repository # * Simple integration with ActiveRecord # * Dublin Core metadata format included # * Easily add addition metadata formats # * Adaptable to any data source # # # === Current shortcomings # * No resumption tokens # * Doesn’t validate metadata # * No deletion support # * Many others I can’t think of right now. :-) # # # === ActiveRecord integration # # To successfully use ActiveRecord as a OAI PMH datasource the database table # should include an updated_at column so that updates to the table are # tracked by ActiveRecord. This provides much of the base functionality for # selecting update periods. # # To understand how the data is extracted from the AR model it’s best to just # go thru the logic: # # Does the model respond to ‘to_prefix’? Where prefix is the # metadata prefix. If it does then just include the response from # the model. So if you want to provide custom or complex metadata you can # simply define a ‘to_prefix’ method on your model. # # Example: # # class Record < ActiveRecord::Base # # def to_oai_dc # xml = Builder::XmlMarkup.new # xml.tag!(‘oai_dc:dc’, # ‘xmlns:oai_dc’ => “www.openarchives.org/OAI/2.0/oai_dc/”, # ‘xmlns:dc’ => “purl.org/dc/elements/1.1/”, # ‘xmlns:xsi’ => “www.w3.org/2001/XMLSchema-instance”, # ‘xsi:schemaLocation’ => # %http://www.openarchives.org/OAI/2.0/oai_dc) do # # xml.oai_dc :title, title # xml.oai_dc :subject, subject # end # xml.to_s # end # # end # # If the model doesn’t define a ‘to_prefix’ then start iterating thru # the defined metadata fields. # # Grab a mapping if one exists by trying to call ‘map_prefix’. # # Now do the iteration and try calling methods on the model that match # the field names, or the mapped field names. # # So with Dublin Core we end up with the following: # # 1. Check for ‘title’ mapped to a different method. # 2. Call model.titles - try plural # 3. Call model.title - try singular last # # Extremely contrived Blog example: # # class Post < ActiveRecord::Base # def map_oai_dc # => :tags, # :description => :text, # :creator => :user, # :contibutor => :comments # end # end # # === Supporting custom metadata # # See OaiPmh::Metadata for details. # # == Examples # # === Sub classing a provider # # class MyProvider < OaiPmh::Provider # name ‘My little OAI provider’ # url ‘localhost/provider’ # prefix ‘oai:localhost’ # email ‘root@localhost’ # String or Array # deletes ‘no’ # future versions will support deletes # granularity ‘YYYY-MM-DDThh:mm:ssZ’ # update resolution # model MyModel # Class to get data from # end # # # Now use it # # provider = MyProvider.new # provider.identify # provider.list_sets # provider.list_metadata_formats # # these verbs require a working model # provider.list_identifiers # provider.list_records # provider.get_record(‘oai:localhost/1’) # # # === Configuring the default provider # # class OaiPmh::Provider # name ‘My little OAI Provider’ # url ‘localhost/provider’ # prefix ‘oai:localhost’ # email ‘root@localhost’ # String or Array # deletes ‘no’ # future versions will support deletes # granularity ‘YYYY-MM-DDThh:mm:ssZ’ # update resolution # model MyModel # Class to get data from # end # #