oai 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/{README → README.md} +33 -32
  2. data/Rakefile +2 -3
  3. data/bin/oai +0 -0
  4. data/examples/models/file_model.rb +0 -0
  5. data/lib/oai/harvester/config.rb +0 -0
  6. data/lib/oai/harvester/harvest.rb +0 -0
  7. data/lib/oai/harvester/logging.rb +0 -0
  8. data/lib/oai/harvester/mailer.rb +0 -0
  9. data/lib/oai/harvester/shell.rb +0 -0
  10. data/lib/oai/provider.rb +0 -0
  11. data/lib/oai/provider/metadata_format.rb +2 -3
  12. data/lib/oai/provider/metadata_format/oai_dc.rb +0 -0
  13. data/lib/oai/provider/model.rb +0 -0
  14. data/lib/oai/provider/model/activerecord_caching_wrapper.rb +0 -0
  15. data/lib/oai/provider/model/activerecord_wrapper.rb +0 -0
  16. data/lib/oai/provider/partial_result.rb +0 -0
  17. data/lib/oai/provider/response.rb +4 -0
  18. data/lib/oai/provider/response/error.rb +0 -0
  19. data/lib/oai/provider/response/get_record.rb +0 -0
  20. data/lib/oai/provider/response/identify.rb +0 -0
  21. data/lib/oai/provider/response/list_identifiers.rb +0 -0
  22. data/lib/oai/provider/response/list_metadata_formats.rb +0 -0
  23. data/lib/oai/provider/response/list_records.rb +0 -0
  24. data/lib/oai/provider/response/list_sets.rb +0 -0
  25. data/lib/oai/provider/response/record_response.rb +0 -0
  26. data/lib/oai/provider/resumption_token.rb +1 -1
  27. data/test/activerecord_provider/config/connection.rb +0 -0
  28. data/test/activerecord_provider/config/database.yml +0 -0
  29. data/test/activerecord_provider/database/ar_migration.rb +0 -0
  30. data/test/activerecord_provider/helpers/providers.rb +0 -0
  31. data/test/activerecord_provider/helpers/set_provider.rb +0 -0
  32. data/test/activerecord_provider/models/dc_field.rb +0 -0
  33. data/test/activerecord_provider/models/dc_set.rb +0 -0
  34. data/test/activerecord_provider/models/oai_token.rb +0 -0
  35. data/test/activerecord_provider/tc_ar_provider.rb +0 -0
  36. data/test/activerecord_provider/tc_ar_sets_provider.rb +0 -0
  37. data/test/activerecord_provider/tc_caching_paging_provider.rb +0 -0
  38. data/test/activerecord_provider/tc_simple_paging_provider.rb +0 -0
  39. data/test/activerecord_provider/test_helper.rb +0 -0
  40. data/test/client/helpers/provider.rb +0 -0
  41. data/test/client/helpers/test_wrapper.rb +0 -0
  42. data/test/client/tc_exception.rb +1 -1
  43. data/test/client/tc_low_resolution_dates.rb +1 -1
  44. data/test/client/test_helper.rb +0 -0
  45. data/test/provider/models.rb +1 -0
  46. data/test/provider/tc_exceptions.rb +6 -0
  47. data/test/provider/tc_functional_tokens.rb +0 -0
  48. data/test/provider/tc_resumption_tokens.rb +0 -0
  49. data/test/provider/tc_simple_provider.rb +5 -0
  50. metadata +121 -112
