hydra-pbcore 2.4.0 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +1 -1
  3. data/Gemfile.lock +135 -0
  4. data/README.md +32 -25
  5. data/Rakefile +1 -1
  6. data/hydra-pbcore.gemspec +3 -1
  7. data/lib/hydra-pbcore.rb +19 -2
  8. data/lib/hydra_pbcore/datastream.rb +0 -1
  9. data/lib/hydra_pbcore/datastream/document.rb +6 -11
  10. data/lib/hydra_pbcore/datastream/instantiation.rb +5 -10
  11. data/lib/hydra_pbcore/methods.rb +0 -6
  12. data/lib/hydra_pbcore/templates.rb +6 -6
  13. data/lib/hydra_pbcore/version.rb +1 -1
  14. data/spec/config_spec.rb +88 -0
  15. data/spec/document_spec.rb +37 -17
  16. data/spec/fixtures/digital_instantiation_solr.xml +1009 -1009
  17. data/spec/fixtures/document_solr.xml +441 -430
  18. data/spec/fixtures/physical_instantiation_solr.xml +291 -282
  19. data/spec/instantiation_spec.rb +38 -6
  20. data/spec/spec_helper.rb +1 -0
  21. metadata +42 -87
  22. data/lib/hydra_pbcore/conversions.rb +0 -107
  23. data/lib/hydra_pbcore/datastream/deprecated.rb +0 -6
  24. data/lib/hydra_pbcore/datastream/deprecated/digital_document.rb +0 -105
  25. data/lib/hydra_pbcore/datastream/deprecated/document.rb +0 -332
  26. data/lib/hydra_pbcore/datastream/deprecated/instantiation.rb +0 -263
  27. data/lib/hydra_pbcore/mapper.rb +0 -50
  28. data/spec/deprecated/digital_document_spec.rb +0 -242
  29. data/spec/deprecated/document_spec.rb +0 -282
  30. data/spec/deprecated/instantiation_spec.rb +0 -214
  31. data/spec/fixtures/converted_digital_document_rrhof_1904.xml +0 -61
  32. data/spec/fixtures/converted_digital_document_rrhof_2405.xml +0 -54
  33. data/spec/fixtures/converted_document_rrhof_2439.xml +0 -19
  34. data/spec/fixtures/converted_document_rrhof_524.xml +0 -45
  35. data/spec/fixtures/converted_instantiation_rrhof_1184.xml +0 -39
  36. data/spec/fixtures/converted_rrhof_524.xml +0 -45
  37. data/spec/fixtures/converted_rrhof_524_instantiation.xml +0 -18
  38. data/spec/fixtures/deprecated/pbcore_digital_document_template.xml +0 -67
  39. data/spec/fixtures/deprecated/pbcore_document_template.xml +0 -90
  40. data/spec/fixtures/deprecated/pbcore_instantiation_template.xml +0 -62
  41. data/spec/fixtures/deprecated/pbcore_solr_digital_document_template.xml +0 -500
  42. data/spec/fixtures/deprecated/pbcore_solr_document_template.xml +0 -592
  43. data/spec/fixtures/deprecated/pbcore_solr_instantiation_template.xml +0 -784
  44. data/spec/fixtures/integration/digital_document_rrhof_1904.xml +0 -67
  45. data/spec/fixtures/integration/digital_document_rrhof_2405.xml +0 -66
  46. data/spec/fixtures/integration/document_rrhof_2439.xml +0 -54
  47. data/spec/fixtures/integration/document_rrhof_524.xml +0 -80
  48. data/spec/fixtures/integration/instantiation_rrhof_1184.xml +0 -44
  49. data/spec/integration/conversions_spec.rb +0 -76
  50. data/spec/mapper_spec.rb +0 -18
@@ -154,7 +154,7 @@ describe HydraPbcore::Datastream::Instantiation do
154
154
  @digital.send("#{field}=".to_sym, field)
155
155
  end
156
156
  # Use a real date
157
- @digital.date = "2012-11"
157
+ @digital.date = "2012-11-01"
158
158
  end
159
159
 
160
160
  it "should match an exmplar" do
@@ -163,11 +163,11 @@ describe HydraPbcore::Datastream::Instantiation do
163
163
  end
164
164
 
165
165
  it "should display dates as they were entered" do
