iiif-presentation 1.4.2 → 1.5.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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +8 -1
  3. data/.standard.yml +1 -0
  4. data/Gemfile +5 -5
  5. data/README.md +1 -1
  6. data/Rakefile +4 -2
  7. data/VERSION +1 -1
  8. data/bin/standardrb +16 -0
  9. data/iiif-presentation.gemspec +23 -23
  10. data/lib/iiif/hash_behaviours.rb +29 -33
  11. data/lib/iiif/ordered_hash.rb +33 -33
  12. data/lib/iiif/presentation/abstract_resource.rb +17 -22
  13. data/lib/iiif/presentation/annotation.rb +9 -11
  14. data/lib/iiif/presentation/annotation_list.rb +8 -10
  15. data/lib/iiif/presentation/canvas.rb +11 -13
  16. data/lib/iiif/presentation/collection.rb +7 -9
  17. data/lib/iiif/presentation/image_resource.rb +33 -35
  18. data/lib/iiif/presentation/layer.rb +8 -10
  19. data/lib/iiif/presentation/manifest.rb +9 -12
  20. data/lib/iiif/presentation/range.rb +8 -10
  21. data/lib/iiif/presentation/resource.rb +5 -7
  22. data/lib/iiif/presentation/sequence.rb +8 -11
  23. data/lib/iiif/presentation/service.rb +1 -2
  24. data/lib/iiif/presentation.rb +7 -7
  25. data/lib/iiif/service.rb +121 -102
  26. data/lib/iiif/v3/abstract_resource.rb +127 -130
  27. data/lib/iiif/v3/presentation/annotation.rb +20 -21
  28. data/lib/iiif/v3/presentation/annotation_collection.rb +7 -9
  29. data/lib/iiif/v3/presentation/annotation_page.rb +14 -15
  30. data/lib/iiif/v3/presentation/canvas.rb +21 -22
  31. data/lib/iiif/v3/presentation/choice.rb +14 -15
  32. data/lib/iiif/v3/presentation/collection.rb +7 -8
  33. data/lib/iiif/v3/presentation/image_resource.rb +21 -22
  34. data/lib/iiif/v3/presentation/manifest.rb +18 -19
  35. data/lib/iiif/v3/presentation/nav_place.rb +125 -29
  36. data/lib/iiif/v3/presentation/range.rb +10 -10
  37. data/lib/iiif/v3/presentation/resource.rb +4 -5
  38. data/lib/iiif/v3/presentation/sequence.rb +10 -11
  39. data/lib/iiif/v3/presentation/service.rb +12 -13
  40. data/lib/iiif/v3/presentation.rb +8 -8
  41. data/spec/integration/iiif/presentation/image_resource_spec.rb +54 -58
  42. data/spec/integration/iiif/service_spec.rb +76 -77
  43. data/spec/integration/iiif/v3/abstract_resource_spec.rb +72 -73
  44. data/spec/integration/iiif/v3/presentation/image_resource_spec.rb +53 -56
  45. data/spec/spec_helper.rb +56 -64
  46. data/spec/unit/iiif/hash_behaviours_spec.rb +384 -387
  47. data/spec/unit/iiif/ordered_hash_spec.rb +86 -91
  48. data/spec/unit/iiif/presentation/abstract_resource_spec.rb +64 -70
  49. data/spec/unit/iiif/presentation/annotation_list_spec.rb +1 -3
  50. data/spec/unit/iiif/presentation/annotation_spec.rb +1 -3
  51. data/spec/unit/iiif/presentation/canvas_spec.rb +11 -14
  52. data/spec/unit/iiif/presentation/collection_spec.rb +26 -33
  53. data/spec/unit/iiif/presentation/image_resource_spec.rb +4 -6
  54. data/spec/unit/iiif/presentation/layer_spec.rb +16 -20
  55. data/spec/unit/iiif/presentation/manifest_spec.rb +45 -48
  56. data/spec/unit/iiif/presentation/range_spec.rb +18 -22
  57. data/spec/unit/iiif/presentation/resource_spec.rb +3 -6
  58. data/spec/unit/iiif/presentation/sequence_spec.rb +58 -63
  59. data/spec/unit/iiif/presentation/shared_examples/abstract_resource_only_keys.rb +4 -10
  60. data/spec/unit/iiif/presentation/shared_examples/any_type_keys.rb +5 -9
  61. data/spec/unit/iiif/presentation/shared_examples/array_only_keys.rb +9 -17
  62. data/spec/unit/iiif/presentation/shared_examples/int_only_keys.rb +6 -14
  63. data/spec/unit/iiif/presentation/shared_examples/string_only_keys.rb +6 -13
  64. data/spec/unit/iiif/service_spec.rb +8 -13
  65. data/spec/unit/iiif/v3/abstract_resource_define_methods_for_spec.rb +39 -37
  66. data/spec/unit/iiif/v3/abstract_resource_spec.rb +124 -131
  67. data/spec/unit/iiif/v3/presentation/annotation_collection_spec.rb +14 -17
  68. data/spec/unit/iiif/v3/presentation/annotation_page_spec.rb +71 -69
  69. data/spec/unit/iiif/v3/presentation/annotation_spec.rb +249 -233
  70. data/spec/unit/iiif/v3/presentation/canvas_spec.rb +211 -193
  71. data/spec/unit/iiif/v3/presentation/choice_spec.rb +81 -77
  72. data/spec/unit/iiif/v3/presentation/collection_spec.rb +24 -29
  73. data/spec/unit/iiif/v3/presentation/image_resource_spec.rb +70 -71
  74. data/spec/unit/iiif/v3/presentation/manifest_spec.rb +248 -235
  75. data/spec/unit/iiif/v3/presentation/nav_place_spec.rb +249 -49
  76. data/spec/unit/iiif/v3/presentation/range_spec.rb +28 -29
  77. data/spec/unit/iiif/v3/presentation/resource_spec.rb +83 -82
  78. data/spec/unit/iiif/v3/presentation/sequence_spec.rb +125 -119
  79. data/spec/unit/iiif/v3/presentation/service_spec.rb +123 -124
  80. data/spec/unit/iiif/v3/presentation/shared_examples/abstract_resource_only_keys.rb +4 -8
  81. data/spec/unit/iiif/v3/presentation/shared_examples/any_type_keys.rb +5 -7
  82. data/spec/unit/iiif/v3/presentation/shared_examples/array_only_keys.rb +9 -13
  83. data/spec/unit/iiif/v3/presentation/shared_examples/hash_only_keys.rb +9 -13
  84. data/spec/unit/iiif/v3/presentation/shared_examples/int_only_keys.rb +6 -10
  85. data/spec/unit/iiif/v3/presentation/shared_examples/numeric_only_keys.rb +6 -10
  86. data/spec/unit/iiif/v3/presentation/shared_examples/string_only_keys.rb +6 -10
  87. data/spec/unit/iiif/v3/presentation/shared_examples/uri_only_keys.rb +9 -13
  88. metadata +26 -65
