Skip to content

Commit a8e2c6a

Browse files
johnfcbeer
authored andcommitted
Add sampleIdentifier to Identify
1 parent a68161e commit a8e2c6a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/oai/provider.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
# repository_url 'http://localhost/provider'
5656
# record_prefix 'oai:localhost'
5757
# admin_email 'root@localhost'
58+
# sample_identifier 'oai:pubmedcentral.gov:13900'
5859
# source_model MyModel.new
5960
# end
6061
#
@@ -97,6 +98,7 @@
9798
# record_prefix 'oai:blog'
9899
# admin_email 'root@localhost'
99100
# source_model OAI::Provider::ActiveRecordWrapper.new(Post)
101+
# sample_identifier 'oai:pubmedcentral.gov:13900'
100102
# end
101103
#
102104
# Create a custom controller:
@@ -184,7 +186,7 @@ class Base
184186

185187
class << self
186188
attr_reader :formats
187-
attr_accessor :name, :url, :prefix, :email, :delete_support, :granularity, :model
189+
attr_accessor :name, :url, :prefix, :email, :delete_support, :granularity, :model, :identifier
188190

189191
def register_format(format)
190192
@formats ||= {}
@@ -218,6 +220,7 @@ def inherited(klass)
218220
alias_method :deletion_support, :delete_support=
219221
alias_method :update_granularity, :granularity=
220222
alias_method :source_model, :model=
223+
alias_method :sample_id, :identifier=
221224

222225
end
223226

@@ -228,6 +231,7 @@ def inherited(klass)
228231
Base.admin_email 'nobody@localhost'
229232
Base.deletion_support OAI::Const::Delete::TRANSIENT
230233
Base.update_granularity OAI::Const::Granularity::HIGH
234+
Base.sample_id '13900'
231235

232236
Base.register_format(OAI::Provider::Metadata::DublinCore.instance)
233237

lib/oai/provider/response/identify.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ def to_xml
1616
r.earliestDatestamp Time.parse(provider.model.earliest.to_s).utc.xmlschema
1717
r.deletedRecord provider.delete_support.to_s
1818
r.granularity provider.granularity
19+
r.description do
20+
r.tag! 'oai-identifier', 'xmlns' => 'http://www.openarchives.org/OAI/2.0/oai-identifier', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'http://www.openarchives.org/OAI/2.0/oai-identifier http://www.openarchives.org/OAI/2.0/oai-identifier.xsd' do
21+
r.scheme 'oai'
22+
r.repositoryIdentifier provider.prefix.gsub(/oai:/, '')
23+
r.delimiter ':'
24+
r.sampleIdentifier "#{provider.prefix}:#{provider.identifier}"
25+
end
26+
end
1927
end
2028
end
2129
end

0 commit comments

Comments
 (0)