166
- @digital.to_solr["date_display"].should == ["2012-11"]
166
+ @digital.to_solr["date_ssm"].should == ["2012-11-01"]
167
167
  end
168
168
 
169
169
  it "should have dates converted to ISO 8601" do
170
- @digital.to_solr["date_dt"].should == ["2012-11-01T00:00:00Z"]
170
+ @digital.to_solr["date_dtsim"].should == ["2012-11-01T00:00:00Z"]
171
171
  end
172
172
 
173
173
  it "should not index dates as text" do
@@ -236,7 +236,7 @@ describe HydraPbcore::Datastream::Instantiation do
236
236
  @physical.send("#{field}=".to_sym, field)
237
237
  end
238
238
  # Use a real date
239
- @physical.date = "2012-11"
239
+ @physical.date = "2012-11-01"
240
240
  end
241
241
 
242
242
  it "should match an exmplar" do
@@ -245,11 +245,11 @@ describe HydraPbcore::Datastream::Instantiation do
245
245
  end
246
246
 
247
247
  it "should display dates as they were entered" do
248
- @physical.to_solr["date_display"].should == ["2012-11"]
248
+ @physical.to_solr["date_ssm"].should == ["2012-11-01"]
249
249
  end
250
250
 
251
251
  it "should have dates converted to ISO 8601" do
252
- @physical.to_solr["date_dt"].should == ["2012-11-01T00:00:00Z"]
252
+ @physical.to_solr["date_dtsim"].should == ["2012-11-01T00:00:00Z"]
253
253
  end
254
254
 
255
255
  it "should not index dates as text" do
@@ -259,4 +259,36 @@ describe HydraPbcore::Datastream::Instantiation do
259
259
 
260
260
  end
261
261
 
262
+ describe "solrization of dates" do
263
+
264
+ before :each do
265
+ @ds = HydraPbcore::Datastream::Instantiation.new(nil, nil)
266
+ end
267
+
268
+ it "creates dateable and displayable fields for complete dates" do
269
+ @ds.date = "1898-11-12"
270
+ @ds.to_solr["date_dtsim"].should == ["1898-11-12T00:00:00Z"]
271
+ @ds.to_solr["date_ssm"].should == ["1898-11-12"]
272
+ end
273
+
274
+ it "creates only displayable fields for dates without day" do
275
+ @ds.date = "1911-07"
276
+ @ds.to_solr["date_dtsim"].should be_empty
277
+ @ds.to_solr["date_ssm"].should == ["1911-07"]
278
+ end
279
+
280
+ it "creates only displayable fields for dates without day and month" do
281
+ @ds.date = "1945"
282
+ @ds.to_solr["date_dtsim"].should be_empty
283
+ @ds.to_solr["date_ssm"].should == ["1945"]
284
+ end
285
+
286
+ it "creates only displayable for non-parseable dates" do
287
+ @ds.date = "crap"
288
+ @ds.to_solr["date_dtsim"].should be_empty
289
+ @ds.to_solr["date_ssm"].should == ["crap"]
290
+ end
291
+
292
+ end
293
+
262
294
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # :nodoc
2
2
  require "hydra-pbcore"
3
3
  require "equivalent-xml"
4
+ require "pry"
4
5
 
5
6
  RSpec.configure do |config|
6
7
  config.color = true
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-pbcore
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
5
- prerelease:
4
+ version: 3.0.0.rc1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Adam Wead
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-25 00:00:00.000000000 Z
11
+ date: 2013-08-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: active-fedora
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,23 +27,20 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: solrizer
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - <
31
+ - - ! '>='
36
32
  - !ruby/object:Gem::Version
37
- version: 3.0.0
33
+ version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - <
38
+ - - ! '>='
44
39
  - !ruby/object:Gem::Version
45
- version: 3.0.0
40
+ version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: yard
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: redcarpet
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rake
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rspec
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ! '>='
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ! '>='
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rdoc
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ! '>='
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ! '>='
124
109
  - !ruby/object:Gem::Version
@@ -126,7 +111,6 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: equivalent-xml
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
115
  - - ! '>='
132
116
  - !ruby/object:Gem::Version
@@ -134,7 +118,34 @@ dependencies:
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: debugger
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ! '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
138
149
  requirements:
139
150
  - - ! '>='
140
151
  - !ruby/object:Gem::Version
