hydra-pbcore 1.0.0 → 1.1.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.
Files changed (49) hide show
  1. data/.gitignore +1 -0
  2. data/Rakefile +6 -0
  3. data/lib/hydra-pbcore.rb +60 -1
  4. data/lib/hydra-pbcore/behaviors.rb +4 -2
  5. data/lib/hydra-pbcore/conversions.rb +88 -0
  6. data/lib/hydra-pbcore/datastream/{digital_document.rb → deprecated/digital_document.rb} +3 -2
  7. data/lib/hydra-pbcore/datastream/deprecated/document.rb +310 -0
  8. data/lib/hydra-pbcore/datastream/deprecated/instantiation.rb +261 -0
  9. data/lib/hydra-pbcore/datastream/document.rb +37 -139
  10. data/lib/hydra-pbcore/datastream/instantiation.rb +184 -223
  11. data/lib/hydra-pbcore/methods.rb +23 -2
  12. data/lib/hydra-pbcore/templates.rb +116 -0
  13. data/lib/hydra-pbcore/version.rb +1 -1
  14. data/spec/{digital_document_spec.rb → deprecated/digital_document_spec.rb} +6 -26
  15. data/spec/deprecated/document_spec.rb +282 -0
  16. data/spec/deprecated/instantiation_spec.rb +214 -0
  17. data/spec/document_spec.rb +71 -194
  18. data/spec/fixtures/converted_digital_document_rrhof_1904.xml +53 -0
  19. data/spec/fixtures/converted_digital_document_rrhof_2405.xml +46 -0
  20. data/spec/fixtures/converted_document_rrhof_2439.xml +19 -0
  21. data/spec/fixtures/converted_document_rrhof_524.xml +45 -0
  22. data/spec/fixtures/converted_instantiation_rrhof_1184.xml +39 -0
  23. data/spec/fixtures/converted_rrhof_524.xml +45 -0
  24. data/spec/fixtures/converted_rrhof_524_instantiation.xml +18 -0
  25. data/spec/fixtures/{pbcore_digital_document_template.xml → deprecated/pbcore_digital_document_template.xml} +0 -0
  26. data/spec/fixtures/{pbcore_document_template.xml → deprecated/pbcore_document_template.xml} +0 -0
  27. data/spec/fixtures/{pbcore_instantiation_template.xml → deprecated/pbcore_instantiation_template.xml} +0 -0
  28. data/spec/fixtures/{pbcore_solr_digital_document_template.xml → deprecated/pbcore_solr_digital_document_template.xml} +0 -0
  29. data/spec/fixtures/{pbcore_solr_document_template.xml → deprecated/pbcore_solr_document_template.xml} +0 -0
  30. data/spec/fixtures/{pbcore_solr_instantiation_template.xml → deprecated/pbcore_solr_instantiation_template.xml} +0 -0
  31. data/spec/fixtures/digital_instantiation.xml +56 -0
  32. data/spec/fixtures/digital_instantiation_solr.xml +1913 -0
  33. data/spec/fixtures/digital_instantiation_template.xml +33 -0
  34. data/spec/fixtures/document.xml +72 -0
  35. data/spec/fixtures/document_solr.xml +582 -0
  36. data/spec/fixtures/document_template.xml +30 -0
  37. data/spec/fixtures/integration/digital_document_rrhof_1904.xml +63 -0
  38. data/spec/fixtures/integration/digital_document_rrhof_2405.xml +62 -0
  39. data/spec/fixtures/integration/document_rrhof_2439.xml +54 -0
  40. data/spec/fixtures/integration/document_rrhof_524.xml +80 -0
  41. data/spec/fixtures/integration/instantiation_rrhof_1184.xml +44 -0
  42. data/spec/fixtures/physical_instantiation.xml +20 -0
  43. data/spec/fixtures/physical_instantiation_solr.xml +441 -0
  44. data/spec/fixtures/physical_instantiation_template.xml +18 -0
  45. data/spec/instantiation_spec.rb +180 -132
  46. data/spec/integration/conversions_spec.rb +73 -0
  47. data/spec/spec_helper.rb +37 -9
  48. data/spec/templates_spec.rb +31 -0
  49. metadata +68 -17
data/spec/spec_helper.rb CHANGED
@@ -4,18 +4,46 @@ require "debugger"
4
4
  require "equivalent-xml"
5
5
 
6
6
  RSpec.configure do |config|
7
+ config.color = true
8
+ end
7
9
 
8
- # == Mock Framework
9
- # Note: we're not mocking... yet.
10
- # config.mock_with :mocha
11
- # config.mock_with :flexmock
12
- # config.mock_with :rr
13
- #config.mock_with :rspec
10
+ # Returns a file from spec/fixtures
11
+ def fixture(file)
12
+ File.new(File.join(File.dirname(__FILE__), 'fixtures', file))
13
+ end
14
14
 
