Class: OaiPmh::Provider
- Inherits:
-
Object
show all
- Includes:
- Helpers
- Defined in:
- lib/oaipmh/provider.rb
Constant Summary
collapse
- AVAILABLE_FORMATS =
{}
- @@options =
{}
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.
155
156
157
|
# File 'lib/oaipmh/provider.rb', line 155
def initialize
@config = OaiPmh::Const::DEFAULTS.merge(@@options)
end
|
Class Method Details
.model(value) ⇒ Object
149
150
151
|
# File 'lib/oaipmh/provider.rb', line 149
def model(value)
@@options[:model] = value
end
|
Instance Method Details
#get_record(id, opts = {}) ⇒ Object
171
172
173
|
# File 'lib/oaipmh/provider.rb', line 171
def get_record(id, opts = {})
process_verb 'GetRecord', opts.merge(:id => id)
end
|
#identify ⇒ Object
159
160
161
|
# File 'lib/oaipmh/provider.rb', line 159
def identify
process_verb 'Identify'
end
|
#list_identifiers(opts = {}) ⇒ Object
175
176
177
|
# File 'lib/oaipmh/provider.rb', line 175
def list_identifiers(opts = {})
process_verb 'ListIdentifiers', opts
end
|
163
164
165
|
# File 'lib/oaipmh/provider.rb', line 163
def list_metadata_formats
process_verb 'ListMetadataFormats'
end
|
#list_records(opts = {}) ⇒ Object
179
180
181
|
# File 'lib/oaipmh/provider.rb', line 179
def list_records(opts = {})
process_verb 'ListRecords', opts
end
|
#list_sets(opts = {}) ⇒ Object
167
168
169
|
# File 'lib/oaipmh/provider.rb', line 167
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
187
188
189
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
|
# File 'lib/oaipmh/provider.rb', line 187
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
|