@@ -149,127 +160,71 @@ files:
149
160
  - .gitignore
150
161
  - .travis.yml
151
162
  - Gemfile
163
+ - Gemfile.lock
152
164
  - LICENSE
153
165
  - README.md
154
166
  - Rakefile
155
167
  - hydra-pbcore.gemspec
156
168
  - lib/hydra-pbcore.rb
157
169
  - lib/hydra_pbcore/behaviors.rb
158
- - lib/hydra_pbcore/conversions.rb
159
170
  - lib/hydra_pbcore/datastream.rb
160
- - lib/hydra_pbcore/datastream/deprecated.rb
161
- - lib/hydra_pbcore/datastream/deprecated/digital_document.rb
162
- - lib/hydra_pbcore/datastream/deprecated/document.rb
163
- - lib/hydra_pbcore/datastream/deprecated/instantiation.rb
164
171
  - lib/hydra_pbcore/datastream/document.rb
165
172
  - lib/hydra_pbcore/datastream/instantiation.rb
166
- - lib/hydra_pbcore/mapper.rb
167
173
  - lib/hydra_pbcore/methods.rb
168
174
  - lib/hydra_pbcore/templates.rb
169
175
  - lib/hydra_pbcore/version.rb
170
- - spec/deprecated/digital_document_spec.rb
171
- - spec/deprecated/document_spec.rb
172
- - spec/deprecated/instantiation_spec.rb
176
+ - spec/config_spec.rb
173
177
  - spec/document_spec.rb
174
- - spec/fixtures/converted_digital_document_rrhof_1904.xml
175
- - spec/fixtures/converted_digital_document_rrhof_2405.xml
176
- - spec/fixtures/converted_document_rrhof_2439.xml
177
- - spec/fixtures/converted_document_rrhof_524.xml
178
- - spec/fixtures/converted_instantiation_rrhof_1184.xml
179
- - spec/fixtures/converted_rrhof_524.xml
180
- - spec/fixtures/converted_rrhof_524_instantiation.xml
181
- - spec/fixtures/deprecated/pbcore_digital_document_template.xml
182
- - spec/fixtures/deprecated/pbcore_document_template.xml
183
- - spec/fixtures/deprecated/pbcore_instantiation_template.xml
184
- - spec/fixtures/deprecated/pbcore_solr_digital_document_template.xml
185
- - spec/fixtures/deprecated/pbcore_solr_document_template.xml
186
- - spec/fixtures/deprecated/pbcore_solr_instantiation_template.xml
187
178
  - spec/fixtures/digital_instantiation.xml
188
179
  - spec/fixtures/digital_instantiation_solr.xml
189
180
  - spec/fixtures/digital_instantiation_template.xml
190
181
  - spec/fixtures/document.xml
191
182
  - spec/fixtures/document_solr.xml
192
183
  - spec/fixtures/document_template.xml
193
- - spec/fixtures/integration/digital_document_rrhof_1904.xml
194
- - spec/fixtures/integration/digital_document_rrhof_2405.xml
195
- - spec/fixtures/integration/document_rrhof_2439.xml
196
- - spec/fixtures/integration/document_rrhof_524.xml
197
- - spec/fixtures/integration/instantiation_rrhof_1184.xml
198
184
  - spec/fixtures/physical_instantiation.xml
199
185
  - spec/fixtures/physical_instantiation_solr.xml
200
186
  - spec/fixtures/physical_instantiation_template.xml
201
187
  - spec/instantiation_spec.rb
202
- - spec/integration/conversions_spec.rb
203
- - spec/mapper_spec.rb
204
188
  - spec/methods_spec.rb
205
189
  - spec/spec_helper.rb
206
190
  - spec/templates_spec.rb
207
191
  - tmp/.gitkeep
208
192
  homepage: ''
209
193
  licenses: []
194
+ metadata: {}
210
195
  post_install_message:
211
196
  rdoc_options: []
212
197
  require_paths:
213
198
  - lib
214
199
  required_ruby_version: !ruby/object:Gem::Requirement
215
- none: false
216
200
  requirements:
217
201
  - - ! '>='
218
202
  - !ruby/object:Gem::Version
219
203
  version: '0'
220
- segments:
221
- - 0
222
- hash: 3882171645005853524
223
204
  required_rubygems_version: !ruby/object:Gem::Requirement
