fieldhand 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -12
- data/lib/fieldhand/record.rb +3 -2
- data/lib/fieldhand/set.rb +3 -1
- data/spec/fieldhand/record_spec.rb +23 -0
- data/spec/fieldhand/set_spec.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe77387e599f04fe11981420174c0c53c6f1b3ce
|
4
|
+
data.tar.gz: f3bc88686b42bca448c52a06988273dcae890b8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aac19ca6cdda6acc837c4d8f2e33874fccaa30ee91b3e78e9f0e0a5948b93712785507e960a3c13cfa55da963695b7ce695ddd86333358041335868ee6dca6bd
|
7
|
+
data.tar.gz: e1dfdb2adf541cf2a4dc2c3cfbe39da2b5843595b484ff6a7fcf31f22694431a38b09dcbbbc855d6ee3426ad789ce3fcea45f4263f215b62001be4cf076c8f48
|
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.
|
5
|
+
**Current version:** 0.3.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.
|
11
|
+
gem install fieldhand -v '~> 0.3'
|
12
12
|
```
|
13
13
|
|
14
14
|
Or, in your `Gemfile`:
|
15
15
|
|
16
16
|
```ruby
|
17
|
-
gem 'fieldhand', '~> 0.
|
17
|
+
gem 'fieldhand', '~> 0.3'
|
18
18
|
```
|
19
19
|
|
20
20
|
## Usage
|
@@ -286,10 +286,10 @@ Returns the compression encodings supported by the repository as an `Array` of `
|
|
286
286
|
|
287
287
|
```ruby
|
288
288
|
repository.identify.descriptions
|
289
|
-
#=> [
|
289
|
+
#=> ["<description>..."]
|
290
290
|
```
|
291
291
|
|
292
|
-
Returns
|
292
|
+
Returns descriptions of this repository as an `Array` of `String`s.
|
293
293
|
|
294
294
|
As descriptions can be in any format, Fieldhand doesn't attempt to parse descriptions but leaves parsing to the client.
|
295
295
|
|
@@ -368,10 +368,10 @@ Return a short human-readable `String` naming the set.
|
|
368
368
|
|
369
369
|
```ruby
|
370
370
|
repository.sets.first.descriptions
|
371
|
-
#=> [
|
371
|
+
#=> ["<setDescription>..."]
|
372
372
|
```
|
373
373
|
|
374
|
-
Return an `Array` of
|
374
|
+
Return an `Array` of `String`s of any optional and repeatable containers that may hold community-specific XML-encoded data about the set.
|
375
375
|
|
376
376
|
#### `Fieldhand::Set#response_date`
|
377
377
|
|
@@ -439,10 +439,10 @@ Return an `Array` of `String` [set specs](#fieldhandsetspec) indicating set memb
|
|
439
439
|
|
440
440
|
```ruby
|
441
441
|
repository.records.first.metadata
|
442
|
-
#=>
|
442
|
+
#=> "<metadata>..."
|
443
443
|
```
|
444
444
|
|
445
|
-
Return a single manifestation of the metadata from a record as
|
445
|
+
Return a single manifestation of the metadata from a record as a `String` or `nil` if this is a deleted record.
|
446
446
|
|
447
447
|
As the metadata can be in [any format supported by the repository](#fieldhandrepositorymetadata_formatsidentifier), Fieldhand doesn't attempt to parse the metadata but leaves parsing to the client.
|
448
448
|
|
@@ -450,10 +450,10 @@ As the metadata can be in [any format supported by the repository](#fieldhandrep
|
|
450
450
|
|
451
451
|
```ruby
|
452
452
|
repository.records.first.about
|
453
|
-
#=> [
|
453
|
+
#=> ["<about>..."]
|
454
454
|
```
|
455
455
|
|
456
|
-
Return an `Array` of
|
456
|
+
Return an `Array` of `String`s of any optional and repeatable containers holding data about the metadata part of the record.
|
457
457
|
|
458
458
|
#### `Fieldhand::Record#response_date`
|
459
459
|
|
@@ -585,7 +585,6 @@ This can be used to rescue all the following child error types.
|
|
585
585
|
[Enumerator]: https://ruby-doc.org/core/Enumerator.html
|
586
586
|
[Time]: https://ruby-doc.org/core/Time.html
|
587
587
|
[URI]: https://ruby-doc.org/stdlib/libdoc/uri/rdoc/URI.html
|
588
|
-
[Element]: http://www.rubydoc.info/github/ohler55/ox/Ox/Element
|
589
588
|
|
590
589
|
## Acknowledgements
|
591
590
|
|
data/lib/fieldhand/record.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fieldhand/header'
|
2
|
+
require 'ox'
|
2
3
|
|
3
4
|
module Fieldhand
|
4
5
|
# A record is metadata expressed in a single format.
|
@@ -33,11 +34,11 @@ module Fieldhand
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def metadata
|
36
|
-
@metadata ||= element.locate('metadata[0]').first
|
37
|
+
@metadata ||= element.locate('metadata[0]').map { |metadata| Ox.dump(metadata) }.first
|
37
38
|
end
|
38
39
|
|
39
40
|
def about
|
40
|
-
@about ||= element.locate('about')
|
41
|
+
@about ||= element.locate('about').map { |about| Ox.dump(about) }
|
41
42
|
end
|
42
43
|
|
43
44
|
def header
|
data/lib/fieldhand/set.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'ox'
|
2
|
+
|
1
3
|
module Fieldhand
|
2
4
|
# A set is an optional construct for grouping items for the purpose of selective harvesting.
|
3
5
|
#
|
@@ -23,7 +25,7 @@ module Fieldhand
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def descriptions
|
26
|
-
@descriptions ||= element.locate('setDescription')
|
28
|
+
@descriptions ||= element.locate('setDescription').map { |description| Ox.dump(description) }
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
@@ -19,6 +19,22 @@ module Fieldhand
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
describe '#metadata' do
|
23
|
+
it 'returns nil if there is no metadata' do
|
24
|
+
element = ::Ox.parse('<record/>')
|
25
|
+
record = described_class.new(element)
|
26
|
+
|
27
|
+
expect(record.metadata).to be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns the metadata as a string' do
|
31
|
+
element = ::Ox.parse('<record><metadata>Foo</metadata></record>')
|
32
|
+
record = described_class.new(element)
|
33
|
+
|
34
|
+
expect(record.metadata).to eq("\n<metadata>Foo</metadata>\n")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
22
38
|
describe '#about' do
|
23
39
|
it 'returns an empty array if there are no about elements' do
|
24
40
|
element = ::Ox.parse('<record/>')
|
@@ -33,6 +49,13 @@ module Fieldhand
|
|
33
49
|
|
34
50
|
expect(record.about.size).to eq(2)
|
35
51
|
end
|
52
|
+
|
53
|
+
it 'returns about sections as strings' do
|
54
|
+
element = ::Ox.parse('<record><about>Foo</about><about>Bar</about></record>')
|
55
|
+
record = described_class.new(element)
|
56
|
+
|
57
|
+
expect(record.about).to contain_exactly("\n<about>Foo</about>\n", "\n<about>Bar</about>\n")
|
58
|
+
end
|
36
59
|
end
|
37
60
|
|
38
61
|
describe '#response_date' do
|
data/spec/fieldhand/set_spec.rb
CHANGED
@@ -17,6 +17,14 @@ module Fieldhand
|
|
17
17
|
|
18
18
|
expect(set.descriptions.size).to eq(2)
|
19
19
|
end
|
20
|
+
|
21
|
+
it 'returns descriptions as strings' do
|
22
|
+
element = ::Ox.parse('<set><setDescription>Foo</setDescription><setDescription>Bar</setDescription></set>')
|
23
|
+
set = described_class.new(element)
|
24
|
+
|
25
|
+
expect(set.descriptions).
|
26
|
+
to contain_exactly("\n<setDescription>Foo</setDescription>\n", "\n<setDescription>Bar</setDescription>\n")
|
27
|
+
end
|
20
28
|
end
|
21
29
|
|
22
30
|
describe '#to_s' do
|