hydra-pbcore 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Rakefile +6 -0
- data/lib/hydra-pbcore.rb +60 -1
- data/lib/hydra-pbcore/behaviors.rb +4 -2
- data/lib/hydra-pbcore/conversions.rb +88 -0
- data/lib/hydra-pbcore/datastream/{digital_document.rb → deprecated/digital_document.rb} +3 -2
- data/lib/hydra-pbcore/datastream/deprecated/document.rb +310 -0
- data/lib/hydra-pbcore/datastream/deprecated/instantiation.rb +261 -0
- data/lib/hydra-pbcore/datastream/document.rb +37 -139
- data/lib/hydra-pbcore/datastream/instantiation.rb +184 -223
- data/lib/hydra-pbcore/methods.rb +23 -2
- data/lib/hydra-pbcore/templates.rb +116 -0
- data/lib/hydra-pbcore/version.rb +1 -1
- data/spec/{digital_document_spec.rb → deprecated/digital_document_spec.rb} +6 -26
- data/spec/deprecated/document_spec.rb +282 -0
- data/spec/deprecated/instantiation_spec.rb +214 -0
- data/spec/document_spec.rb +71 -194
- data/spec/fixtures/converted_digital_document_rrhof_1904.xml +53 -0
- data/spec/fixtures/converted_digital_document_rrhof_2405.xml +46 -0
- data/spec/fixtures/converted_document_rrhof_2439.xml +19 -0
- data/spec/fixtures/converted_document_rrhof_524.xml +45 -0
- data/spec/fixtures/converted_instantiation_rrhof_1184.xml +39 -0
- data/spec/fixtures/converted_rrhof_524.xml +45 -0
- data/spec/fixtures/converted_rrhof_524_instantiation.xml +18 -0
- data/spec/fixtures/{pbcore_digital_document_template.xml → deprecated/pbcore_digital_document_template.xml} +0 -0
- data/spec/fixtures/{pbcore_document_template.xml → deprecated/pbcore_document_template.xml} +0 -0
- data/spec/fixtures/{pbcore_instantiation_template.xml → deprecated/pbcore_instantiation_template.xml} +0 -0
- data/spec/fixtures/{pbcore_solr_digital_document_template.xml → deprecated/pbcore_solr_digital_document_template.xml} +0 -0
- data/spec/fixtures/{pbcore_solr_document_template.xml → deprecated/pbcore_solr_document_template.xml} +0 -0
- data/spec/fixtures/{pbcore_solr_instantiation_template.xml → deprecated/pbcore_solr_instantiation_template.xml} +0 -0
- data/spec/fixtures/digital_instantiation.xml +56 -0
- data/spec/fixtures/digital_instantiation_solr.xml +1913 -0
- data/spec/fixtures/digital_instantiation_template.xml +33 -0
- data/spec/fixtures/document.xml +72 -0
- data/spec/fixtures/document_solr.xml +582 -0
- data/spec/fixtures/document_template.xml +30 -0
- data/spec/fixtures/integration/digital_document_rrhof_1904.xml +63 -0
- data/spec/fixtures/integration/digital_document_rrhof_2405.xml +62 -0
- data/spec/fixtures/integration/document_rrhof_2439.xml +54 -0
- data/spec/fixtures/integration/document_rrhof_524.xml +80 -0
- data/spec/fixtures/integration/instantiation_rrhof_1184.xml +44 -0
- data/spec/fixtures/physical_instantiation.xml +20 -0
- data/spec/fixtures/physical_instantiation_solr.xml +441 -0
- data/spec/fixtures/physical_instantiation_template.xml +18 -0
- data/spec/instantiation_spec.rb +180 -132
- data/spec/integration/conversions_spec.rb +73 -0
- data/spec/spec_helper.rb +37 -9
- data/spec/templates_spec.rb +31 -0
- metadata +68 -17
@@ -0,0 +1,18 @@
|
|
1
|
+
<pbcoreInstantiation>
|
2
|
+
<instantiationIdentifier annotation="Barcode" source="Rock and Roll Hall of Fame and Museum"/>
|
3
|
+
<instantiationDate dateType="created"/>
|
4
|
+
<instantiationPhysical source="PBCore instantiationPhysical"/>
|
5
|
+
<instantiationStandard/>
|
6
|
+
<instantiationLocation>Rock and Roll Hall of Fame and Museum,
|
7
|
+
2809 Woodland Ave.,
|
8
|
+
Cleveland, OH, 44115
|
9
|
+
216-515-1956
|
10
|
+
library@rockhall.org</instantiationLocation>
|
11
|
+
<instantiationMediaType source="PBCore instantiationMediaType">Moving image</instantiationMediaType>
|
12
|
+
<instantiationGenerations source="PBCore instantiationGenerations">Original</instantiationGenerations>
|
13
|
+
<instantiationColors source="PBCore instantiationColors">Color</instantiationColors>
|
14
|
+
<instantiationLanguage source="ISO 639.2" ref="http://www.loc.gov/standards/iso639-2/php/code_list.php">eng</instantiationLanguage>
|
15
|
+
<instantiationRights>
|
16
|
+
<rightsSummary/>
|
17
|
+
</instantiationRights>
|
18
|
+
</pbcoreInstantiation>
|
data/spec/instantiation_spec.rb
CHANGED
@@ -3,11 +3,20 @@ require "spec_helper"
|
|
3
3
|
describe HydraPbcore::Datastream::Instantiation do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
@
|
6
|
+
@digital = HydraPbcore::Datastream::Instantiation.new(nil, nil)
|
7
|
+
@digital.define :digital
|
8
|
+
@physical = HydraPbcore::Datastream::Instantiation.new(nil, nil)
|
9
|
+
@physical.define :physical
|
7
10
|
end
|
8
11
|
|
9
|
-
describe "
|
10
|
-
it "should
|
12
|
+
describe "::xml_template" do
|
13
|
+
it "should have a blank default xml template" do
|
14
|
+
HydraPbcore::Datastream::Instantiation.xml_template.text.should be_empty
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "digital instantiaions" do
|
19
|
+
it "should have these fields defined" do
|
11
20
|
[
|
12
21
|
[:name],
|
13
22
|
[:location],
|
@@ -50,165 +59,204 @@ describe HydraPbcore::Datastream::Instantiation do
|
|
50
59
|
[:audio_bit_depth],
|
51
60
|
[:audio_channels],
|
52
61
|
].each do |pointer|
|
53
|
-
test_val =
|
54
|
-
@
|
55
|
-
@
|
56
|
-
@
|
62
|
+
test_val = random_string
|
63
|
+
@digital.update_indexed_attributes( {pointer=>{"0"=>test_val}} )
|
64
|
+
@digital.get_values(pointer).first.should == test_val
|
65
|
+
@digital.get_values(pointer).length.should == 1
|
57
66
|
end
|
58
67
|
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "default fields" do
|
62
68
|
|
63
|
-
it "
|
64
|
-
@
|
69
|
+
it "should have default values for fields" do
|
70
|
+
@digital.media_type.first.should == "Moving image"
|
71
|
+
@digital.colors.first.should == "Color"
|
65
72
|
end
|
66
73
|
|
67
|
-
it "
|
68
|
-
@
|
74
|
+
it "should have a file format and no format" do
|
75
|
+
@digital.file_format.should == [""]
|
76
|
+
@digital.format.should == []
|
69
77
|
end
|
70
78
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
@
|
78
|
-
@
|
79
|
-
@
|
80
|
-
@
|
81
|
-
@
|
82
|
-
@
|
83
|
-
@
|
84
|
-
@
|
85
|
-
@
|
86
|
-
@
|
87
|
-
@object_ds.update_indexed_attributes({ [:cleaning] => { 0 => "inserted" }} )
|
88
|
-
@object_ds.update_indexed_attributes({ [:color_space] => { 0 => "inserted" }} )
|
89
|
-
@object_ds.update_indexed_attributes({ [:chroma] => { 0 => "inserted" }} )
|
90
|
-
@object_ds.update_indexed_attributes({ [:standard] => { 0 => "inserted" }} )
|
91
|
-
@object_ds.update_indexed_attributes({ [:language] => { 0 => "inserted" }} )
|
79
|
+
it "should match an exmplar with all fields shown" do
|
80
|
+
@digital.checksum_type = "inserted"
|
81
|
+
@digital.note = "inserted"
|
82
|
+
@digital.checksum_value = "inserted"
|
83
|
+
@digital.device = "inserted"
|
84
|
+
@digital.capture_soft = "inserted"
|
85
|
+
@digital.trans_soft = "inserted"
|
86
|
+
@digital.operator = "inserted"
|
87
|
+
@digital.trans_note = "inserted"
|
88
|
+
@digital.vendor = "inserted"
|
89
|
+
@digital.condition = "inserted"
|
90
|
+
@digital.cleaning = "inserted"
|
91
|
+
@digital.color_space = "inserted"
|
92
|
+
@digital.chroma = "inserted"
|
93
|
+
@digital.standard = "inserted"
|
94
|
+
@digital.language = "inserted"
|
92
95
|
|
93
96
|
# insert optional nodes using sample values
|
94
|
-
@
|
95
|
-
@
|
96
|
-
|
97
|
-
# Load example fixture
|
98
|
-
f = fixture "pbcore_instantiation_template.xml"
|
99
|
-
ref_node = Nokogiri::XML(f)
|
100
|
-
f.close
|
101
|
-
|
102
|
-
# Nokogiri-fy our sample document and add in namespace
|
103
|
-
sample_node = Nokogiri::XML(@object_ds.to_xml)
|
104
|
-
with_namespace = HydraPbcore::Behaviors.insert_pbcore_namespace(sample_node)
|
105
|
-
|
106
|
-
# Save this for later...
|
107
|
-
out = File.new("tmp/pbcore_instantiation_sample.xml", "w")
|
108
|
-
out.write(with_namespace.to_s)
|
109
|
-
out.close
|
97
|
+
@digital.insert_next("inserted")
|
98
|
+
@digital.insert_previous("inserted")
|
110
99
|
|
111
|
-
|
112
|
-
|
113
|
-
# TODO: reorder nodes on the instantiaion
|
114
|
-
#Rockhall::Pbcore.validate(with_namespace).should be_empty
|
100
|
+
save_template @digital.to_xml, "digital_instantiation.xml"
|
101
|
+
equivalent_xml_files("digital_instantiation.xml").should be_true
|
115
102
|
end
|
116
|
-
|
103
|
+
|
104
|
+
it "should have different essenceTrackStandard nodes" do
|
105
|
+
@digital.video_standard = "video standard"
|
106
|
+
@digital.audio_standard = "audio standard"
|
107
|
+
@digital.get_values([{:pbcoreInstantiation=>0}, {:instantiationEssenceTrack=>0}, :essenceTrackStandard]).first.should == "video standard"
|
108
|
+
@digital.get_values([{:pbcoreInstantiation=>0}, {:instantiationEssenceTrack=>1}, :essenceTrackStandard]).first.should == "audio standard"
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "solr documents" do
|
112
|
+
before(:each) do
|
113
|
+
[
|
114
|
+
"name",
|
115
|
+
"location",
|
116
|
+
"generation",
|
117
|
+
"media_type",
|
118
|
+
"file_format",
|
119
|
+
"size",
|
120
|
+
"size_units",
|
121
|
+
"colors",
|
122
|
+
"duration",
|
123
|
+
"rights_summary",
|
124
|
+
"note",
|
125
|
+
"checksum_type",
|
126
|
+
"checksum_value",
|
127
|
+
"device",
|
128
|
+
"capture_soft",
|
129
|
+
"trans_soft",
|
130
|
+
"operator",
|
131
|
+
"trans_note",
|
132
|
+
"vendor",
|
133
|
+
"condition",
|
134
|
+
"cleaning",
|
135
|
+
"color_space",
|
136
|
+
"chroma",
|
137
|
+
"video_standard",
|
138
|
+
"video_encoding",
|
139
|
+
"video_bit_rate",
|
140
|
+
"video_bit_rate_units",
|
141
|
+
"frame_rate",
|
142
|
+
"frame_size",
|
143
|
+
"video_bit_depth",
|
144
|
+
"aspect_ratio",
|
145
|
+
"audio_standard",
|
146
|
+
"audio_encoding",
|
147
|
+
"audio_bit_rate",
|
148
|
+
"audio_bit_rate_units",
|
149
|
+
"audio_sample_rate",
|
150
|
+
"audio_sample_rate_units",
|
151
|
+
"audio_bit_depth",
|
152
|
+
"audio_channels"
|
153
|
+
].each do |field|
|
154
|
+
@digital.send("#{field}=".to_sym, field)
|
155
|
+
end
|
156
|
+
# Use a real date
|
157
|
+
@digital.date = "2012-11"
|
158
|
+
end
|
117
159
|
|
118
|
-
|
160
|
+
it "should match an exmplar" do
|
161
|
+
save_template @digital.to_solr.to_xml, "digital_instantiation_solr.xml"
|
162
|
+
equivalent_xml_files("digital_instantiation_solr.xml").should be_true
|
163
|
+
end
|
119
164
|
|
120
|
-
|
165
|
+
it "should display dates as they were entered" do
|
166
|
+
@digital.to_solr["date_display"].should == ["2012-11"]
|
167
|
+
end
|
121
168
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
@object_ds.get_values([{:pbcoreInstantiation=>0}, {:instantiationEssenceTrack=>0}, :essenceTrackStandard]).first.should == "video standard"
|
126
|
-
@object_ds.get_values([{:pbcoreInstantiation=>0}, {:instantiationEssenceTrack=>1}, :essenceTrackStandard]).first.should == "audio standard"
|
169
|
+
it "should have dates converted to ISO 8601" do
|
170
|
+
@digital.to_solr["date_dt"].should == ["2012-11-01T00:00:00Z"]
|
171
|
+
end
|
127
172
|
|
173
|
+
it "should not index dates as text" do
|
174
|
+
@digital.to_solr["date_t"].should be_nil
|
175
|
+
end
|
128
176
|
end
|
129
|
-
|
177
|
+
|
130
178
|
end
|
131
179
|
|
132
|
-
describe "
|
133
|
-
|
134
|
-
before(:each) do
|
180
|
+
describe "physical instantiaions" do
|
181
|
+
it "should have these fields defined" do
|
135
182
|
[
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
"
|
151
|
-
|
152
|
-
|
153
|
-
"trans_note",
|
154
|
-
"vendor",
|
155
|
-
"condition",
|
156
|
-
"cleaning",
|
157
|
-
"color_space",
|
158
|
-
"chroma",
|
159
|
-
"video_standard",
|
160
|
-
"video_encoding",
|
161
|
-
"video_bit_rate",
|
162
|
-
"video_bit_rate_units",
|
163
|
-
"frame_rate",
|
164
|
-
"frame_size",
|
165
|
-
"video_bit_depth",
|
166
|
-
"aspect_ratio",
|
167
|
-
"audio_standard",
|
168
|
-
"audio_encoding",
|
169
|
-
"audio_bit_rate",
|
170
|
-
"audio_bit_rate_units",
|
171
|
-
"audio_sample_rate",
|
172
|
-
"audio_sample_rate_units",
|
173
|
-
"audio_bit_depth",
|
174
|
-
"audio_channels"
|
175
|
-
].each do |field|
|
176
|
-
@object_ds.send("#{field}=".to_sym, field)
|
183
|
+
[:date],
|
184
|
+
[:barcode],
|
185
|
+
[:location],
|
186
|
+
[:format],
|
187
|
+
[:standard],
|
188
|
+
[:media_type],
|
189
|
+
[:generation],
|
190
|
+
[:language],
|
191
|
+
[:colors],
|
192
|
+
[:rights_summary],
|
193
|
+
[:condition_note],
|
194
|
+
[:cleaning_note]
|
195
|
+
].each do |pointer|
|
196
|
+
test_val = random_string
|
197
|
+
@physical.update_indexed_attributes( {pointer=>{"0"=>test_val}} )
|
198
|
+
@physical.get_values(pointer).first.should == test_val
|
199
|
+
@physical.get_values(pointer).length.should == 1
|
177
200
|
end
|
201
|
+
end
|
178
202
|
|
179
|
-
|
180
|
-
|
203
|
+
it "should have default values for fields" do
|
204
|
+
@physical.media_type.first.should == "Moving image"
|
205
|
+
@physical.colors.first.should == "Color"
|
181
206
|
end
|
182
207
|
|
183
|
-
it "should
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
f.close
|
208
|
+
it "should have a format and no file format" do
|
209
|
+
@physical.file_format.should == []
|
210
|
+
@physical.format.should == [""]
|
211
|
+
end
|
188
212
|
|
189
|
-
|
190
|
-
|
213
|
+
it "should match an exmplar with all fields shown" do
|
214
|
+
@physical.cleaning_note = "inserted"
|
215
|
+
@physical.condition_note = "inserted"
|
216
|
+
save_template @physical.to_xml, "physical_instantiation.xml"
|
217
|
+
equivalent_xml_files("physical_instantiation.xml").should be_true
|
218
|
+
end
|
191
219
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
220
|
+
describe "solr documents" do
|
221
|
+
before :each do
|
222
|
+
[
|
223
|
+
"date",
|
224
|
+
"barcode",
|
225
|
+
"location",
|
226
|
+
"format",
|
227
|
+
"standard",
|
228
|
+
"media_type",
|
229
|
+
"generation",
|
230
|
+
"language",
|
231
|
+
"colors",
|
232
|
+
"rights_summary",
|
233
|
+
"condition_note",
|
234
|
+
"cleaning_note"
|
235
|
+
].each do |field|
|
236
|
+
@physical.send("#{field}=".to_sym, field)
|
237
|
+
end
|
238
|
+
# Use a real date
|
239
|
+
@physical.date = "2012-11"
|
240
|
+
end
|
196
241
|
|
197
|
-
|
198
|
-
|
242
|
+
it "should match an exmplar" do
|
243
|
+
save_template @physical.to_solr.to_xml, "physical_instantiation_solr.xml"
|
244
|
+
equivalent_xml_files("physical_instantiation_solr.xml").should be_true
|
245
|
+
end
|
199
246
|
|
200
|
-
|
201
|
-
|
202
|
-
|
247
|
+
it "should display dates as they were entered" do
|
248
|
+
@physical.to_solr["date_display"].should == ["2012-11"]
|
249
|
+
end
|
203
250
|
|
204
|
-
|
205
|
-
|
206
|
-
|
251
|
+
it "should have dates converted to ISO 8601" do
|
252
|
+
@physical.to_solr["date_dt"].should == ["2012-11-01T00:00:00Z"]
|
253
|
+
end
|
207
254
|
|
208
|
-
|
209
|
-
|
255
|
+
it "should not index dates as text" do
|
256
|
+
@physical.to_solr["date_t"].should be_nil
|
257
|
+
end
|
210
258
|
end
|
211
259
|
|
212
260
|
end
|
213
261
|
|
214
|
-
end
|
262
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Converting" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
class FakeDocument
|
7
|
+
include HydraPbcore::Conversions
|
8
|
+
end
|
9
|
+
@fake = FakeDocument.new
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "HydraPbcore::Datastream::Deprecated::Document to HydraPbcore::Datastream::Document" do
|
13
|
+
it "should return a valid pbcore document" do
|
14
|
+
doc = HydraPbcore::Datastream::Deprecated::Document.from_xml(integration_fixture "document_rrhof_524.xml")
|
15
|
+
doc.to_document
|
16
|
+
save_template doc.to_xml, "converted_rrhof_524.xml"
|
17
|
+
equivalent_xml_files("converted_rrhof_524.xml").should be_true
|
18
|
+
end
|
19
|
+
it "should raise an error with the wrong class" do
|
20
|
+
lambda { @fake.to_document }.should raise_error
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "HydraPbcore::Datastream::Deprecated::Document to HydraPbcore::Datastream::Instantiation" do
|
25
|
+
it "should return a physical instantation from an existing document" do
|
26
|
+
doc = HydraPbcore::Datastream::Deprecated::Document.from_xml(integration_fixture "document_rrhof_524.xml")
|
27
|
+
inst = doc.to_physical_instantiation
|
28
|
+
inst.should be_kind_of HydraPbcore::Datastream::Instantiation
|
29
|
+
save_template inst.to_xml, "converted_rrhof_524_instantiation.xml"
|
30
|
+
equivalent_xml_files("converted_rrhof_524_instantiation.xml").should be_true
|
31
|
+
end
|
32
|
+
it "should raise an error with the wrong class" do
|
33
|
+
lambda { @fake.to_document }.should raise_error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "HydraPbcore::Datastream::Deprecated::Instantiation to HydraPbcore::Datastream::Instantiation" do
|
38
|
+
it "should return a valid instantation" do
|
39
|
+
inst = HydraPbcore::Datastream::Deprecated::Instantiation.from_xml(integration_fixture "instantiation_rrhof_1184.xml")
|
40
|
+
inst.to_instantiation
|
41
|
+
save_template inst.to_xml, "converted_instantiation_rrhof_1184.xml"
|
42
|
+
equivalent_xml_files("converted_instantiation_rrhof_1184.xml").should be_true
|
43
|
+
end
|
44
|
+
it "should raise an error with the wrong class" do
|
45
|
+
lambda { @fake.to_document }.should raise_error
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#clean_document" do
|
50
|
+
it "should correct invalid pbcoreDigitalDocuments" do
|
51
|
+
["digital_document_rrhof_1904.xml","digital_document_rrhof_2405.xml"].each do |file|
|
52
|
+
doc = HydraPbcore::Datastream::Deprecated::DigitalDocument.from_xml(integration_fixture file)
|
53
|
+
doc.clean_document
|
54
|
+
save_template doc.to_xml, ("converted_"+file)
|
55
|
+
equivalent_xml_files(("converted_"+file)).should be_true
|
56
|
+
save_template doc.to_pbcore_xml, "valid_pbcore.xml"
|
57
|
+
doc.valid?.should == []
|
58
|
+
end
|
59
|
+
end
|
60
|
+
it "should correct invalid pbcoreDocuments" do
|
61
|
+
["document_rrhof_524.xml","document_rrhof_2439.xml"].each do |file|
|
62
|
+
doc = HydraPbcore::Datastream::Deprecated::Document.from_xml(integration_fixture file)
|
63
|
+
doc.to_document
|
64
|
+
doc.clean_document
|
65
|
+
save_template doc.to_xml, ("converted_"+file)
|
66
|
+
equivalent_xml_files(("converted_"+file)).should be_true
|
67
|
+
save_template doc.to_pbcore_xml, "valid_pbcore.xml"
|
68
|
+
doc.valid?.should == []
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|