224
- none: false
225
205
  requirements:
226
- - - ! '>='
206
+ - - ! '>'
227
207
  - !ruby/object:Gem::Version
228
- version: '0'
229
- segments:
230
- - 0
231
- hash: 3882171645005853524
208
+ version: 1.3.1
232
209
  requirements: []
233
210
  rubyforge_project:
234
- rubygems_version: 1.8.23
211
+ rubygems_version: 2.0.3
235
212
  signing_key:
236
- specification_version: 3
213
+ specification_version: 4
237
214
  summary: A Hydra gem that offers PBCore datastream definitions using OM
238
215
  test_files:
239
- - spec/deprecated/digital_document_spec.rb
240
- - spec/deprecated/document_spec.rb
241
- - spec/deprecated/instantiation_spec.rb
216
+ - spec/config_spec.rb
242
217
  - spec/document_spec.rb
243
- - spec/fixtures/converted_digital_document_rrhof_1904.xml
244
- - spec/fixtures/converted_digital_document_rrhof_2405.xml
245
- - spec/fixtures/converted_document_rrhof_2439.xml
246
- - spec/fixtures/converted_document_rrhof_524.xml
247
- - spec/fixtures/converted_instantiation_rrhof_1184.xml
248
- - spec/fixtures/converted_rrhof_524.xml
249
- - spec/fixtures/converted_rrhof_524_instantiation.xml
250
- - spec/fixtures/deprecated/pbcore_digital_document_template.xml
251
- - spec/fixtures/deprecated/pbcore_document_template.xml
252
- - spec/fixtures/deprecated/pbcore_instantiation_template.xml
253
- - spec/fixtures/deprecated/pbcore_solr_digital_document_template.xml
254
- - spec/fixtures/deprecated/pbcore_solr_document_template.xml
255
- - spec/fixtures/deprecated/pbcore_solr_instantiation_template.xml
256
218
  - spec/fixtures/digital_instantiation.xml
257
219
  - spec/fixtures/digital_instantiation_solr.xml
258
220
  - spec/fixtures/digital_instantiation_template.xml
259
221
  - spec/fixtures/document.xml
260
222
  - spec/fixtures/document_solr.xml
261
223
  - spec/fixtures/document_template.xml
262
- - spec/fixtures/integration/digital_document_rrhof_1904.xml
263
- - spec/fixtures/integration/digital_document_rrhof_2405.xml
264
- - spec/fixtures/integration/document_rrhof_2439.xml
265
- - spec/fixtures/integration/document_rrhof_524.xml
266
- - spec/fixtures/integration/instantiation_rrhof_1184.xml
267
224
  - spec/fixtures/physical_instantiation.xml
268
225
  - spec/fixtures/physical_instantiation_solr.xml
269
226
  - spec/fixtures/physical_instantiation_template.xml
270
227
  - spec/instantiation_spec.rb
271
- - spec/integration/conversions_spec.rb
272
- - spec/mapper_spec.rb
273
228
  - spec/methods_spec.rb
274
229
  - spec/spec_helper.rb
275
230
  - spec/templates_spec.rb