@@ -1,331 +1,349 @@
1
1
  describe IIIF::V3::Presentation::Canvas do
2
+ describe "#required_keys" do
3
+ %w[type id label].each do |k|
4
+ it k do
5
+ expect(subject.required_keys).to include(k)
6
+ end
7
+ end
8
+ end
2
9
 
3
- describe '#required_keys' do
4
- %w{ type id label }.each do |k|
5
- it k do
6
- expect(subject.required_keys).to include(k)
7
- end
8
- end
9
- end
10
-
11
- describe '#prohibited_keys' do
12
- it 'contains the expected key names' do
13
- keys = described_class::PAGING_PROPERTIES +
14
- %w{
15
- viewing_direction
16
- format
17
- nav_date
18
- start_canvas
19
- content_annotations
20
- }
21
- expect(subject.prohibited_keys).to include(*keys)
22
- end
10
+ describe "#prohibited_keys" do
11
+ it "contains the expected key names" do
12
+ keys = described_class::PAGING_PROPERTIES +
13
+ %w[
14
+ viewing_direction
15
+ format
16
+ nav_date
17
+ start_canvas
18
+ content_annotations
19
+ ]
20
+ expect(subject.prohibited_keys).to include(*keys)
21
+ end
23
22
  end
24
23
 
25
- describe '#int_only_keys' do
26
- it 'depth (for 3d objects)' do
27
- expect(subject.int_only_keys).to include('depth')
24
+ describe "#int_only_keys" do
25
+ it "depth (for 3d objects)" do
26
+ expect(subject.int_only_keys).to include("depth")
28
27
  end
