Skip to content

Commit 663fc72

Browse files
committed
Changes to support 1.9
1 parent 4efba69 commit 663fc72

5 files changed

Lines changed: 12 additions & 13 deletions

File tree

lib/oai/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def load_document(xml)
199199
begin
200200
return REXML::Document.new(xml)
201201
rescue REXML::ParseException => e
202-
raise OAI::Exception, 'response not well formed XML: '+e, caller
202+
raise OAI::Exception, 'response not well formed XML: '+e.message, caller
203203
end
204204
end
205205
end

lib/oai/provider/metadata_format.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ def encode(model, record)
5656
def value_for(field, record, map)
5757
method = map[field] ? map[field].to_s : field.to_s
5858

59-
methods = record.public_methods(false)
60-
if methods.include?(pluralize(method))
59+
if record.respond_to?(pluralize(method))
6160
record.send pluralize(method)
62-
elsif methods.include?(method)
61+
elsif record.respond_to?(method)
6362
record.send method
6463
else
6564
[]
@@ -87,6 +86,7 @@ def pluralize(word)
8786
'move' => 'moves', 'cow' => 'kine' }.each { |k,v| return v if word == k }
8887

8988
rules.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
89+
result
9090
end
9191

9292
def rules

lib/oai/provider/response/identify.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ def to_xml
88
r.repositoryName provider.name
99
r.baseURL provider.url
1010
r.protocolVersion 2.0
11-
provider.email.each do |address|
12-
r.adminEmail address
13-
end if provider.email
11+
if provider.email and provider.email.respond_to?(:each)
12+
provider.email.each { |address| r.adminEmail address }
13+
else
14+
r.adminEmail provider.email.to_s
15+
end
1416
r.earliestDatestamp provider.model.earliest
1517
r.deletedRecord provider.delete_support.to_s
1618
r.granularity provider.granularity

test/client/tc_utf8_escaping.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class UTF8Test < Test::Unit::TestCase
44

55
def test_escaping_invalid_utf_8_characters
6-
client = OAI::Client.new 'http://localhost:3333/oai', :parser => 'libxml'
6+
client = OAI::Client.new 'http://localhost:3333/oai' #, :parser => 'libxml'
77
invalid_utf_8 = [2, 3, 4, 104, 5, 101, 6, 108, 66897, 108, 66535, 111, 1114112, 33, 55234123, 33].pack("U*")
88
assert_equal("hello!!", client.send(:strip_invalid_utf_8_chars, invalid_utf_8).gsub(/\?/, ''))
99
end

test/client/tc_xpath.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_rexml
1313
def test_libxml
1414
begin
1515
require 'xml/libxml'
16-
rescue
16+
rescue LoadError
1717
# libxml not available so nothing to test!
1818
return
1919
end
@@ -23,7 +23,4 @@ def test_libxml
2323
assert_equal xpath(doc, './/foobar'), nil
2424
end
2525

26-
end
27-
28-
__END__
29-
26+
end

0 commit comments

Comments
 (0)