@@ -1,107 +0,0 @@
1
- # Methods for converting HydraPbcore 1.x datastreams to HydraPbcore 2.x datastreams
2
- #
3
- # Verion 1.x of the HydraPbcore gem uses two kinds of pbcoreDocuments, one which includes an instantation
4
- # and one which does not. Version 2 of the gem refactors these so that there
5
- # is only one kind of pbcoreDocument and two kinds of instatiations. This offers greater flexibility
6
- # as any number of instantiations may be attached to a document. Instatntiations come in two types,
7
- # one is physical, meaning it represents a tape or other
8
- # tangible object on which the video content resides, while the other kind is
9
- # digital, representing a video file.
10
- #
11
- # These methods attempt to correct invalid or inconsistent xml created using the first version of the
12
- # gem.
13
-
14
- module HydraPbcore::Conversions
15
-
16
- # Converts a HydraPbcore::Datastream::Deprecated::Document to a HydraPbcore::Datastream::Document
17
- # - the existing pbcoreInstantiation node is removed and returned
18
- def to_document xml = self.ng_xml
19
- xml.search("//pbcoreInstantiation").remove
20
- end
21
-
22
- # Extracts the instantation from a HydraPbcore::Datastream::Deprecated::Document and returns
23
- # a physical HydraPbcore::Datastream::Instantion
24
- # - removes all instantiationRelation nodes
25
- # - adds source="PBCore instantiationColors" to instantiationColors node
26
- # - extracts the pbcoreInstantiation node and returns new Instantiation object
27
- def to_physical_instantiation xml = self.ng_xml
28
- xml.search("//instantiationRelation").each do |node|
29
- node.remove
30
- end
31
- xml.search("//instantiationColors").first["source"] = "PBCore instantiationColors"
32
- inst_xml = xml.xpath("//pbcoreInstantiation")
33
- HydraPbcore::Datastream::Instantiation.from_xml(inst_xml.to_xml)
34
- end
35
-
36
- # Converts a HydraPbcore::Datastream::Deprecated::Instantiation to a HydraPbcore::Datastream::Instantiation
37
- # Modifies the exiting xml to exclude any parent nodes of the pbcoreInstantiation node
38
- def to_instantiation
39
- self.ng_xml = self.ng_xml.xpath("//pbcoreInstantiation").to_xml
40
- end
41
-
42
- # Corrects errors in HydraPbcore::Datastream::Deprecated::Document
43
- # - removes all pbcoreRelation nodes, except those that define event_series
44
- # - removes orphaned pbcoreRelationIdentifier nodes
45
- # - corrects invalid usage of event_place and event_series terms
46
- def clean_document xml = self.ng_xml
47
- xml.search("//pbcoreRelation").each do |node|
48
- node.remove unless is_relation?("Event Series", node)
49
- end
50
- xml.search("/pbcoreDescriptionDocument/pbcoreRelationIdentifier").collect {|n| n.remove}
51
- xml.search("/pbcoreDescriptionDocument/instantiationRelationIdentifier").collect {|n| n.remove}
52
- xml.search("//pbcoreCoverage").each do |node|
53
- node.children.each do |c|
54
- if c.attribute("annotation").nil? and c.name == "coverage"
55
- self.send(("insert_"+coverage_type(node)), c.text)
56
- c.remove
57
- end
58
- end
59
- end
60
- end
61
-
62
- # Corrects errors in HydraPbcore::Datastream::Deprecated::DigitalDocument
63
- # - finds the current archival collection
64
- # - removes all pbcoreRelation nodes, except those that define event_series
65
- # - re-inserts the collection
66
- # - removes orphaned pbcoreRelationIdentifier nodes
67
- # - corrects invalid usage of event_place and event_series terms
68
- def clean_digital_document xml = self.ng_xml
69
- collection = xml.search("//pbcoreRelationIdentifier[@annotation='Archival Collection']").text
70
- xml.search("//pbcoreRelation").each do |node|
71
- unless is_relation?("Accession Number", node) or is_relation?("Event Series", node)
72
- node.remove
73
- end
74
- end
75
- xml.search("/pbcoreDescriptionDocument/pbcoreRelationIdentifier").collect {|n| n.remove}
76
- xml.search("/pbcoreDescriptionDocument/instantiationRelationIdentifier").collect {|n| n.remove}
77
- self.insert_relation(collection, "Archival Collection") unless collection.nil?
78
- xml.search("//pbcoreCoverage").each do |node|
79
- node.children.each do |c|
80
- if c.attribute("annotation").nil? and c.name == "coverage"
81
- self.send(("insert_"+coverage_type(node)), c.text)
82
- c.remove
83
- end
84
- end
85
- end
86
- end
87
-
88
- # Determines if the given node defines a relation of a give type
89
- def is_relation? type, node
90
- unless node.at_xpath("pbcoreRelationIdentifier").nil?
91
- if node.at_xpath("pbcoreRelationIdentifier").attribute("annotation").to_s == type
92
- return true
93
- end
94
- end
95
- end
96
-
97
- # Determines if a coverage node that has no annotation attribute should be either an event_date term or an event_date term.
98
- # Returns the first instance of an annotation attribute, processing it so that may be sent directly to
99
- # the datastream as a method.
100
- def coverage_type node
101
- node.children.each do |c|
102
- return c.attribute("annotation").to_s.split.last.downcase unless c.attribute("annotation").nil?
103
- end
104
- end
105
-
106
-
107
- end