@@ -1,37 +1,43 @@
1
- = ruby-oai
2
-
3
- == DESCRIPTION
4
-
5
- ruby-oai is a Open Archives Protocol for Metadata Harvesting (OAI-PMH[http://openarchives.org])
6
- library for Ruby. If you're not familiar with OAI-PMH[http://openarchives.org] it is the most used
7
- protocol for sharing metadata between digital library repositories.
8
-
9
- The OAI-PMH[http://openarchives.org] spec defines six verbs (Identify, ListIdentifiers, ListRecords,
1
+ ruby-oai
2
+ ========
3
+
4
+ ruby-oai is a Open Archives Protocol for Metadata Harvesting (OAI-PMH)
5
+ library for Ruby. OAI-PMH[http://openarchives.org] it is a somewhat
6
+ archaic protocol for sharing metadata between digital library repositories.
7
+ If you are looking to share metadata on the web you are probably better off
8
+ using a feed format like RSS or Atom. If have to work with a backwards
9
+ digital repository that only offers OAI-PMH access then ruby-oai is your
10
+ friend.
11
+
12
+ The [OAI-PMH](http://openarchives.org) spec defines six verbs (Identify, ListIdentifiers, ListRecords,
10
13
  GetRecords, ListSets, ListMetadataFormat) used for discovery and sharing of
11
14
  metadata.
12
15
 
13
16
  The ruby-oai gem includes a client library, a server/provider library and
14
17
  a interactive harvesting shell.
15
18
 
16
- === client
19
+ Client
20
+ ------
17
21
 
18
22
  The OAI client library is used for harvesting metadata from repositories.
19
23
  For example to initiate a ListRecords request to pubmed you can:
20
24
 
25
+ ```ruby
21
26
  require 'oai'
22
27
  client = OAI::Client.new 'http://www.pubmedcentral.gov/oai/oai.cgi'
23
28
  for record in client.list_records
24
29
  puts record.metadata
25
30
  end
31
+ ```
26
32
 
27
33
  See OAI::Client for more details
28
34
 
29
- === provider
30
-
31
- The OAI provider library handles serving local content to other clients.
35
+ Server
36
+ ------
32
37
 
33
- Setting up a simple provider:
38
+ The OAI provider library handles serving local content to other clients. Here's how to set up a simple provider:
34
39
 
40
+ ```ruby
35
41
  class MyProvider < Oai::Provider
36
42
  repository_name 'My little OAI provider'
37
43
  repository_url 'http://localhost/provider'
@@ -39,43 +45,38 @@ Setting up a simple provider:
39
45
  admin_email 'root@localhost' # String or Array
40
46
  source_model MyModel.new # Subclass of OAI::Provider::Model
41
47
  end
48
+ ```
42
49
 
43
50
  See OAI::Provider for more details
44
51
 
45
- === interactive harvester
52
+ Interactive Harvester
53
+ ---------------------
46
54
 
47
- The OAI-PMH[http://openarchives.org] client shell allows OAI Harvesting to be configured in
48
- an interactive manner. Typing 'oai' on the command line starts the
49
- shell.
50
-
51
- After initial configuration, the shell can be used to manage harvesting
52
- operations.
55
+ The OAI-PMH client shell allows OAI Harvesting to be configured in an interactive manner. Typing 'oai' on the command line starts the shell. After initial configuration, the shell can be used to manage harvesting operations.
53
56
 
54
57
  See OAI::Harvester::Shell for more details
55
58
 
56
- == INSTALLATION
59
+ Installation
60
+ ------------
57
61
 
58
62
  Normally the best way to install oai is from rubyforge using the gem
59
63
  command line tool:
60
64
 
65
+ ```
61
66
  % gem install oai
67
+ ```
62
68
 
63
69
  If you're reading this you've presumably got the tarball or zip distribution.
64
70
  So you'll need to:
65
71
 
72
+ ```
66
73
  % rake package
67
74
  % gem install pkg/oai-x.y.z.gem
75
+ ```
68
76
 
69
77
  Where x.y.z is the version of the gem that was generated.
70
78
 
71
- == TODO
72
-
73
- * consolidate response classes used by provider and client
74
- * automatic validation of metadata schemas
75
- * email the authors with your suggestions
76
-
77
- == AUTHORS
79
+ License
80
+ -------
78
81
 
79
- - Ed Summers <ehs@pobox.com>
80
- - William Groppe <will.groppe@gmail.com>
81
- - Terry Reese <terry.reese@oregonstate.edu>
82
+ [Public Domain](http://creativecommons.org/publicdomain/zero/1.0/)
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- RUBY_OAI_VERSION = '0.0.12'
1
+ RUBY_OAI_VERSION = '0.0.13'
2
2
 
3
3
  require 'rubygems'
4
4
  require 'rake'
@@ -21,13 +21,12 @@ spec = Gem::Specification.new do |s|
21
21
  s.summary = 'A ruby library for working with the Open Archive Initiative Protocol for Metadata Harvesting (OAI-PMH)'
22
22
  s.require_path = 'lib'
23
23
  s.autorequire = 'oai'
24
- s.has_rdoc = true
25
24
  s.bindir = 'bin'
26
25
  s.executables = 'oai'
27
26
 
28
27
  s.add_dependency('builder', '>=2.0.0')
29
28
 
30
- s.files = %w(README Rakefile) +
29
+ s.files = %w(README.md Rakefile) +
31
30
  Dir.glob("{bin,test,lib}/**/*") +
32
31
  Dir.glob("examples/**/*.rb")
33
32
  end
data/bin/oai CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/lib/oai/provider.rb CHANGED
File without changes
@@ -58,9 +58,8 @@ module OAI::Provider::Metadata
58
58
 
59
59
  if record.respond_to?(pluralize(method))
60
60
  record.send pluralize(method)
61
- elsif record.respond_to?(method)
62
- # at this point, this function will throw a dep. error because of the call to type -- a reserved work
63
- # in ruby
61
+ elsif method != 'type' and record.respond_to?(method)
62
+ # TODO: this calls type, which is deprecated, should be
64
63
  record.send method
65
64
  else
66
65
  []
File without changes
File without changes
File without changes
File without changes
@@ -61,6 +61,10 @@ module OAI
61
61
 
62
62
  return true if self.class.valid_options.nil? and options.empty?
63
63
 
64
+ # check if the request includes an argument and there are no valid
65
+ # arguments for that verb (Identify, for example).
66
+ raise OAI::ArgumentException.new if self.class.valid_options.nil? && !options.empty?
67
+
64
68
  if self.class.required_options
65
69
  return false unless (self.class.required_options - @options.keys).empty?
66
70
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -32,7 +32,7 @@ module OAI::Provider
32
32
  end
33
33
  self.new(options)
34
34
  rescue => err
35
- raise ResumptionTokenException.new
35
+ raise OAI::ResumptionTokenException.new
36
36
  end
37
37
  end
38
38
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -4,7 +4,7 @@ class ExceptionTest < Test::Unit::TestCase
4
4
 
5
5
  def test_not_found
6
6
  client = OAI::Client.new 'http://www.google.com'
7
- assert_raises(ArgumentError) { client.identify }
7
+ assert_raises(OAI::Exception) { client.identify }
8
8
  end
9
9
 
10
10
  def test_xml_error
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  class LowResolutionDatesTest < Test::Unit::TestCase
4
4
 
5
5
  def test_low_res_date_parsing
6
- client = OAI::Client.new 'http://caltechcstr.library.caltech.edu/perl/oai2'
6
+ client = OAI::Client.new 'http://authors.library.caltech.edu/cgi/oai2'
7
7
 
8
8
  date = Date.new 2003, 1, 1
9
9
 
File without changes
@@ -113,6 +113,7 @@ class TestModel < OAI::Provider::Model
113
113
 
114
114
  def generate_records(number, timestamp = Time.now.utc.xmlschema, sets = [], deleted = false)
115
115
  @earliest = timestamp.dup if @earliest.nil? || timestamp.to_s < @earliest
116
+ @earliest = timestamp.dup if @earliest.nil?
116
117
 
117
118
  # Add any sets we don't already have
118
119
  sets = [sets] unless sets.respond_to?(:each)
@@ -7,6 +7,12 @@ class ProviderExceptions < Test::Unit::TestCase
7
7
  @provider = ComplexProvider.new
8
8
  end
9
9
 
10
+ def test_argument_exception
11
+ assert_raise(OAI::ArgumentException) do
12
+ @provider.identify(:identifier => 'invalid_arg')
13
+ end
14
+ end
15
+
10
16
  def test_resumption_token_exception
11
17
  assert_raise(OAI::ResumptionTokenException) do
12
18
  @provider.list_records(:resumption_token => 'aaadddd:1000')
File without changes
File without changes
@@ -13,6 +13,11 @@ class TestSimpleProvider < Test::Unit::TestCase
13
13
  doc.elements["/OAI-PMH/Identify/repositoryName"].text
14
14
  assert_equal SimpleModel.new.earliest.to_s,
15
15
  doc.elements["/OAI-PMH/Identify/earliestDatestamp"].text
16
+
17
+ # PC
18
+ # lambda { REXML::Document.new(@simple_provider.identify(:set => 'A')) }
19
+
20
+
16
21
  end
17
22
 
18
23
  def test_list_sets
metadata CHANGED
@@ -1,152 +1,161 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: oai
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.0.12
7
- date: 2008-12-22 00:00:00 -08:00
8
- summary: A ruby library for working with the Open Archive Initiative Protocol for Metadata Harvesting (OAI-PMH)
9
- require_paths:
10
- - lib
11
- email: ehs@pobox.com
12
- homepage: http://www.textualize.com/ruby_oai_0
13
- rubyforge_project:
14
- description:
15
- autorequire: oai
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ hash: 5
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 13
10
+ version: 0.0.13
25
11
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
12
  authors:
30
13
  - Ed Summers
14
+ autorequire: oai
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-04-09 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: builder
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 15
29
+ segments:
30
+ - 2
31
+ - 0
32
+ - 0
33
+ version: 2.0.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description:
37
+ email: ehs@pobox.com
38
+ executables:
39
+ - oai
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
31
44
  files:
32
- - README
45
+ - README.md
33
46
  - Rakefile
34
47
  - bin/oai
35
- - test/client
36
- - test/client/helpers
37
- - test/client/helpers/test_wrapper.rb
48
+ - test/client/tc_get_record.rb
49
+ - test/client/tc_identify.rb
38
50
  - test/client/helpers/provider.rb
39
- - test/client/tc_list_sets.rb
40
- - test/client/tc_list_metadata_formats.rb
51
+ - test/client/helpers/test_wrapper.rb
52
+ - test/client/tc_list_identifiers.rb
41
53
  - test/client/tc_utf8_escaping.rb
42
- - test/client/tc_identify.rb
54
+ - test/client/tc_list_sets.rb
55
+ - test/client/test_helper.rb
56
+ - test/client/tc_list_records.rb
43
57
  - test/client/tc_libxml.rb
44
- - test/client/tc_list_identifiers.rb
45
- - test/client/tc_get_record.rb
46
58
  - test/client/tc_low_resolution_dates.rb
47
- - test/client/tc_list_records.rb
48
- - test/client/tc_xpath.rb
49
- - test/client/test_helper.rb
50
59
  - test/client/tc_exception.rb
51
- - test/activerecord_provider
52
- - test/activerecord_provider/tc_ar_provider.rb
53
- - test/activerecord_provider/helpers
60
+ - test/client/tc_list_metadata_formats.rb
61
+ - test/client/tc_xpath.rb
62
+ - test/provider/tc_simple_provider.rb
63
+ - test/provider/models.rb
64
+ - test/provider/tc_functional_tokens.rb
65
+ - test/provider/tc_provider.rb
66
+ - test/provider/tc_resumption_tokens.rb
67
+ - test/provider/test_helper.rb
68
+ - test/provider/tc_exceptions.rb
69
+ - test/test.xml
70
+ - test/activerecord_provider/fixtures/dc.yml
54
71
  - test/activerecord_provider/helpers/providers.rb
55
72
  - test/activerecord_provider/helpers/set_provider.rb
56
- - test/activerecord_provider/models
57
- - test/activerecord_provider/models/dc_set.rb
73
+ - test/activerecord_provider/tc_caching_paging_provider.rb
74
+ - test/activerecord_provider/tc_ar_sets_provider.rb
58
75
  - test/activerecord_provider/models/oai_token.rb
76
+ - test/activerecord_provider/models/dc_set.rb
59
77
  - test/activerecord_provider/models/dc_field.rb
78
+ - test/activerecord_provider/test_helper.rb
60
79
  - test/activerecord_provider/tc_simple_paging_provider.rb
61
- - test/activerecord_provider/tc_caching_paging_provider.rb
62
- - test/activerecord_provider/database
63
- - test/activerecord_provider/database/ar_migration.rb
64
80
  - test/activerecord_provider/database/oaipmhtest
65
- - test/activerecord_provider/test_helper.rb
66
- - test/activerecord_provider/fixtures
67
- - test/activerecord_provider/fixtures/dc.yml
68
- - test/activerecord_provider/tc_ar_sets_provider.rb
69
- - test/activerecord_provider/config
70
- - test/activerecord_provider/config/database.yml
81
+ - test/activerecord_provider/database/ar_migration.rb
82
+ - test/activerecord_provider/tc_ar_provider.rb
71
83
  - test/activerecord_provider/config/connection.rb
72
- - test/test.xml
73
- - test/provider
74
- - test/provider/tc_provider.rb
75
- - test/provider/tc_functional_tokens.rb
76
- - test/provider/tc_simple_provider.rb
77
- - test/provider/tc_exceptions.rb
78
- - test/provider/tc_resumption_tokens.rb
79
- - test/provider/test_helper.rb
80
- - test/provider/models.rb
81
- - lib/oai
84
+ - test/activerecord_provider/config/database.yml
85
+ - lib/oai/set.rb
82
86
  - lib/oai/xpath.rb
83
- - lib/oai/client
87
+ - lib/oai/harvester/logging.rb
88
+ - lib/oai/harvester/mailer.rb
89
+ - lib/oai/harvester/harvest.rb
90
+ - lib/oai/harvester/shell.rb
91
+ - lib/oai/harvester/config.rb
92
+ - lib/oai/client/list_identifiers.rb
93
+ - lib/oai/client/list_records.rb
94
+ - lib/oai/client/header.rb
84
95
  - lib/oai/client/identify.rb
85
96
  - lib/oai/client/record.rb
86
- - lib/oai/client/list_sets.rb
87
- - lib/oai/client/header.rb
88
- - lib/oai/client/metadata_format.rb
89
- - lib/oai/client/response.rb
90
- - lib/oai/client/list_records.rb
91
97
  - lib/oai/client/get_record.rb
92
- - lib/oai/client/list_identifiers.rb
98
+ - lib/oai/client/response.rb
99
+ - lib/oai/client/metadata_format.rb
93
100
  - lib/oai/client/list_metadata_formats.rb
94
- - lib/oai/exception.rb
95
- - lib/oai/constants.rb
96
- - lib/oai/set.rb
97
- - lib/oai/harvester
98
- - lib/oai/harvester/harvest.rb
99
- - lib/oai/harvester/config.rb
100
- - lib/oai/harvester/logging.rb
101
- - lib/oai/harvester/mailer.rb
102
- - lib/oai/harvester/shell.rb
103
- - lib/oai/client.rb
104
- - lib/oai/harvester.rb
105
- - lib/oai/provider.rb
106
- - lib/oai/provider
107
- - lib/oai/provider/resumption_token.rb
108
- - lib/oai/provider/partial_result.rb
101
+ - lib/oai/client/list_sets.rb
109
102
  - lib/oai/provider/model.rb
110
- - lib/oai/provider/metadata_format.rb
111
- - lib/oai/provider/response.rb
112
- - lib/oai/provider/response
113
- - lib/oai/provider/response/identify.rb
114
- - lib/oai/provider/response/list_sets.rb
103
+ - lib/oai/provider/model/activerecord_caching_wrapper.rb
104
+ - lib/oai/provider/model/activerecord_wrapper.rb
105
+ - lib/oai/provider/response/list_identifiers.rb
106
+ - lib/oai/provider/response/list_records.rb
115
107
  - lib/oai/provider/response/record_response.rb
108
+ - lib/oai/provider/response/identify.rb
116
109
  - lib/oai/provider/response/error.rb
117
- - lib/oai/provider/response/list_records.rb
118
110
  - lib/oai/provider/response/get_record.rb
119
- - lib/oai/provider/response/list_identifiers.rb
120
111
  - lib/oai/provider/response/list_metadata_formats.rb
121
- - lib/oai/provider/model
122
- - lib/oai/provider/model/activerecord_caching_wrapper.rb
123
- - lib/oai/provider/model/activerecord_wrapper.rb
124
- - lib/oai/provider/extensions
125
- - lib/oai/provider/metadata_format
112
+ - lib/oai/provider/response/list_sets.rb
126
113
  - lib/oai/provider/metadata_format/oai_dc.rb
127
- - lib/oai.rb
114
+ - lib/oai/provider/resumption_token.rb
115
+ - lib/oai/provider/response.rb
116
+ - lib/oai/provider/partial_result.rb
117
+ - lib/oai/provider/metadata_format.rb
118
+ - lib/oai/constants.rb
119
+ - lib/oai/client.rb
120
+ - lib/oai/provider.rb
121
+ - lib/oai/harvester.rb
122
+ - lib/oai/exception.rb
128
123
  - lib/test.rb
124
+ - lib/oai.rb
129
125
  - examples/providers/dublin_core.rb
130
126
  - examples/models/file_model.rb
131
- test_files: []
127
+ homepage: http://www.textualize.com/ruby_oai_0
128
+ licenses: []
132
129
 
130
+ post_install_message:
133
131
  rdoc_options: []
134
132
 
135
- extra_rdoc_files: []
136
-
137
- executables:
138
- - oai
139
- extensions: []
140
-
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ hash: 3
141
+ segments:
142
+ - 0
143
+ version: "0"
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ hash: 3
150
+ segments:
151
+ - 0
152
+ version: "0"
141
153
  requirements: []
142
154
 
143
- dependencies:
144
- - !ruby/object:Gem::Dependency
145
- name: builder
146
- version_requirement:
147
- version_requirements: !ruby/object:Gem::Version::Requirement
148
- requirements:
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- version: 2.0.0
152
- version:
155
+ rubyforge_project:
156
+ rubygems_version: 1.7.2
157
+ signing_key:
158
+ specification_version: 3
159
+ summary: A ruby library for working with the Open Archive Initiative Protocol for Metadata Harvesting (OAI-PMH)
160
+ test_files: []
161
+