Skip to content

Commit b271303

Browse files
johnfcbeer
authored andcommitted
Add extra description support
1 parent a8e2c6a commit b271303

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

lib/oai/provider.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class Base
186186

187187
class << self
188188
attr_reader :formats
189-
attr_accessor :name, :url, :prefix, :email, :delete_support, :granularity, :model, :identifier
189+
attr_accessor :name, :url, :prefix, :email, :delete_support, :granularity, :model, :identifier, :description
190190

191191
def register_format(format)
192192
@formats ||= {}
@@ -221,6 +221,7 @@ def inherited(klass)
221221
alias_method :update_granularity, :granularity=
222222
alias_method :source_model, :model=
223223
alias_method :sample_id, :identifier=
224+
alias_method :extra_description, :description=
224225

225226
end
226227

lib/oai/provider/response/identify.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ def to_xml
2424
r.sampleIdentifier "#{provider.prefix}:#{provider.identifier}"
2525
end
2626
end
27+
if provider.description
28+
r.target! << provider.description
29+
end
2730
end
31+
2832
end
2933
end
3034

test/provider/tc_provider.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ class OaiTest < Test::Unit::TestCase
55
def setup
66
@mapped_provider = MappedProvider.new
77
@big_provider = BigProvider.new
8+
@described_provider = DescribedProvider.new
9+
end
10+
11+
def test_additional_description
12+
doc = REXML::Document.new(@described_provider.identify)
13+
assert_equal "oai:test:13900", doc.elements['OAI-PMH/Identify/description/oai-identifier/sampleIdentifier'].text
14+
assert_not_nil doc.elements['OAI-PMH/Identify/my_custom_xml']
815
end
916

1017
def test_list_identifiers_for_correct_xml

test/provider/test_helper.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,13 @@ class ComplexProvider < Provider::Base
3333
repository_url 'http://localhost'
3434
record_prefix 'oai:test'
3535
source_model ComplexModel.new(100)
36-
end
36+
end
37+
38+
class DescribedProvider < Provider::Base
39+
repository_name 'Described PRovider'
40+
repository_url 'http://localhost'
41+
record_prefix 'oai:test'
42+
source_model SimpleModel.new
43+
sample_id '13900'
44+
extra_description "<my_custom_xml />"
45+
end

0 commit comments

Comments
 (0)