ddr-models 2.8.0 → 2.9.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/collection.rb +55 -0
- data/app/models/component.rb +23 -13
- data/app/models/item.rb +28 -0
- data/config/initializers/active_fedora_base.rb +8 -0
- data/lib/ddr/datastreams.rb +2 -0
- data/lib/ddr/datastreams/administrative_metadata_datastream.rb +3 -0
- data/lib/ddr/datastreams/caption_datastream.rb +5 -0
- data/lib/ddr/index/fields.rb +2 -0
- data/lib/ddr/models.rb +27 -5
- data/lib/ddr/models/base.rb +15 -2
- data/lib/ddr/models/captionable.rb +37 -0
- data/lib/ddr/models/has_children.rb +0 -28
- data/lib/ddr/models/has_intermediate_file.rb +23 -0
- data/lib/ddr/models/indexing.rb +2 -0
- data/lib/ddr/models/solr_document.rb +99 -0
- data/lib/ddr/models/streamable.rb +15 -0
- data/lib/ddr/models/version.rb +1 -1
- data/lib/ddr/vocab/asset.rb +4 -0
- data/spec/fixtures/abcd1234.vtt +38 -0
- data/spec/models/active_fedora_base_spec.rb +3 -0
- data/spec/models/collection_spec.rb +152 -0
- data/spec/models/component_spec.rb +32 -2
- data/spec/models/has_children_spec.rb +0 -51
- data/spec/models/indexing_spec.rb +8 -0
- data/spec/models/item_spec.rb +64 -0
- data/spec/models/solr_document_spec.rb +131 -0
- data/spec/support/shared_examples_for_captionable.rb +23 -0
- data/spec/support/shared_examples_for_streamable_media.rb +1 -0
- metadata +10 -4
@@ -155,5 +155,13 @@ module Ddr::Models
|
|
155
155
|
}
|
156
156
|
end
|
157
157
|
|
158
|
+
describe "nested path" do
|
159
|
+
subject { FactoryGirl.build(:item) }
|
160
|
+
before { subject.nested_path = "/foo/bar/baz" }
|
161
|
+
specify {
|
162
|
+
expect(subject.index_fields[Indexing::NESTED_PATH]).to eq "/foo/bar/baz"
|
163
|
+
expect(subject.index_fields[Indexing::NESTED_PATH_TEXT]).to eq "/foo/bar/baz"
|
164
|
+
}
|
165
|
+
end
|
158
166
|
end
|
159
167
|
end
|
data/spec/models/item_spec.rb
CHANGED
@@ -46,4 +46,68 @@ RSpec.describe Item, type: :model do
|
|
46
46
|
}
|
47
47
|
end
|
48
48
|
|
49
|
+
describe "#default_structure" do
|
50
|
+
describe "when the item has no components" do
|
51
|
+
let(:expected) do
|
52
|
+
xml = <<-EOS
|
53
|
+
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
|
54
|
+
<metsHdr>
|
55
|
+
<agent ROLE="#{Ddr::Models::Structures::Agent::ROLE_CREATOR}">
|
56
|
+
<name>#{Ddr::Models::Structures::Agent::NAME_REPOSITORY_DEFAULT}</name>
|
57
|
+
</agent>
|
58
|
+
</metsHdr>
|
59
|
+
<structMap TYPE="#{Ddr::Models::Structure::TYPE_DEFAULT}" />
|
60
|
+
</mets>
|
61
|
+
EOS
|
62
|
+
xml
|
63
|
+
end
|
64
|
+
it "should be the appropriate structure" do
|
65
|
+
expect(subject.default_structure.to_xml).to be_equivalent_to(expected)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
describe "when the item has components" do
|
69
|
+
let(:comp1) { FactoryGirl.create(:component) }
|
70
|
+
let(:comp2) { FactoryGirl.create(:component) }
|
71
|
+
let(:expected) do
|
72
|
+
xml = <<-EOS
|
73
|
+
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
|
74
|
+
<metsHdr>
|
75
|
+
<agent ROLE="#{Ddr::Models::Structures::Agent::ROLE_CREATOR}">
|
76
|
+
<name>#{Ddr::Models::Structures::Agent::NAME_REPOSITORY_DEFAULT}</name>
|
77
|
+
</agent>
|
78
|
+
</metsHdr>
|
79
|
+
<structMap TYPE="#{Ddr::Models::Structure::TYPE_DEFAULT}">
|
80
|
+
<div ORDER="1">
|
81
|
+
<mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4bbb" />
|
82
|
+
</div>
|
83
|
+
<div ORDER="2">
|
84
|
+
<mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4aaa" />
|
85
|
+
</div>
|
86
|
+
</structMap>
|
87
|
+
</mets>
|
88
|
+
EOS
|
89
|
+
xml
|
90
|
+
end
|
91
|
+
before do
|
92
|
+
comp1.local_id = "test002"
|
93
|
+
comp1.permanent_id = "ark:/99999/fk4aaa"
|
94
|
+
comp1.save!
|
95
|
+
comp2.local_id = "test001"
|
96
|
+
comp2.permanent_id = "ark:/99999/fk4bbb"
|
97
|
+
comp2.save!
|
98
|
+
subject.children << comp1
|
99
|
+
subject.children << comp2
|
100
|
+
subject.save!
|
101
|
+
allow(SecureRandom).to receive(:uuid).and_return("abc-def", "ghi-jkl")
|
102
|
+
end
|
103
|
+
after do
|
104
|
+
comp1.destroy
|
105
|
+
comp2.destroy
|
106
|
+
end
|
107
|
+
it "should be the appropriate structure" do
|
108
|
+
expect(subject.default_structure.to_xml).to be_equivalent_to(expected)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
49
113
|
end
|
@@ -207,6 +207,117 @@ EOS
|
|
207
207
|
}
|
208
208
|
end
|
209
209
|
|
210
|
+
describe "#intermediate_type" do
|
211
|
+
specify {
|
212
|
+
allow(subject).to receive(:has_intermediate_file?) { false }
|
213
|
+
expect(subject.intermediate_path).to be_nil
|
214
|
+
}
|
215
|
+
specify {
|
216
|
+
allow(subject).to receive(:datastreams) do
|
217
|
+
{"intermediateFile"=>{"dsMIME"=>"audio/wav"}}
|
218
|
+
end
|
219
|
+
expect(subject.intermediate_type).to eq "audio/wav"
|
220
|
+
}
|
221
|
+
end
|
222
|
+
|
223
|
+
describe "#intermediate_path" do
|
224
|
+
specify {
|
225
|
+
allow(subject).to receive(:has_intermediate_file?) { false }
|
226
|
+
expect(subject.intermediate_path).to be_nil
|
227
|
+
}
|
228
|
+
specify {
|
229
|
+
allow(subject).to receive(:datastreams) do
|
230
|
+
{"intermediateFile"=>{"dsLocation"=>"file:/foo/bar/baz.txt"}}
|
231
|
+
end
|
232
|
+
expect(subject.intermediate_path).to eq "/foo/bar/baz.txt"
|
233
|
+
}
|
234
|
+
end
|
235
|
+
|
236
|
+
describe "#intermediate_extension" do
|
237
|
+
let(:extensions) { {'audio/wav' => 'wav', 'video/quicktime' => 'mov'} }
|
238
|
+
before { allow(Ddr::Models).to receive(:preferred_file_extensions) { extensions } }
|
239
|
+
before { allow(subject).to receive(:has_intermediate_file?) { true } }
|
240
|
+
specify {
|
241
|
+
allow(subject).to receive(:has_intermediate_file?) { false }
|
242
|
+
expect(subject.intermediate_extension).to be_nil
|
243
|
+
}
|
244
|
+
specify {
|
245
|
+
allow(subject).to receive(:intermediate_type) { 'audio/wav'}
|
246
|
+
expect(subject.intermediate_extension).to eq "wav"
|
247
|
+
}
|
248
|
+
specify {
|
249
|
+
allow(subject).to receive(:intermediate_type) { 'video/quicktime'}
|
250
|
+
expect(subject.intermediate_extension).to eq "mov"
|
251
|
+
}
|
252
|
+
specify {
|
253
|
+
allow(subject).to receive(:intermediate_type) { 'application/foo'}
|
254
|
+
allow(subject).to receive(:intermediate_extension_default) { "bin" }
|
255
|
+
expect(subject.intermediate_extension).to eq "bin"
|
256
|
+
}
|
257
|
+
end
|
258
|
+
|
259
|
+
|
260
|
+
describe "#captionable?" do
|
261
|
+
specify {
|
262
|
+
allow(subject).to receive(:has_datastream?).with(Ddr::Datastreams::CAPTION) { false }
|
263
|
+
expect(subject).not_to be_captionable
|
264
|
+
}
|
265
|
+
specify {
|
266
|
+
allow(subject).to receive(:has_datastream?).with(Ddr::Datastreams::CAPTION) { true }
|
267
|
+
expect(subject).to be_captionable
|
268
|
+
}
|
269
|
+
end
|
270
|
+
|
271
|
+
describe "#caption_type" do
|
272
|
+
specify {
|
273
|
+
allow(subject).to receive(:captionable?) { false }
|
274
|
+
expect(subject.caption_type).to be_nil
|
275
|
+
}
|
276
|
+
specify {
|
277
|
+
allow(subject).to receive(:datastreams) do
|
278
|
+
{"caption"=>{"dsMIME"=>"text/vtt"}}
|
279
|
+
end
|
280
|
+
expect(subject.caption_type).to eq "text/vtt"
|
281
|
+
}
|
282
|
+
end
|
283
|
+
|
284
|
+
describe "#caption_path" do
|
285
|
+
specify {
|
286
|
+
allow(subject).to receive(:captionable?) { false }
|
287
|
+
expect(subject.caption_path).to be_nil
|
288
|
+
}
|
289
|
+
specify {
|
290
|
+
allow(subject).to receive(:datastreams) do
|
291
|
+
{"caption"=>{"dsLocation"=>"file:/foo/bar/baz.txt"}}
|
292
|
+
end
|
293
|
+
expect(subject.caption_path).to eq "/foo/bar/baz.txt"
|
294
|
+
}
|
295
|
+
end
|
296
|
+
|
297
|
+
describe "#caption_extension" do
|
298
|
+
let(:extensions) { {'text/vtt' => 'vtt', 'application/zip' => 'zip'} }
|
299
|
+
before { allow(Ddr::Models).to receive(:preferred_file_extensions) { extensions } }
|
300
|
+
before { allow(subject).to receive(:captionable?) { true } }
|
301
|
+
specify {
|
302
|
+
allow(subject).to receive(:captionable?) { false }
|
303
|
+
expect(subject.caption_extension).to be_nil
|
304
|
+
}
|
305
|
+
specify {
|
306
|
+
allow(subject).to receive(:caption_type) { 'text/vtt'}
|
307
|
+
expect(subject.caption_extension).to eq "vtt"
|
308
|
+
}
|
309
|
+
specify {
|
310
|
+
allow(subject).to receive(:caption_type) { 'application/zip'}
|
311
|
+
expect(subject.caption_extension).to eq "zip"
|
312
|
+
}
|
313
|
+
specify {
|
314
|
+
allow(subject).to receive(:caption_type) { 'application/foo'}
|
315
|
+
allow(subject).to receive(:caption_extension_default) { "bin" }
|
316
|
+
expect(subject.caption_extension).to eq "bin"
|
317
|
+
}
|
318
|
+
end
|
319
|
+
|
320
|
+
|
210
321
|
describe "#streamable?" do
|
211
322
|
specify {
|
212
323
|
allow(subject).to receive(:has_datastream?).with(Ddr::Datastreams::STREAMABLE_MEDIA) { false }
|
@@ -231,6 +342,26 @@ EOS
|
|
231
342
|
}
|
232
343
|
end
|
233
344
|
|
345
|
+
describe "#streamable_media_extension" do
|
346
|
+
let(:extensions) { {'audio/mpeg' => 'mp3', 'video/mp4' => 'mp4'} }
|
347
|
+
before { allow(Ddr::Models).to receive(:preferred_file_extensions) { extensions } }
|
348
|
+
before { allow(subject).to receive(:streamable?) { true } }
|
349
|
+
specify {
|
350
|
+
allow(subject).to receive(:streamable?) { false }
|
351
|
+
expect(subject.streamable_media_extension).to be_nil
|
352
|
+
}
|
353
|
+
specify {
|
354
|
+
allow(subject).to receive(:streamable_media_type) { 'audio/mpeg'}
|
355
|
+
expect(subject.streamable_media_extension).to eq "mp3"
|
356
|
+
}
|
357
|
+
specify {
|
358
|
+
allow(subject).to receive(:streamable_media_type) { 'application/foo'}
|
359
|
+
allow(subject).to receive(:streamable_media_extension_default) { "bin" }
|
360
|
+
expect(subject.streamable_media_extension).to eq "bin"
|
361
|
+
}
|
362
|
+
end
|
363
|
+
|
364
|
+
|
234
365
|
describe "#rights" do
|
235
366
|
specify {
|
236
367
|
obj = Item.create(rights: ["http://example.com"])
|
@@ -0,0 +1,23 @@
|
|
1
|
+
RSpec.shared_examples "an object that cannot be captioned" do
|
2
|
+
it { is_expected.to_not be_captioned }
|
3
|
+
its(:captionable?) { is_expected.to be false }
|
4
|
+
end
|
5
|
+
|
6
|
+
RSpec.shared_examples "an object that can be captioned" do
|
7
|
+
it { is_expected.to_not be_captioned }
|
8
|
+
its(:captionable?) { is_expected.to be true }
|
9
|
+
|
10
|
+
describe "when caption file is present" do
|
11
|
+
before {
|
12
|
+
subject.add_file(fixture_file_upload('abcd1234.vtt', 'text/vtt'), 'caption')
|
13
|
+
subject.save!
|
14
|
+
}
|
15
|
+
specify {
|
16
|
+
expect(subject).to be_captioned
|
17
|
+
expect(subject.caption_path).to be_present
|
18
|
+
expect(subject.caption_path).to eq subject.caption.file_path
|
19
|
+
expect(subject.caption_type).to eq 'text/vtt'
|
20
|
+
expect(subject.caption_extension).to eq 'vtt'
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
@@ -17,6 +17,7 @@ RSpec.shared_examples "an object that can be streamable" do
|
|
17
17
|
expect(subject.streamable_media_type).to eq 'image/jpeg'
|
18
18
|
expect(subject.streamable_media_path).to be_present
|
19
19
|
expect(subject.streamable_media_path).to eq subject.streamableMedia.file_path
|
20
|
+
expect(subject.streamable_media_extension).to eq 'jpeg'
|
20
21
|
}
|
21
22
|
end
|
22
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ddr-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Coble
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -494,6 +494,7 @@ files:
|
|
494
494
|
- lib/ddr/auth/web_auth_context.rb
|
495
495
|
- lib/ddr/datastreams.rb
|
496
496
|
- lib/ddr/datastreams/administrative_metadata_datastream.rb
|
497
|
+
- lib/ddr/datastreams/caption_datastream.rb
|
497
498
|
- lib/ddr/datastreams/content_datastream.rb
|
498
499
|
- lib/ddr/datastreams/datastream_behavior.rb
|
499
500
|
- lib/ddr/datastreams/delete_external_files.rb
|
@@ -551,6 +552,7 @@ files:
|
|
551
552
|
- lib/ddr/models/admin_set.rb
|
552
553
|
- lib/ddr/models/base.rb
|
553
554
|
- lib/ddr/models/cache.rb
|
555
|
+
- lib/ddr/models/captionable.rb
|
554
556
|
- lib/ddr/models/contact.rb
|
555
557
|
- lib/ddr/models/describable.rb
|
556
558
|
- lib/ddr/models/engine.rb
|
@@ -683,6 +685,7 @@ files:
|
|
683
685
|
- spec/factories/user_factories.rb
|
684
686
|
- spec/fixtures/16bit.tif
|
685
687
|
- spec/fixtures/8bit.tif
|
688
|
+
- spec/fixtures/abcd1234.vtt
|
686
689
|
- spec/fixtures/arrow1rightred_e0.gif
|
687
690
|
- spec/fixtures/bird.jpg
|
688
691
|
- spec/fixtures/extractedText1.txt
|
@@ -748,6 +751,7 @@ files:
|
|
748
751
|
- spec/support/ezid_mock_identifier.rb
|
749
752
|
- spec/support/shared_examples_for_associations.rb
|
750
753
|
- spec/support/shared_examples_for_auth_contexts.rb
|
754
|
+
- spec/support/shared_examples_for_captionable.rb
|
751
755
|
- spec/support/shared_examples_for_ddr_models.rb
|
752
756
|
- spec/support/shared_examples_for_describables.rb
|
753
757
|
- spec/support/shared_examples_for_events.rb
|
@@ -777,9 +781,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
777
781
|
version: '0'
|
778
782
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
779
783
|
requirements:
|
780
|
-
- - "
|
784
|
+
- - ">"
|
781
785
|
- !ruby/object:Gem::Version
|
782
|
-
version:
|
786
|
+
version: 1.3.1
|
783
787
|
requirements: []
|
784
788
|
rubyforge_project:
|
785
789
|
rubygems_version: 2.6.11
|
@@ -869,6 +873,7 @@ test_files:
|
|
869
873
|
- spec/factories/user_factories.rb
|
870
874
|
- spec/fixtures/16bit.tif
|
871
875
|
- spec/fixtures/8bit.tif
|
876
|
+
- spec/fixtures/abcd1234.vtt
|
872
877
|
- spec/fixtures/arrow1rightred_e0.gif
|
873
878
|
- spec/fixtures/bird.jpg
|
874
879
|
- spec/fixtures/extractedText1.txt
|
@@ -934,6 +939,7 @@ test_files:
|
|
934
939
|
- spec/support/ezid_mock_identifier.rb
|
935
940
|
- spec/support/shared_examples_for_associations.rb
|
936
941
|
- spec/support/shared_examples_for_auth_contexts.rb
|
942
|
+
- spec/support/shared_examples_for_captionable.rb
|
937
943
|
- spec/support/shared_examples_for_ddr_models.rb
|
938
944
|
- spec/support/shared_examples_for_describables.rb
|
939
945
|
- spec/support/shared_examples_for_events.rb
|