eader 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/eader/document.rb +3 -3
- data/lib/eader/item.rb +27 -20
- data/lib/eader/version.rb +1 -1
- data/spec/eader_spec.rb +39 -1
- data/spec/support/test.xml +18 -0
- metadata +2 -2
data/lib/eader/document.rb
CHANGED
@@ -12,7 +12,7 @@ module Eader
|
|
12
12
|
def series
|
13
13
|
doc.css('dsc c01').map do |c|
|
14
14
|
if c['level'] == 'series'
|
15
|
-
Item.new(c
|
15
|
+
Item.new(c)
|
16
16
|
end
|
17
17
|
end.compact
|
18
18
|
end
|
@@ -20,7 +20,7 @@ module Eader
|
|
20
20
|
def subseries
|
21
21
|
doc.css('dsc c02').map do |c|
|
22
22
|
if c['level'] == 'subseries'
|
23
|
-
Item.new(c
|
23
|
+
Item.new(c)
|
24
24
|
end
|
25
25
|
end.compact
|
26
26
|
end
|
@@ -31,7 +31,7 @@ module Eader
|
|
31
31
|
(1..3).each do |n|
|
32
32
|
doc.css("dsc c0#{n}").map do |c|
|
33
33
|
if c['level'] == 'item'
|
34
|
-
@items << Item.new(c
|
34
|
+
@items << Item.new(c)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
data/lib/eader/item.rb
CHANGED
@@ -7,44 +7,51 @@ module Eader
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def unitid
|
10
|
-
|
11
|
-
uid[0].text.strip
|
12
|
-
end
|
10
|
+
find('did unitid')
|
13
11
|
end
|
14
12
|
|
15
13
|
def origination
|
16
|
-
|
17
|
-
orig[0].text.strip
|
18
|
-
end
|
14
|
+
find('did origination')
|
19
15
|
end
|
20
16
|
|
21
17
|
def langmaterial
|
22
|
-
|
23
|
-
langm[0].text.strip
|
24
|
-
end
|
18
|
+
find('did langmaterial')
|
25
19
|
end
|
26
20
|
|
27
21
|
def unittitle
|
28
|
-
|
29
|
-
|
30
|
-
|
22
|
+
find('did unittitle')
|
23
|
+
end
|
24
|
+
|
25
|
+
def scope_content
|
26
|
+
find('scopecontent', :html => true)
|
27
|
+
end
|
28
|
+
|
29
|
+
def note
|
30
|
+
find('note', :html => true)
|
31
|
+
end
|
32
|
+
|
33
|
+
def use_restrict
|
34
|
+
find('userestrict')
|
31
35
|
end
|
32
36
|
|
33
37
|
def unitdate
|
34
|
-
|
35
|
-
_unit_dates[0].text.strip
|
36
|
-
end
|
38
|
+
find('did unitdate')
|
37
39
|
end
|
38
40
|
|
39
41
|
def unitdate_type
|
40
|
-
|
41
|
-
_unit_dates[0].attr('type')
|
42
|
-
end
|
42
|
+
node.css('did unitdate')[0].attr('type')
|
43
43
|
end
|
44
44
|
|
45
45
|
private
|
46
|
-
def
|
47
|
-
node.css(
|
46
|
+
def find(selector, options = {})
|
47
|
+
results = node.css(selector)
|
48
|
+
return nil unless results.any?
|
49
|
+
|
50
|
+
if options[:html]
|
51
|
+
results[0].children.to_s
|
52
|
+
else
|
53
|
+
results[0].text.strip
|
54
|
+
end
|
48
55
|
end
|
49
56
|
end
|
50
57
|
end
|
data/lib/eader/version.rb
CHANGED
data/spec/eader_spec.rb
CHANGED
@@ -9,7 +9,9 @@ describe Eader do
|
|
9
9
|
e.should have(1).items
|
10
10
|
|
11
11
|
# checking that remote url works
|
12
|
-
|
12
|
+
if ENV['REMOTE_URL']
|
13
|
+
i.should have(4434).items
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
17
|
it "returns item unitids" do
|
@@ -32,4 +34,40 @@ describe Eader do
|
|
32
34
|
item.unitdate.should be_empty
|
33
35
|
item.unitdate_type.should == "inclusive"
|
34
36
|
end
|
37
|
+
|
38
|
+
it "returns items' scope_content" do
|
39
|
+
expected = <<-EOD
|
40
|
+
<p>Thurman Barker, percussion</p>
|
41
|
+
<p>Recorded live 1987.03.21, Links Hall, 3435 N. Sheffield, Chicago, IL 60657</p>
|
42
|
+
<p>Contents: [Introduction] (2 min. 17 sec.) -- ["The Hunt"] (11 min. 7 sec.) --
|
43
|
+
[Untitled] (11 min. 19 sec.) -- [Untitled] (10 min. 42 sec.) -- ["Blue in
|
44
|
+
green"] (12 min. 5 sec.) -- [Intermission] (2 min. 40 sec.) --
|
45
|
+
["Kalingalinga"] (17 min. 1 sec.) -- ["Hocus Pocus"] (21 min. 15 sec.) --
|
46
|
+
[Outro] (2 min. 19 sec.)</p>
|
47
|
+
|
48
|
+
EOD
|
49
|
+
|
50
|
+
content = item.scope_content.gsub(/\n\s+/, ' ')
|
51
|
+
|
52
|
+
content.should == expected.gsub(/\n\s+/, ' ')
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns items' note" do
|
56
|
+
expected = <<-EOD
|
57
|
+
<p>Barker's recent activities include a trio with Joseph Jarman and Amina
|
58
|
+
Claudine Meyers, and solo work on marimba, traps and xylophone. He has
|
59
|
+
recorded with Muhal Richard Abrams, Sam Rivers, Anthony Braxton, Roscoe
|
60
|
+
Mitchell, Billy Bang, John Lindberg and the World Bass Violin Ensemble, to
|
61
|
+
name a few. [Links Hall Program Schedule, March-June 1987]</p>
|
62
|
+
|
63
|
+
EOD
|
64
|
+
|
65
|
+
note = item.note.gsub(/\n\s+/, ' ')
|
66
|
+
|
67
|
+
note.should == expected.gsub(/\n\s+/, ' ')
|
68
|
+
end
|
69
|
+
|
70
|
+
it "returns items' use_restrict" do
|
71
|
+
item.use_restrict.should == 'Material is copyright of respective artists.'
|
72
|
+
end
|
35
73
|
end
|
data/spec/support/test.xml
CHANGED
@@ -138,6 +138,24 @@
|
|
138
138
|
<unittitle> 5 empty loose CD jewel cases [sound recording]</unittitle>
|
139
139
|
<unitdate type="inclusive"> </unitdate>
|
140
140
|
</did>
|
141
|
+
<scopecontent>
|
142
|
+
<p>Thurman Barker, percussion</p>
|
143
|
+
<p>Recorded live 1987.03.21, Links Hall, 3435 N. Sheffield, Chicago, IL 60657</p>
|
144
|
+
<p>Contents: [Introduction] (2 min. 17 sec.) -- ["The Hunt"] (11 min. 7 sec.) --
|
145
|
+
[Untitled] (11 min. 19 sec.) -- [Untitled] (10 min. 42 sec.) -- ["Blue in
|
146
|
+
green"] (12 min. 5 sec.) -- [Intermission] (2 min. 40 sec.) --
|
147
|
+
["Kalingalinga"] (17 min. 1 sec.) -- ["Hocus Pocus"] (21 min. 15 sec.) --
|
148
|
+
[Outro] (2 min. 19 sec.)</p>
|
149
|
+
</scopecontent>
|
150
|
+
<note>
|
151
|
+
<p>Barker's recent activities include a trio with Joseph Jarman and Amina
|
152
|
+
Claudine Meyers, and solo work on marimba, traps and xylophone. He has
|
153
|
+
recorded with Muhal Richard Abrams, Sam Rivers, Anthony Braxton, Roscoe
|
154
|
+
Mitchell, Billy Bang, John Lindberg and the World Bass Violin Ensemble, to
|
155
|
+
name a few. [Links Hall Program Schedule, March-June 1987]</p>
|
156
|
+
</note>
|
157
|
+
<userestrict>Material is copyright of respective artists.</userestrict>
|
158
|
+
|
141
159
|
</c01>
|
142
160
|
</dsc>
|
143
161
|
</ead>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|