fieldhand 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c93850935147ebbd65f18c017647d95fb92f0a8
4
- data.tar.gz: aa07bb08297620d753ffd50f62fa393450932ec1
3
+ metadata.gz: d9c3e17513d85f7e8dec36a7fb9b52fa547e1f2c
4
+ data.tar.gz: dd74e19d59725bb667f959166a30bdd8506e7c85
5
5
  SHA512:
6
- metadata.gz: 5c17919de0da4c4f435724db51eabf4953ae4d9ad5fbad608fe4b35d3425fef5f65d9fd4492c3cc756ba6bb182ecae913b15156ef42a9502019457603d995e9a
7
- data.tar.gz: efa32effd77a428477c16debc10030df6dacc9b2e40e70300613de3d82bed1f09525974006d517d61faf0bc5c05e63b7d4e7bcc57f8990b08b53e51f468df69a
6
+ metadata.gz: c69eb6a4cc5d8f45716f465a4dcf1b35b760bd8c7d47449168aaa66afe1b29e70eee22cc25b31b900fbd6dfb547b594b79e31fe69132b4d22e2e9a12b756b970
7
+ data.tar.gz: a1a4fd53a7ce8e5ebd611515d9d0ae76b7e12c52d415ec05c2f0f020ddaeb74c0f7a83fcd5483aa4ff8b4842bd4b15e4c807ef3941c3de6d8ac5229896878866
data/README.md CHANGED
@@ -2,19 +2,19 @@
2
2
 
3
3
  A Ruby library for harvesting metadata from [OAI-PMH](https://www.openarchives.org/OAI/openarchivesprotocol.html) repositories.
4
4
 
5
- **Current version:** 0.10.0
5
+ **Current version:** 0.11.0
6
6
  **Supported Ruby versions:** 1.8.7, 1.9.2, 1.9.3, 2.0, 2.1, 2.2
7
7
 
8
8
  ## Installation
9
9
 
10
10
  ```
11
- gem install fieldhand -v '~> 0.10'
11
+ gem install fieldhand -v '~> 0.11'
12
12
  ```
13
13
 
14
14
  Or, in your `Gemfile`:
15
15
 
16
16
  ```ruby
17
- gem 'fieldhand', '~> 0.10'
17
+ gem 'fieldhand', '~> 0.11'
18
18
  ```
19
19
 
20
20
  ## Usage
@@ -115,7 +115,7 @@ A class to represent [an OAI-PMH repository](https://www.openarchives.org/OAI/op
115
115
  Fieldhand::Repository.new('http://www.example.com/oai')
116
116
  Fieldhand::Repository.new(URI('http://www.example.com/oai'))
117
117
  Fieldhand::Repository.new('http://www.example.com/oai', :logger => Logger.new(STDOUT), :timeout => 10, :bearer_token => 'decafbad')
118
- Fieldhand::Repository.new('http://www.example.com/oai', :logger => Logger.new(STDOUT), :timeout => 10, :headers => { 'Custom header' => 'decafbad')
118
+ Fieldhand::Repository.new('http://www.example.com/oai', :logger => Logger.new(STDOUT), :timeout => 10, :headers => { 'Custom header' => 'decafbad' })
119
119
  ```
120
120
 
121
121
  Return a new [`Repository`](#fieldhandrepository) instance accessible at the given `uri` (specified
@@ -126,7 +126,7 @@ something that can be coerced into a `URI` such as a `String`) with three option
126
126
  * `:timeout`: a `Numeric` number of seconds to wait before timing out any HTTP requests, defaults to 60;
127
127
  * `:bearer_token`: a `String` bearer token to authorize any HTTP requests, defaults to `nil`.
128
128
  * `:headers`: a `Hash` containing custom HTTP headers, defaults to `{}`.
129
-
129
+
130
130
  #### `Fieldhand::Repository#identify`
131
131
 
132
132
  ```ruby
@@ -53,7 +53,7 @@ module Fieldhand
53
53
 
54
54
  # Return the root element of the parsed document.
55
55
  def root
56
- @root ||= ::Ox.parse(response).root
56
+ @root ||= ::Ox.load(response, :strip_namespace => 'oai').root
57
57
  end
58
58
 
59
59
  private
@@ -124,6 +124,29 @@ module Fieldhand
124
124
 
125
125
  repository.records(:from => '2001-01-01', :until => '2002-01-01')
126
126
  end
127
+
128
+ it 'returns all records for repository with namespace' do
129
+ stub_oai_request('http://www.example.com/oai?verb=ListRecords&metadataPrefix=marcxml', 'list_records_with_namespaces.xml')
130
+ repository = described_class.new('http://www.example.com/oai')
131
+
132
+ records = repository.records(:metadata_prefix => 'marcxml').to_a
133
+ expect(records.size).to eq(2)
134
+ end
135
+
136
+ it 'populates records with the right information for repository with namespace' do
137
+ stub_oai_request('http://www.example.com/oai?verb=ListRecords&metadataPrefix=marcxml', 'list_records_with_namespaces.xml')
138
+ repository = described_class.new('http://www.example.com/oai')
139
+ record = repository.records(:metadata_prefix => 'marcxml').first
140
+
141
+ expect(record).to have_attributes(:identifier => '123456',
142
+ :datestamp => ::Date.strptime('2018-11-08'),
143
+ :sets => %w[],
144
+ :deleted? => false,
145
+ :status => nil,
146
+ :about => [],
147
+ :metadata => "<metadata><collection><record/></collection></metadata>\n"
148
+ )
149
+ end
127
150
  end
128
151
 
129
152
  describe '#identifiers' do
@@ -186,6 +209,15 @@ module Fieldhand
186
209
  expect(repository.get('oai:oai.datacite.org:32356', :metadata_prefix => 'oai_dc')).
187
210
  to have_attributes(:identifier => 'oai:oai.datacite.org:32356')
188
211
  end
212
+
213
+ it 'fetches the record by identifier' do
214
+ stub_oai_request('http://www.example.com/oai?verb=GetRecord&metadataPrefix=marcxml&identifier=123456',
215
+ 'get_record_with_namespace.xml')
216
+ repository = described_class.new('http://www.example.com/oai')
217
+
218
+ expect(repository.get('123456', :metadata_prefix => 'marcxml')).
219
+ to have_attributes(:identifier => '123456')
220
+ end
189
221
  end
190
222
 
191
223
  describe '#timeout' do
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fieldhand
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Mucur
8
8
  - Maciej Gajewski
9
9
  - Giovanni Derks
10
10
  - Abeer Salameh
11
+ - Anna Klimas
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2018-10-18 00:00:00.000000000 Z
15
+ date: 2018-11-12 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: ox