15
- config.color = true
15
+ # Returns a file from spec/fixtures/deprecated
16
+ def deprecated_fixture(file)
17
+ File.new(File.join(File.dirname(__FILE__), 'fixtures', 'deprecated', file))
18
+ end
16
19
 
20
+ # Returns a file from tmp
21
+ def sample(file)
22
+ File.new(File.join('tmp', file))
17
23
  end
18
24
 
19
- def fixture(file) #:nodoc
20
- File.new(File.join(File.dirname(__FILE__), 'fixtures', file))
25
+ # Returns a Nokogiri::XML object from spec/fixtures/integration
26
+ def integration_fixture(file)
27
+ Nokogiri::XML(File.new(File.join(File.dirname(__FILE__), 'fixtures', 'integration', file)))
28
+ end
29
+
30
+ # Saves a sample template to tmp
31
+ def save_template input, filename
32
+ out = File.new(File.join("tmp", filename), "w")
33
+ out.write(input.to_s)
34
+ out.close
21
35
  end
36
+
37
+ # Tests if a file in spec/fixtures is the same as the file in tmp
38
+ def equivalent_xml_files(file)
39
+ f = Nokogiri::XML(fixture file)
40
+ s = Nokogiri::XML(sample file)
41
+ EquivalentXml.equivalent?(
42
+ f, s,
43
+ opts = { :element_order => false, :normalize_whitespace => true }
44
+ )
45
+ end
46
+
47
+ def random_string
48
+ (0...50).map{ ('a'..'z').to_a[rand(26)] }.join
49
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe HydraPbcore::Templates do
4
+
5
+ before :each do
6
+ class TestClass
7
+
8
+ def self.define_template arg
9
+ end
10
+
11
+ include HydraPbcore::Templates
12
+ end
13
+ @test = TestClass.new
14
+ end
15
+
16
+ describe "#digital_instantiation" do
17
+ it "should return a template for a digital instantiaion" do
18
+ save_template @test.digital_instantiation, "digital_instantiation_template.xml"
19
+ equivalent_xml_files("digital_instantiation_template.xml").should be_true
20
+ end
21
+ end
22
+
23
+ describe "#physical_instantiation" do
24
+ it "should create a template for physical instantiaions such as tapes" do
25
+ save_template @test.physical_instantiation, "physical_instantiation_template.xml"
26
+ equivalent_xml_files("physical_instantiation_template.xml").should be_true
27
+ end
28
+ end
29
+
30
+
31
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-pbcore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
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: 2012-11-20 00:00:00.000000000 Z
12
+ date: 2012-11-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -188,22 +188,49 @@ files:
188
188
  - lib/custom_mapper.rb
189
189
  - lib/hydra-pbcore.rb
190
190
  - lib/hydra-pbcore/behaviors.rb
191
- - lib/hydra-pbcore/datastream/digital_document.rb
191
+ - lib/hydra-pbcore/conversions.rb
192
+ - lib/hydra-pbcore/datastream/deprecated/digital_document.rb
193
+ - lib/hydra-pbcore/datastream/deprecated/document.rb
194
+ - lib/hydra-pbcore/datastream/deprecated/instantiation.rb
192
195
  - lib/hydra-pbcore/datastream/document.rb
193
196
  - lib/hydra-pbcore/datastream/instantiation.rb
194
197
  - lib/hydra-pbcore/methods.rb
195
198
  - lib/hydra-pbcore/templates.rb
196
199
  - lib/hydra-pbcore/version.rb
197
200
  - spec/custom_mapper_spec.rb
198
- - spec/digital_document_spec.rb
201
+ - spec/deprecated/digital_document_spec.rb
202
+ - spec/deprecated/document_spec.rb
203
+ - spec/deprecated/instantiation_spec.rb
199
204
  - spec/document_spec.rb
