Class: OaiPmh::Provider
- Inherits:
-
Object
show all
- Includes:
- Helpers
- Defined in:
- lib/oaipmh/provider.rb
Constant Summary
collapse
- AVAILABLE_FORMATS =
{}
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Helpers
#build_scope_hash, #echo_params, #ensure_valid, #header, #parse_date
Constructor Details
Returns a new instance of Provider.
Class Attribute Details
.options ⇒ Object
Returns the value of attribute options.
138
139
140
|
# File 'lib/oaipmh/provider.rb', line 138
def options
@options
end
|
Class Method Details
.model(value) ⇒ Object
140
141
142
143
|
# File 'lib/oaipmh/provider.rb', line 140
def model(value)
self.options ||={}
self.options[:model] = value
end
|
Instance Method Details
#get_record(id, opts = {}) ⇒ Object
174
175
176
|
# File 'lib/oaipmh/provider.rb', line 174
def get_record(id, opts = {})
process_verb 'GetRecord', opts.merge(:id => id)
end
|
#identify ⇒ Object
162
163
164
|
# File 'lib/oaipmh/provider.rb', line 162
def identify
process_verb 'Identify'
end
|
#list_identifiers(opts = {}) ⇒ Object
178
179
180
|
# File 'lib/oaipmh/provider.rb', line 178
def list_identifiers(opts = {})
process_verb 'ListIdentifiers', opts
end
|
166
167
168
|
# File 'lib/oaipmh/provider.rb', line 166
def list_metadata_formats
process_verb 'ListMetadataFormats'
end
|
#list_records(opts = {}) ⇒ Object
182
183
184
|
# File 'lib/oaipmh/provider.rb', line 182
def list_records(opts = {})
process_verb 'ListRecords', opts
end
|
#list_sets(opts = {}) ⇒ Object
170
171
172
|
# File 'lib/oaipmh/provider.rb', line 170
def list_sets(opts = {})
process_verb 'ListSets', opts
end
|
#process_verb(verb = nil, opts = {}) ⇒ Object
xml_response = process_verb(‘ListRecords’, :from => ‘October’, :until => ‘November’) # thanks Chronic!
If you are implementing a web interface using process_verb is the preferred way. See extensions/camping.rb
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
# File 'lib/oaipmh/provider.rb', line 190
def process_verb(verb = nil, opts = {})
do
begin
raise VerbException.new unless verb &&
OaiPmh::Const::VERBS.keys.include?(verb)
@url = opts['url'] ? opts.delete('url') : @config[:url]
echo_params(verb, opts)
@opts = ensure_valid(verb, opts)
@model = @config[:model]
@format = @opts[:prefix] ? @opts[:prefix] : "oai_dc"
call = verb.gsub(/[A-Z]/) {|m| "_#{m.downcase}"}.sub(/^\_/,'')
send("#{call}_response")
rescue
if $!.respond_to?(:code)
@xml.error $!.to_s, :code => $!.code
else
puts $!.message
puts $!.backtrace.join("\n")
end
end
end
end
|