29
28
  end
30
29
 
31
- describe '#array_only_keys' do
32
- it 'content' do
33
- expect(subject.array_only_keys).to include('content')
30
+ describe "#array_only_keys" do
31
+ it "content" do
32
+ expect(subject.array_only_keys).to include("content")
34
33
  end
35
34
  end
36
35
 
37
- describe '#legal_viewing_hint_values' do
38
- it 'contains the expected values' do
39
- expect(subject.legal_viewing_hint_values).to contain_exactly('paged', 'continuous', 'non-paged', 'facing-pages', 'auto-advance')
36
+ describe "#legal_viewing_hint_values" do
37
+ it "contains the expected values" do
38
+ expect(subject.legal_viewing_hint_values).to contain_exactly("paged", "continuous", "non-paged", "facing-pages", "auto-advance")
40
39
  end
41
40
  end
42
41
 
43
- describe '#initialize' do
44
- it 'sets type to Canvas by default' do
45
- expect(subject['type']).to eq 'Canvas'
42
+ describe "#initialize" do
43
+ it "sets type to Canvas by default" do
44
+ expect(subject["type"]).to eq "Canvas"
46
45
  end
47
- it 'allows subclasses to override type' do
46
+ it "allows subclasses to override type" do
48
47
  subclass = Class.new(described_class) do
49
- def initialize(hsh={})
50
- hsh = { 'type' => 'a:SubClass' }
51
- super(hsh)
48
+ def initialize(_hsh = {})
49
+ super({"type" => "a:SubClass"})
52
50
  end
53
51
  end
54
52
  sub = subclass.new
55
- expect(sub['type']).to eq 'a:SubClass'
53
+ expect(sub["type"]).to eq "a:SubClass"
56
54
  end
57
55
  end
58
56
 
59
- describe '#validate' do
60
- let(:canvas_id) { 'http://example.org/iiif/book1/canvas/c1' }
57
+ describe "#validate" do
58
+ let(:canvas_id) { "http://example.org/iiif/book1/canvas/c1" }
61
59
  let(:exp_id_err_msg) { "id must be an http(s) URI without a fragment for #{described_class}" }
62
60
  before(:each) do
63
- subject['id'] = canvas_id
64
- subject['label'] = 'foo'
61
+ subject["id"] = canvas_id
62
+ subject["label"] = "foo"
65
63
  end
66
- it 'raises IllegalValueError if id is not URI' do
67
- subject['id'] = 'foo'
64
+ it "raises IllegalValueError if id is not URI" do
65
+ subject["id"] = "foo"
68
66
  expect { subject.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_id_err_msg)
69
67
  end
70
- it 'raises IllegalValueError if id is not http(s)' do
71
- subject['id'] = 'ftp://www.example.org'
68
+ it "raises IllegalValueError if id is not http(s)" do
69
+ subject["id"] = "ftp://www.example.org"
72
70
  expect { subject.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_id_err_msg)
73
71
  end
74
- it 'raises IllegalValueError if id has a fragment' do
75
- subject['id'] = 'http://www.example.org#foo'
72
+ it "raises IllegalValueError if id has a fragment" do
73
+ subject["id"] = "http://www.example.org#foo"
76
74
  expect { subject.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_id_err_msg)
77
75
  end
78
76
 
79
77
  # let(:exp_extent_err_msg) { "#{described_class} must have (a height and a width) and/or a duration" }
80
78
  # (see sul-dlss/purl/issues/169)
81
79
  let(:exp_extent_err_msg) { "#{described_class} requires both height and width or neither" }
82
- it 'raises IllegalValueError if height is a string' do
83
- subject['height'] = 'foo'
80
+ it "raises IllegalValueError if height is a string" do
81
+ subject["height"] = "foo"
84
82
  expect { subject.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_extent_err_msg)
85
83
  end
86
- it 'raises IllegalValueError if height but no width' do
87
- subject['height'] = 666
84
+ it "raises IllegalValueError if height but no width" do
85
+ subject["height"] = 666
88
86
  expect { subject.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_extent_err_msg)
89
87
  end
90
- it 'raises IllegalValueError if width but no height' do
91
- subject['width'] = 666
92
- subject['duration'] = 66.6
88
+ it "raises IllegalValueError if width but no height" do
89
+ subject["width"] = 666
90
+ subject["duration"] = 66.6
93
91
  expect { subject.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_extent_err_msg)
94
92
  end
95
- it 'raises IllegalValueError if no width, height or duration' do
93
+ it "raises IllegalValueError if no width, height or duration" do
96
94
  # (see sul-dlss/purl/issues/169)
97
- skip('while this is in the current v3 spec, it does not make sense for some content (e.g. txt files)')
95
+ skip("while this is in the current v3 spec, it does not make sense for some content (e.g. txt files)")
98
96
  expect { subject.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_extent_err_msg)
99
97
  end
100
- it 'allows width, height and duration' do
101
- subject['width'] = 666
102
- subject['height'] = 666
103
- subject['duration'] = 66.6
98
+ it "allows width, height and duration" do
99
+ subject["width"] = 666
100
+ subject["height"] = 666
101
+ subject["duration"] = 66.6
104
102
  expect { subject.validate }.not_to raise_error
105
103
  end
106
104
 
107
- it 'raises IllegalValueError for content entry that is not an AnnotationPage' do
108
- subject['content'] = [IIIF::V3::Presentation::AnnotationPage.new, IIIF::V3::Presentation::Annotation.new]
105
+ it "raises IllegalValueError for content entry that is not an AnnotationPage" do
106
+ subject["content"] = [IIIF::V3::Presentation::AnnotationPage.new, IIIF::V3::Presentation::Annotation.new]
109
107
  exp_err_msg = "All entries in the content list must be a IIIF::V3::Presentation::AnnotationPage"
110
108
  expect { subject.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_err_msg)
111
109
  end
112
110
 
113
- it 'IllegalValueError for content with annotation target not the canvas id' do
111
+ it "IllegalValueError for content with annotation target not the canvas id" do
114
112
  anno = IIIF::V3::Presentation::Annotation.new(
115
- 'id' => 'http://example.com/anno/666',
116
- 'target' => canvas_id)
113
+ "id" => "http://example.com/anno/666",
114
+ "target" => canvas_id
115
+ )
117
116
  anno_page = IIIF::V3::Presentation::AnnotationPage.new(
118
- 'id' => "http://example.org/iiif/book1/page/p1/1",
119
- 'items' => [anno])
120
- subject['content'] = [anno_page]
117
+ "id" => "http://example.org/iiif/book1/page/p1/1",
118
+ "items" => [anno]
119
+ )
120
+ subject["content"] = [anno_page]
121
121
 
122
122
  expect { subject.validate }.not_to raise_error
123
123
 
124
- anno['target'] = 'http://example.com/canvas/abc'
125
- exp_err_msg = 'URI of the canvas must be repeated in the target field of included Annotations'
124
+ anno["target"] = "http://example.com/canvas/abc"
125
+ exp_err_msg = "URI of the canvas must be repeated in the target field of included Annotations"
126
126
  expect { subject.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_err_msg)
127
127
  end
128
128
  end
129
129
 
130
- describe 'realistic examples' do
131
- let(:canvas_id) { 'http://example.org/iiif/book1/canvas/c1' }
132
- let(:minimal_canvas_object) { described_class.new({
133
- "id" => canvas_id,
134
- 'label' => {"en" => ["so minimal it's not here"]},
135
- 'height' => 1000,
136
- 'width' => 1000
137
- })}
138
- let(:anno_page) { IIIF::V3::Presentation::AnnotationPage.new(
139
- "id" => "http://example.org/iiif/book1/page/p1/1",
140
- 'items' => []
141
- )}
142
- describe 'minimal canvas' do
143
- it 'validates' do
144
- expect{minimal_canvas_object.validate}.not_to raise_error
130
+ describe "realistic examples" do
131
+ let(:canvas_id) { "http://example.org/iiif/book1/canvas/c1" }
132
+ let(:minimal_canvas_object) {
133
+ described_class.new({
134
+ "id" => canvas_id,
135
+ "label" => {"en" => ["so minimal it's not here"]},
136
+ "height" => 1000,
137
+ "width" => 1000
138
+ })
139
+ }
140
+ let(:anno_page) {
141
+ IIIF::V3::Presentation::AnnotationPage.new(
142
+ "id" => "http://example.org/iiif/book1/page/p1/1",
143
+ "items" => []
144
+ )
145
+ }
146
+ describe "minimal canvas" do
147
+ it "validates" do
148
+ expect { minimal_canvas_object.validate }.not_to raise_error
145
149
  end
146
- it 'has expected required values' do
150
+ it "has expected required values" do
147
151
  expect(minimal_canvas_object.type).to eq described_class::TYPE
148
152
  expect(minimal_canvas_object.id).to eq canvas_id
149
- expect(minimal_canvas_object.label['en']).to include "so minimal it's not here"
153
+ expect(minimal_canvas_object.label["en"]).to include "so minimal it's not here"
150
154
  expect(minimal_canvas_object.height).to eq 1000
151
155
  expect(minimal_canvas_object.width).to eq 1000
152
156
  end
153
157
  end
154
- describe 'minimal with empty content' do
158
+ describe "minimal with empty content" do
155
159
  let(:canvas_object) {
156
- minimal_canvas_object['content'] = []
160
+ minimal_canvas_object["content"] = []
157
161
  minimal_canvas_object
158
162
  }
159
- it 'validates' do
160
- expect{canvas_object.validate}.not_to raise_error
163
+ it "validates" do
164
+ expect { canvas_object.validate }.not_to raise_error
161
165
  end
162
- it 'has empty array for content' do
166
+ it "has empty array for content" do
163
167
  expect(canvas_object.content).to eq []
164
168
  end
165
169
  end
166
- describe 'minimal with content' do
170
+ describe "minimal with content" do
167
171
  let(:canvas_object) {
168
- minimal_canvas_object['content'] = [anno_page, anno_page]
172
+ minimal_canvas_object["content"] = [anno_page, anno_page]
169
173
  minimal_canvas_object
170
174
  }
171
- it 'validates' do
172
- expect{canvas_object.validate}.not_to raise_error
175
+ it "validates" do
176
+ expect { canvas_object.validate }.not_to raise_error
173
177
  end
174
- it 'has content value' do
178
+ it "has content value" do
175
179
  expect(canvas_object.content.size).to eq 2
176
180
  expect(canvas_object.content).to eq [anno_page, anno_page]
177
181
  end
178
182
 
179
- describe 'stanford (purl code)' do
183
+ describe "stanford (purl code)" do
180
184
  let(:canvas_object) {
181
185
  c = described_class.new
182
- c['id'] = canvas_id
183
- c.label = {'en' => ['label']}
186
+ c["id"] = canvas_id
187
+ c.label = {"en" => ["label"]}
184
188
  c.content << anno_page
185
189
  c
186
190
  }
187
- describe 'non-image' do
188
- it 'validates' do
189
- expect{canvas_object.validate}.not_to raise_error
191
+ describe "non-image" do
192
+ it "validates" do
193
+ expect { canvas_object.validate }.not_to raise_error
190
194
  end
191
- it 'has expected required values' do
195
+ it "has expected required values" do
192
196
  expect(canvas_object.type).to eq described_class::TYPE
193
197
  expect(canvas_object.id).to eq canvas_id
194
- expect(canvas_object.label['en']).to include "label"
198
+ expect(canvas_object.label["en"]).to include "label"
195
199
  end
196
- it 'has expected additional values' do
200
+ it "has expected additional values" do
197
201
  expect(canvas_object.content).to eq [anno_page]
198
202
  end
199
203
  end
200
- describe 'image' do
204
+ describe "image" do
201
205
  let(:img_canvas) {
202
206
  canvas_object.height = 666
203
207
  canvas_object.width = 888
204
208
  canvas_object
205
209
  }
206
- it 'validates' do
207
- expect{img_canvas.validate}.not_to raise_error
210
+ it "validates" do
211
+ expect { img_canvas.validate }.not_to raise_error
208
212
  end
209
- it 'has expected required values' do
213
+ it "has expected required values" do
210
214
  expect(img_canvas.type).to eq described_class::TYPE
211
215
  expect(img_canvas.id).to eq canvas_id
212
- expect(img_canvas.label['en']).to include "label"
216
+ expect(img_canvas.label["en"]).to include "label"
213
217
  expect(img_canvas.height).to eq 666
214
218
  expect(img_canvas.width).to eq 888
215
219
  end
216
- it 'has expected additional values' do
220
+ it "has expected additional values" do
217
221
  expect(img_canvas.content).to eq [anno_page]
218
222
  end
219
223
  end
220
224
  end
221
225
 
222
- describe 'file object' do
223
- describe 'without extent info' do
224
- let(:file_object) { described_class.new({
225
- "id" => "https://example.org/bd742gh0511/iiif3/canvas/bd742gh0511_1",
226
- "label" => {"en" => ["File 1"]},
227
- "content" => [anno_page]
228
- })}
229
- it 'validates' do
230
- expect{file_object.validate}.not_to raise_error
226
+ describe "file object" do
227
+ describe "without extent info" do
228
+ let(:file_object) {
229
+ described_class.new({
230
+ "id" => "https://example.org/bd742gh0511/iiif3/canvas/bd742gh0511_1",
231
+ "label" => {"en" => ["File 1"]},
232
+ "content" => [anno_page]
233
+ })
234
+ }
235
+ it "validates" do
236
+ expect { file_object.validate }.not_to raise_error
231
237
  end
232
238
  end
233
239
  end
234
240
 
235
- describe 'image object' do
236
- describe 'without extent info' do
237
- let(:image_object) { described_class.new({
238
- "id" => "https://example.org/yv090xk3108/iiif3/canvas/yv090xk3108_1",
239
- "label" => {"en" => ["image"]},
240
- "content" => [anno_page]
241
- })}
242
- it 'validates' do
243
- expect{image_object.validate}.not_to raise_error
241
+ describe "image object" do
242
+ describe "without extent info" do
243
+ let(:image_object) {
244
+ described_class.new({
245
+ "id" => "https://example.org/yv090xk3108/iiif3/canvas/yv090xk3108_1",
246
+ "label" => {"en" => ["image"]},
247
+ "content" => [anno_page]
248
+ })
249
+ }
250
+ it "validates" do
251
+ expect { image_object.validate }.not_to raise_error
244
252
  end
245
253
  end
246
- describe 'with extent given' do
247
- let(:image_object) { described_class.new({
248
- "id" => "https://example.org/yy816tv6021/iiif3/canvas/yy816tv6021_3",
249
- "label" => {"en" => ["Image of media (1 of 2)"]},
250
- "height" => 3456,
251
- "width" => 5184,
252
- "content" => [anno_page]
253
- })}
254
- it 'validates' do
255
- expect{image_object.validate}.not_to raise_error
254
+ describe "with extent given" do
255
+ let(:image_object) {
256
+ described_class.new({
257
+ "id" => "https://example.org/yy816tv6021/iiif3/canvas/yy816tv6021_3",
258
+ "label" => {"en" => ["Image of media (1 of 2)"]},
259
+ "height" => 3456,
260
+ "width" => 5184,
261
+ "content" => [anno_page]
262
+ })
263
+ }
264
+ it "validates" do
265
+ expect { image_object.validate }.not_to raise_error
256
266
  end
257
267
  end
258
268
  end
259
269
 
260
- describe 'audio object' do
261
- describe 'without duration' do
262
- let(:canvas_for_audio) { described_class.new({
263
- "id" => "https://example.org/xk681bt2506/iiif3/canvas/xk681bt2506_1",
264
- "label" => {"en" => ["Audio file 1"]},
265
- "content" => [anno_page]
266
- })}
267
- it 'validates' do
268
- expect{canvas_for_audio.validate}.not_to raise_error
270
+ describe "audio object" do
271
+ describe "without duration" do
272
+ let(:canvas_for_audio) {
273
+ described_class.new({
274
+ "id" => "https://example.org/xk681bt2506/iiif3/canvas/xk681bt2506_1",
275
+ "label" => {"en" => ["Audio file 1"]},
276
+ "content" => [anno_page]
277
+ })
278
+ }
279
+ it "validates" do
280
+ expect { canvas_for_audio.validate }.not_to raise_error
269
281
  end
270
282
  end
