oai 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README +80 -0
- data/Rakefile +113 -0
- data/bin/oai +68 -0
- data/examples/models/file_model.rb +63 -0
- data/examples/providers/dublin_core.rb +474 -0
- data/lib/oai.rb +7 -13
- data/lib/oai/client.rb +133 -83
- data/lib/oai/{get_record.rb → client/get_record.rb} +0 -0
- data/lib/oai/{header.rb → client/header.rb} +2 -2
- data/lib/oai/{identify.rb → client/identify.rb} +0 -0
- data/lib/oai/{list_identifiers.rb → client/list_identifiers.rb} +0 -0
- data/lib/oai/{list_metadata_formats.rb → client/list_metadata_formats.rb} +0 -0
- data/lib/oai/{list_records.rb → client/list_records.rb} +0 -0
- data/lib/oai/{list_sets.rb → client/list_sets.rb} +1 -1
- data/lib/oai/{metadata_format.rb → client/metadata_format.rb} +0 -0
- data/lib/oai/{record.rb → client/record.rb} +0 -0
- data/lib/oai/{response.rb → client/response.rb} +1 -1
- data/lib/oai/constants.rb +34 -0
- data/lib/oai/exception.rb +72 -1
- data/lib/oai/harvester.rb +38 -0
- data/lib/oai/harvester/config.rb +41 -0
- data/lib/oai/harvester/harvest.rb +144 -0
- data/lib/oai/harvester/logging.rb +70 -0
- data/lib/oai/harvester/mailer.rb +17 -0
- data/lib/oai/harvester/shell.rb +334 -0
- data/lib/oai/provider.rb +300 -0
- data/lib/oai/provider/metadata_format.rb +72 -0
- data/lib/oai/provider/metadata_format/oai_dc.rb +29 -0
- data/lib/oai/provider/model.rb +71 -0
- data/lib/oai/provider/model/activerecord_caching_wrapper.rb +135 -0
- data/lib/oai/provider/model/activerecord_wrapper.rb +136 -0
- data/lib/oai/provider/partial_result.rb +18 -0
- data/lib/oai/provider/response.rb +119 -0
- data/lib/oai/provider/response/error.rb +16 -0
- data/lib/oai/provider/response/get_record.rb +32 -0
- data/lib/oai/provider/response/identify.rb +24 -0
- data/lib/oai/provider/response/list_identifiers.rb +29 -0
- data/lib/oai/provider/response/list_metadata_formats.rb +21 -0
- data/lib/oai/provider/response/list_records.rb +32 -0
- data/lib/oai/provider/response/list_sets.rb +23 -0
- data/lib/oai/provider/response/record_response.rb +68 -0
- data/lib/oai/provider/resumption_token.rb +106 -0
- data/lib/oai/set.rb +14 -5
- data/test/activerecord_provider/config/connection.rb +5 -0
- data/test/activerecord_provider/config/database.yml +6 -0
- data/test/activerecord_provider/database/ar_migration.rb +59 -0
- data/test/activerecord_provider/database/oaipmhtest +0 -0
- data/test/activerecord_provider/fixtures/dc.yml +1501 -0
- data/test/activerecord_provider/helpers/providers.rb +44 -0
- data/test/activerecord_provider/helpers/set_provider.rb +36 -0
- data/test/activerecord_provider/models/dc_field.rb +7 -0
- data/test/activerecord_provider/models/dc_set.rb +6 -0
- data/test/activerecord_provider/models/oai_token.rb +3 -0
- data/test/activerecord_provider/tc_ar_provider.rb +93 -0
- data/test/activerecord_provider/tc_ar_sets_provider.rb +66 -0
- data/test/activerecord_provider/tc_caching_paging_provider.rb +53 -0
- data/test/activerecord_provider/tc_simple_paging_provider.rb +55 -0
- data/test/activerecord_provider/test_helper.rb +4 -0
- data/test/client/helpers/provider.rb +68 -0
- data/test/client/helpers/test_wrapper.rb +11 -0
- data/test/client/tc_exception.rb +36 -0
- data/test/{tc_get_record.rb → client/tc_get_record.rb} +11 -7
- data/test/client/tc_identify.rb +13 -0
- data/test/{tc_libxml.rb → client/tc_libxml.rb} +20 -10
- data/test/{tc_list_identifiers.rb → client/tc_list_identifiers.rb} +10 -8
- data/test/{tc_list_metadata_formats.rb → client/tc_list_metadata_formats.rb} +4 -1
- data/test/{tc_list_records.rb → client/tc_list_records.rb} +4 -1
- data/test/{tc_list_sets.rb → client/tc_list_sets.rb} +4 -2
- data/test/{tc_xpath.rb → client/tc_xpath.rb} +1 -1
- data/test/client/test_helper.rb +5 -0
- data/test/provider/models.rb +230 -0
- data/test/provider/tc_exceptions.rb +63 -0
- data/test/provider/tc_functional_tokens.rb +42 -0
- data/test/provider/tc_provider.rb +69 -0
- data/test/provider/tc_resumption_tokens.rb +46 -0
- data/test/provider/tc_simple_provider.rb +85 -0
- data/test/provider/test_helper.rb +36 -0
- metadata +123 -27
- data/test/tc_exception.rb +0 -38
- data/test/tc_identify.rb +0 -8
data/test/tc_exception.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
class ExceptionTest < Test::Unit::TestCase
|
2
|
-
|
3
|
-
def test_http_error
|
4
|
-
client = OAI::Client.new 'http://www.example.com'
|
5
|
-
begin
|
6
|
-
client.identify
|
7
|
-
flunk 'did not throw expected exception'
|
8
|
-
rescue OAI::Exception => e
|
9
|
-
assert_match /^HTTP level error/, e.to_s, 'include error message'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_xml_error
|
14
|
-
client = OAI::Client.new 'http://www.yahoo.com'
|
15
|
-
begin
|
16
|
-
client.identify
|
17
|
-
rescue OAI::Exception => e
|
18
|
-
assert_match /response not well formed XML/, e.to_s, 'xml error'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_oai_error
|
23
|
-
client = OAI::Client.new 'http://www.pubmedcentral.gov/oai/oai.cgi'
|
24
|
-
assert_raises(OAI::Exception) do
|
25
|
-
client.list_identifiers :resumption_token => 'bogus'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# must pass in options as a hash
|
30
|
-
def test_parameter_error
|
31
|
-
client = OAI::Client.new 'http://www.pubmedcentral.gov/oai/oai.cgi'
|
32
|
-
assert_raises(OAI::Exception) {client.get_record('foo')}
|
33
|
-
assert_raises(OAI::Exception) {client.list_identifiers('foo')}
|
34
|
-
assert_raises(OAI::Exception) {client.list_records('foo')}
|
35
|
-
assert_raises(OAI::Exception) {client.list_metadata_formats('foo')}
|
36
|
-
assert_raises(OAI::Exception) {client.list_sets('foo')}
|
37
|
-
end
|
38
|
-
end
|
data/test/tc_identify.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
class IdentifyTest < Test::Unit::TestCase
|
2
|
-
def test_ok
|
3
|
-
client = OAI::Client.new 'http://www.pubmedcentral.gov/oai/oai.cgi'
|
4
|
-
response = client.identify
|
5
|
-
assert_kind_of OAI::IdentifyResponse, response
|
6
|
-
assert_equal 'PubMed Central (PMC3 - NLM DTD) [http://www.pubmedcentral.gov/oai/oai.cgi]', response.to_s
|
7
|
-
end
|
8
|
-
end
|