200
- - spec/fixtures/pbcore_digital_document_template.xml
201
- - spec/fixtures/pbcore_document_template.xml
202
- - spec/fixtures/pbcore_instantiation_template.xml
203
- - spec/fixtures/pbcore_solr_digital_document_template.xml
204
- - spec/fixtures/pbcore_solr_document_template.xml
205
- - spec/fixtures/pbcore_solr_instantiation_template.xml
205
+ - spec/fixtures/converted_digital_document_rrhof_1904.xml
206
+ - spec/fixtures/converted_digital_document_rrhof_2405.xml
207
+ - spec/fixtures/converted_document_rrhof_2439.xml
208
+ - spec/fixtures/converted_document_rrhof_524.xml
209
+ - spec/fixtures/converted_instantiation_rrhof_1184.xml
210
+ - spec/fixtures/converted_rrhof_524.xml
211
+ - spec/fixtures/converted_rrhof_524_instantiation.xml
212
+ - spec/fixtures/deprecated/pbcore_digital_document_template.xml
213
+ - spec/fixtures/deprecated/pbcore_document_template.xml
214
+ - spec/fixtures/deprecated/pbcore_instantiation_template.xml
215
+ - spec/fixtures/deprecated/pbcore_solr_digital_document_template.xml
216
+ - spec/fixtures/deprecated/pbcore_solr_document_template.xml
217
+ - spec/fixtures/deprecated/pbcore_solr_instantiation_template.xml
218
+ - spec/fixtures/digital_instantiation.xml
219
+ - spec/fixtures/digital_instantiation_solr.xml
220
+ - spec/fixtures/digital_instantiation_template.xml
221
+ - spec/fixtures/document.xml
222
+ - spec/fixtures/document_solr.xml
223
+ - spec/fixtures/document_template.xml
224
+ - spec/fixtures/integration/digital_document_rrhof_1904.xml
225
+ - spec/fixtures/integration/digital_document_rrhof_2405.xml
226
+ - spec/fixtures/integration/document_rrhof_2439.xml
227
+ - spec/fixtures/integration/document_rrhof_524.xml
228
+ - spec/fixtures/integration/instantiation_rrhof_1184.xml
229
+ - spec/fixtures/physical_instantiation.xml
230
+ - spec/fixtures/physical_instantiation_solr.xml
231
+ - spec/fixtures/physical_instantiation_template.xml
206
232
  - spec/instantiation_spec.rb
233
+ - spec/integration/conversions_spec.rb
207
234
  - spec/spec_helper.rb
208
235
  - spec/templates_spec.rb
209
236
  homepage: ''
@@ -232,15 +259,39 @@ specification_version: 3
232
259
  summary: A Hydra gem that offers PBCore datastream definitions using OM
233
260
  test_files:
234
261
  - spec/custom_mapper_spec.rb
235
- - spec/digital_document_spec.rb
262
+ - spec/deprecated/digital_document_spec.rb
263
+ - spec/deprecated/document_spec.rb
264
+ - spec/deprecated/instantiation_spec.rb
236
265
  - spec/document_spec.rb
237
- - spec/fixtures/pbcore_digital_document_template.xml
238
- - spec/fixtures/pbcore_document_template.xml
239
- - spec/fixtures/pbcore_instantiation_template.xml
240
- - spec/fixtures/pbcore_solr_digital_document_template.xml
241
- - spec/fixtures/pbcore_solr_document_template.xml
242
- - spec/fixtures/pbcore_solr_instantiation_template.xml
266
+ - spec/fixtures/converted_digital_document_rrhof_1904.xml
267
+ - spec/fixtures/converted_digital_document_rrhof_2405.xml
268
+ - spec/fixtures/converted_document_rrhof_2439.xml
269
+ - spec/fixtures/converted_document_rrhof_524.xml
270
+ - spec/fixtures/converted_instantiation_rrhof_1184.xml
271
+ - spec/fixtures/converted_rrhof_524.xml
272
+ - spec/fixtures/converted_rrhof_524_instantiation.xml
273
+ - spec/fixtures/deprecated/pbcore_digital_document_template.xml
274
+ - spec/fixtures/deprecated/pbcore_document_template.xml
275
+ - spec/fixtures/deprecated/pbcore_instantiation_template.xml
276
+ - spec/fixtures/deprecated/pbcore_solr_digital_document_template.xml
277
+ - spec/fixtures/deprecated/pbcore_solr_document_template.xml
278
+ - spec/fixtures/deprecated/pbcore_solr_instantiation_template.xml
279
+ - spec/fixtures/digital_instantiation.xml
280
+ - spec/fixtures/digital_instantiation_solr.xml
281
+ - spec/fixtures/digital_instantiation_template.xml
282
+ - spec/fixtures/document.xml
283
+ - spec/fixtures/document_solr.xml
284
+ - spec/fixtures/document_template.xml
285
+ - spec/fixtures/integration/digital_document_rrhof_1904.xml
286
+ - spec/fixtures/integration/digital_document_rrhof_2405.xml
287
+ - spec/fixtures/integration/document_rrhof_2439.xml
288
+ - spec/fixtures/integration/document_rrhof_524.xml
289
+ - spec/fixtures/integration/instantiation_rrhof_1184.xml
290
+ - spec/fixtures/physical_instantiation.xml
291
+ - spec/fixtures/physical_instantiation_solr.xml
292
+ - spec/fixtures/physical_instantiation_template.xml
243
293
  - spec/instantiation_spec.rb
294
+ - spec/integration/conversions_spec.rb
244
295
  - spec/spec_helper.rb
245
296
  - spec/templates_spec.rb
246
297
  has_rdoc: