Class: OAI::Provider::Base
- Inherits:
-
Object
- Object
- OAI::Provider::Base
- Includes:
- OAI::Provider
- Defined in:
- lib/oai/provider.rb
Class Attribute Summary collapse
-
.delete_support ⇒ Object
Returns the value of attribute delete_support.
-
.description ⇒ Object
Returns the value of attribute description.
-
.email ⇒ Object
Returns the value of attribute email.
-
.formats ⇒ Object
readonly
Returns the value of attribute formats.
-
.granularity ⇒ Object
Returns the value of attribute granularity.
-
.identifier ⇒ Object
Returns the value of attribute identifier.
-
.model ⇒ Object
Returns the value of attribute model.
-
.name ⇒ Object
Returns the value of attribute name.
-
.prefix ⇒ Object
Returns the value of attribute prefix.
-
.url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#get_record(options = {}) ⇒ Object
Equivalent to ‘&verb=GetRecord’, returns a record matching the required :identifier option.
-
#identify(options = {}) ⇒ Object
Equivalent to ‘&verb=Identify’, returns information about the repository.
-
#list_identifiers(options = {}) ⇒ Object
Equivalent to ‘&verb=ListIdentifiers’, returns a list of record headers that meet the supplied criteria.
-
#list_metadata_formats(options = {}) ⇒ Object
Equivalent to ‘&verb=ListMetadataFormats’, returns a list of metadata formats supported by the repository.
-
#list_records(options = {}) ⇒ Object
Equivalent to ‘&verb=ListRecords’, returns a list of records that meet the supplied criteria.
-
#list_sets(options = {}) ⇒ Object
Equivalent to ‘&verb=ListSets’, returns a list of sets that are supported by the repository or an error if sets are not supported.
-
#methodize(verb) ⇒ Object
Convert valid OAI-PMH verbs into ruby method calls.
-
#process_request(params = {}) ⇒ Object
xml_response = process_verb(‘ListRecords’, :from => ‘October 1, 2005’, :until => ‘November 1, 2005’).
Class Attribute Details
.delete_support ⇒ Object
Returns the value of attribute delete_support.
245 246 247 |
# File 'lib/oai/provider.rb', line 245 def delete_support @delete_support end |
.description ⇒ Object
Returns the value of attribute description.
245 246 247 |
# File 'lib/oai/provider.rb', line 245 def description @description end |
.email ⇒ Object
Returns the value of attribute email.
245 246 247 |
# File 'lib/oai/provider.rb', line 245 def email @email end |
.formats ⇒ Object (readonly)
Returns the value of attribute formats.
244 245 246 |
# File 'lib/oai/provider.rb', line 244 def formats @formats end |
.granularity ⇒ Object
Returns the value of attribute granularity.
245 246 247 |
# File 'lib/oai/provider.rb', line 245 def granularity @granularity end |
.identifier ⇒ Object
Returns the value of attribute identifier.
245 246 247 |
# File 'lib/oai/provider.rb', line 245 def identifier @identifier end |
.model ⇒ Object
Returns the value of attribute model.
245 246 247 |
# File 'lib/oai/provider.rb', line 245 def model @model end |
.name ⇒ Object
Returns the value of attribute name.
245 246 247 |
# File 'lib/oai/provider.rb', line 245 def name @name end |
.prefix ⇒ Object
Returns the value of attribute prefix.
245 246 247 |
# File 'lib/oai/provider.rb', line 245 def prefix @prefix end |
.url ⇒ Object
Returns the value of attribute url.
245 246 247 |
# File 'lib/oai/provider.rb', line 245 def url @url end |
Class Method Details
.format(prefix) ⇒ Object
256 257 258 259 260 261 262 |
# File 'lib/oai/provider.rb', line 256 def format(prefix) if @formats[prefix].nil? raise OAI::FormatException.new else @formats[prefix] end end |
.format_supported?(prefix) ⇒ Boolean
252 253 254 |
# File 'lib/oai/provider.rb', line 252 def format_supported?(prefix) @formats.keys.include?(prefix) end |
.register_format(format) ⇒ Object
247 248 249 250 |
# File 'lib/oai/provider.rb', line 247 def register_format(format) @formats ||= {} @formats[format.prefix] = format end |
Instance Method Details
#get_record(options = {}) ⇒ Object
Equivalent to ‘&verb=GetRecord’, returns a record matching the required :identifier option
326 327 328 |
# File 'lib/oai/provider.rb', line 326 def get_record( = {}) Response::GetRecord.new(self.class, ).to_xml end |
#identify(options = {}) ⇒ Object
Equivalent to ‘&verb=Identify’, returns information about the repository
296 297 298 |
# File 'lib/oai/provider.rb', line 296 def identify( = {}) Response::Identify.new(self.class, ).to_xml end |
#list_identifiers(options = {}) ⇒ Object
Equivalent to ‘&verb=ListIdentifiers’, returns a list of record headers that meet the supplied criteria.
314 315 316 |
# File 'lib/oai/provider.rb', line 314 def list_identifiers( = {}) Response::ListIdentifiers.new(self.class, ).to_xml end |
#list_metadata_formats(options = {}) ⇒ Object
Equivalent to ‘&verb=ListMetadataFormats’, returns a list of metadata formats supported by the repository.
308 309 310 |
# File 'lib/oai/provider.rb', line 308 def ( = {}) Response::ListMetadataFormats.new(self.class, ).to_xml end |
#list_records(options = {}) ⇒ Object
Equivalent to ‘&verb=ListRecords’, returns a list of records that meet the supplied criteria.
320 321 322 |
# File 'lib/oai/provider.rb', line 320 def list_records( = {}) Response::ListRecords.new(self.class, ).to_xml end |
#list_sets(options = {}) ⇒ Object
Equivalent to ‘&verb=ListSets’, returns a list of sets that are supported by the repository or an error if sets are not supported.
302 303 304 |
# File 'lib/oai/provider.rb', line 302 def list_sets( = {}) Response::ListSets.new(self.class, ).to_xml end |
#methodize(verb) ⇒ Object
Convert valid OAI-PMH verbs into ruby method calls
359 360 361 |
# File 'lib/oai/provider.rb', line 359 def methodize(verb) verb.gsub(/[A-Z]/) {|m| "_#{m.downcase}"}.sub(/^\_/,'') end |
#process_request(params = {}) ⇒ Object
xml_response = process_verb(‘ListRecords’, :from => ‘October 1, 2005’,
:until => 'November 1, 2005')
If you are implementing a web interface using process_request is the preferred way.
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/oai/provider.rb', line 335 def process_request(params = {}) begin # Allow the request to pass in a url self.class.url = params['url'] ? params.delete('url') : self.class.url verb = params.delete('verb') || params.delete(:verb) unless verb and OAI::Const::VERBS.keys.include?(verb) raise OAI::VerbException.new end send(methodize(verb), params) rescue => err if err.respond_to?(:code) Response::Error.new(self.class, err).to_xml else raise err end end end |