271
- describe 'digerati example' do
272
- let(:canvas_for_audio) { described_class.new({
273
- "id" => "http://tomcrane.github.io/scratch/manifests/3/canvas/2",
274
- "label" => "Track 2",
275
- 'summary' => {
276
- 'en' => ['foo']
277
- },
278
- "duration" => 45,
279
- "content" => [anno_page]
280
- })}
281
- it 'validates' do
282
- expect{canvas_for_audio.validate}.not_to raise_error
283
+ describe "digerati example" do
284
+ let(:canvas_for_audio) {
285
+ described_class.new({
286
+ "id" => "http://tomcrane.github.io/scratch/manifests/3/canvas/2",
287
+ "label" => "Track 2",
288
+ "summary" => {
289
+ "en" => ["foo"]
290
+ },
291
+ "duration" => 45,
292
+ "content" => [anno_page]
293
+ })
294
+ }
295
+ it "validates" do
296
+ expect { canvas_for_audio.validate }.not_to raise_error
283
297
  end
284
- it 'duration' do
298
+ it "duration" do
285
299
  expect(canvas_for_audio.duration).to eq 45
286
300
  end
287
- it 'summary' do
288
- expect(canvas_for_audio.summary['en'].first).to eq 'foo'
301
+ it "summary" do
302
+ expect(canvas_for_audio.summary["en"].first).to eq "foo"
289
303
  end
290
304
  end
291
305
  end
292
306
 
293
- describe '3d object' do
294
- let(:canvas_3d_object) { described_class.new({
295
- "id" => "http://tomcrane.github.io/scratch/manifests/3/canvas/3d",
296
- "thumbnail" => [{'id' => "http://files.universalviewer.io/manifests/nelis/animal-skull/thumb.jpg",
297
- 'type' => 'Image'}],
298
- "width" => 10000,
299
- "height" => 10000,
300
- "depth" => 10000,
301
- "label" => "A stage for an object",
302
- "content" => [anno_page]
303
- })}
304
- it 'validates' do
305
- expect{canvas_3d_object.validate}.not_to raise_error
307
+ describe "3d object" do
308
+ let(:canvas_3d_object) {
309
+ described_class.new({
310
+ "id" => "http://tomcrane.github.io/scratch/manifests/3/canvas/3d",
311
+ "thumbnail" => [{"id" => "http://files.universalviewer.io/manifests/nelis/animal-skull/thumb.jpg",
312
+ "type" => "Image"}],
313
+ "width" => 10000,
314
+ "height" => 10000,
315
+ "depth" => 10000,
316
+ "label" => "A stage for an object",
317
+ "content" => [anno_page]
318
+ })
319
+ }
320
+ it "validates" do
321
+ expect { canvas_3d_object.validate }.not_to raise_error
306
322
  end
307
- it 'thumbnail' do
308
- expect(canvas_3d_object.thumbnail).to eq [{'id' => "http://files.universalviewer.io/manifests/nelis/animal-skull/thumb.jpg", 'type' => 'Image'}]
323
+ it "thumbnail" do
324
+ expect(canvas_3d_object.thumbnail).to eq [{"id" => "http://files.universalviewer.io/manifests/nelis/animal-skull/thumb.jpg", "type" => "Image"}]
309
325
  end
310
- it 'depth' do
326
+ it "depth" do
311
327
  expect(canvas_3d_object.depth).to eq 10000
312
328
  end
313
329
  end
314
330
 
315
- describe 'video object' do
316
- describe 'with extent info' do
317
- let(:canvas_for_video) { described_class.new({
318
- "id" => "http://tomcrane.github.io/scratch/manifests/3/canvas/1",
319
- "label" => "Associate multiple Video representations as Choice",
320
- "height" => 1000,
321
- "width" => 1000,
322
- "duration" => 100,
323
- "content" => [anno_page]
324
- }) }
325
- it 'validates' do
326
- expect{canvas_for_video.validate}.not_to raise_error
331
+ describe "video object" do
332
+ describe "with extent info" do
333
+ let(:canvas_for_video) {
334
+ described_class.new({
335
+ "id" => "http://tomcrane.github.io/scratch/manifests/3/canvas/1",
336
+ "label" => "Associate multiple Video representations as Choice",
337
+ "height" => 1000,
338
+ "width" => 1000,
339
+ "duration" => 100,
340
+ "content" => [anno_page]
341
+ })
342
+ }
343
+ it "validates" do
344
+ expect { canvas_for_video.validate }.not_to raise_error
327
345
  end
328
- it 'height, width, duration' do
346
+ it "height, width, duration" do
329
347
  expect(canvas_for_video.height).to eq 1000
330
348
  expect(canvas_for_video.width).to eq 1000
331
349
  expect(canvas_for_video.duration).to eq 100