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,392 +1,408 @@
1
1
  describe IIIF::V3::Presentation::Annotation do
2
+ let(:content_id) { "http://example.org/iiif/book1/res/tei-text-p1.xml" }
3
+ let(:content_type) { "dctypes:Text" }
4
+ let(:mimetype) { "application/tei+xml" }
5
+ let(:image_2_api_service) {
6
+ IIIF::V3::Presentation::Service.new({
7
+ "id" => content_id,
8
+ "@id" => content_id,
9
+ "profile" => IIIF::V3::Presentation::Service::IIIF_IMAGE_V2_LEVEL1_PROFILE
10
+ })
11
+ }
12
+ let(:img_content_resource) {
13
+ IIIF::V3::Presentation::ImageResource.new(
14
+ "id" => content_id,
15
+ "type" => content_type,
16
+ "format" => mimetype,
17
+ "service" => [image_2_api_service]
18
+ )
19
+ }
2
20
 
3
- let(:content_id) { 'http://example.org/iiif/book1/res/tei-text-p1.xml' }
4
- let(:content_type) { 'dctypes:Text' }
5
- let(:mimetype) { 'application/tei+xml' }
6
- let(:image_2_api_service) { IIIF::V3::Presentation::Service.new({
7
- 'id' => content_id,
8
- '@id' => content_id,
9
- 'profile' => IIIF::V3::Presentation::Service::IIIF_IMAGE_V2_LEVEL1_PROFILE
10
- })}
11
- let(:img_content_resource) { IIIF::V3::Presentation::ImageResource.new(
12
- 'id' => content_id,
13
- 'type' => content_type,
14
- 'format' => mimetype,
15
- 'service' => [image_2_api_service]
16
- )}
17
-
18
- describe '#required_keys' do
19
- %w{ type id motivation target }.each do |k|
21
+ describe "#required_keys" do
22
+ %w[type id motivation target].each do |k|
20
23
  it k do
21
24
  expect(subject.required_keys).to include(k)
22
25
  end
23
26
  end
24
27
  end
25
28
 
26
- describe '#prohibited_keys' do
27
- it 'contains the expected key names' do
29
+ describe "#prohibited_keys" do
30
+ it "contains the expected key names" do
28
31
  keys = described_class::PAGING_PROPERTIES +
29
32
  described_class::CONTENT_RESOURCE_PROPERTIES +
30
- %w{
31
- nav_date
32
- viewing_direction
33
- start_canvas
34
- content_annotations
35
- }
36
- expect(subject.prohibited_keys).to include(*keys)
37
- end
33
+ %w[
34
+ nav_date
35
+ viewing_direction
36
+ start_canvas
37
+ content_annotations
38
+ ]
39
+ expect(subject.prohibited_keys).to include(*keys)
40
+ end
38
41
  end
39
42
 
40
- describe '#any_type_keys' do
41
- it 'body' do
42
- expect(subject.any_type_keys).to include('body')
43
+ describe "#any_type_keys" do
44
+ it "body" do
45
+ expect(subject.any_type_keys).to include("body")
43
46
  end
44
- it 'target' do
45
- expect(subject.any_type_keys).to include('target')
47
+ it "target" do
48
+ expect(subject.any_type_keys).to include("target")
46
49
  end
47
50
  end
48
51
 
49
- describe '#uri_only_keys' do
50
- it 'id' do
51
- expect(subject.uri_only_keys).to include('id')
52
+ describe "#uri_only_keys" do
53
+ it "id" do
54
+ expect(subject.uri_only_keys).to include("id")
52
55
  end
53
56
  end
54
57
 
55
- describe '#string_only_keys' do
56
- it 'time_mode' do
57
- expect(subject.string_only_keys).to include('time_mode')
58
+ describe "#string_only_keys" do
59
+ it "time_mode" do
60
+ expect(subject.string_only_keys).to include("time_mode")
58
61
  end
59
62
  end
60
63
 
61
- describe '#legal_time_mode_values' do
62
- it 'contains the expected values' do
63
- expect(subject.legal_time_mode_values).to contain_exactly('trim', 'scale', 'loop')
64
+ describe "#legal_time_mode_values" do
65
+ it "contains the expected values" do
66
+ expect(subject.legal_time_mode_values).to contain_exactly("trim", "scale", "loop")
64
67
  end
65
68
  end
66
69
 
67
- describe '#legal_viewing_hint_values' do
68
- it 'contains none' do
69
- expect(subject.legal_viewing_hint_values).to contain_exactly('none')
70
+ describe "#legal_viewing_hint_values" do
71
+ it "contains none" do
72
+ expect(subject.legal_viewing_hint_values).to contain_exactly("none")
70
73
  end
71
74
  end
72
75
 
73
- describe '#initialize' do
74
- it 'sets type to Annotation by default' do
75
- expect(subject['type']).to eq 'Annotation'
76
+ describe "#initialize" do
77
+ it "sets type to Annotation by default" do
78
+ expect(subject["type"]).to eq "Annotation"
76
79
  end
77
- it 'allows subclasses to override type' do
80
+ it "allows subclasses to override type" do
78
81
  subclass = Class.new(described_class) do
79
- def initialize(hsh={})
80
- hsh = { 'type' => 'a:SubClass' }
81
- super(hsh)
82
+ def initialize(_hsh = {})
83
+ super({"type" => "a:SubClass"})
82
84
  end
83
85
  end
84
86
  sub = subclass.new
85
- expect(sub['type']).to eq 'a:SubClass'
87
+ expect(sub["type"]).to eq "a:SubClass"
86
88
  end
87
- it 'sets motivation to painting by default' do
88
- expect(subject['motivation']).to eq 'painting'
89
+ it "sets motivation to painting by default" do
90
+ expect(subject["motivation"]).to eq "painting"
89
91
  end
90
- it 'allows motivation to be passed in' do
91
- my_anno = described_class.new('motivation' => 'foo')
92
- expect(my_anno.motivation).to eq 'foo'
92
+ it "allows motivation to be passed in" do
93
+ my_anno = described_class.new("motivation" => "foo")
94
+ expect(my_anno.motivation).to eq "foo"
93
95
  end
94
- it 'allows type to be passed in' do
95
- my_anno = described_class.new('type' => 'bar')
96
- expect(my_anno.type).to eq 'bar'
96
+ it "allows type to be passed in" do
97
+ my_anno = described_class.new("type" => "bar")
98
+ expect(my_anno.type).to eq "bar"
97
99
  end
98
100
  end
99
101
 
100
- describe '#validate' do
102
+ describe "#validate" do
101
103
  before(:each) do
102
- subject['id'] = 'http://example.org/iiif/anno/1s'
103
- subject['target'] = 'foo'
104
+ subject["id"] = "http://example.org/iiif/anno/1s"
105
+ subject["target"] = "foo"
104
106
  end
105
- it 'raises IllegalValueError if id is not URI' do
107
+ it "raises IllegalValueError if id is not URI" do
106
108
  exp_err_msg = "id value must be a String containing a URI for #{described_class}"
107
- subject['id'] = 'foo'
109
+ subject["id"] = "foo"
108
110
  expect { subject.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_err_msg)
109
111
  end
110
112
 
111
- it 'raises IllegalValueError if time_mode isn\'t an allowable value' do
113
+ it "raises IllegalValueError if time_mode isn't an allowable value" do
112
114
  exp_err_msg = "timeMode for #{described_class} must be one of [\"trim\", \"scale\", \"loop\"]."
113
- subject['time_mode'] = 'foo'
115
+ subject["time_mode"] = "foo"
114
116
  expect { subject.validate }.to raise_error IIIF::V3::Presentation::IllegalValueError, exp_err_msg
115
117
  end
116
118
 
117
- describe 'body is a kind of IIIF::V3::Presentation::ImageResource' do
119
+ describe "body is a kind of IIIF::V3::Presentation::ImageResource" do
118
120
  let(:img_body_anno) {
119
- subject['id'] = 'http://example.org/iiif/anno/1s'
120
- subject['target'] = 'foo'
121
- subject['body'] = img_content_resource
121
+ subject["id"] = "http://example.org/iiif/anno/1s"
122
+ subject["target"] = "foo"
123
+ subject["body"] = img_content_resource
122
124
  subject
123
125
  }
124
126
  it 'raises IllegalValueError if motivation isn\'t "painting"' do
125
127
  exp_err_msg = "#{described_class} motivation must be 'painting' when body is a kind of IIIF::V3::Presentation::ImageResource"
126
- img_body_anno['motivation'] = 'foo'
128
+ img_body_anno["motivation"] = "foo"
127
129
  expect { img_body_anno.validate }.to raise_error IIIF::V3::Presentation::IllegalValueError, exp_err_msg
128
130
  end
129
131
  let(:img_resource_without_id) {
130
132
  IIIF::V3::Presentation::ImageResource.new(
131
- 'type' => content_type,
132
- 'format' => mimetype
133
- )}
133
+ "type" => content_type,
134
+ "format" => mimetype
135
+ )
136
+ }
134
137
  let(:http_uri_err_msg) {
135
138
  "when #{described_class} body is a kind of IIIF::V3::Presentation::ImageResource, ImageResource id must be an http(s) URI"
136
139
  }
137
- it 'raises IllegalValueError if no id field in ImageResource' do
140
+ it "raises IllegalValueError if no id field in ImageResource" do
138
141
  img_body_anno.body = img_resource_without_id
139
142
  expect { img_body_anno.validate }.to raise_error IIIF::V3::Presentation::IllegalValueError, http_uri_err_msg
140
143
  end
141
- it 'raises IllegalValueError if id in ImageResource isn\'t URI' do
142
- img_resource_without_id['id'] = 'foo'
144
+ it "raises IllegalValueError if id in ImageResource isn't URI" do
145
+ img_resource_without_id["id"] = "foo"
143
146
  img_body_anno.body = img_resource_without_id
144
147
  expect { img_body_anno.validate }.to raise_error IIIF::V3::Presentation::IllegalValueError, http_uri_err_msg
145
148
  end
146
- it 'raises IllegalValueError if id in ImageResource isn\'t http(s) URI' do
147
- img_resource_without_id['id'] = 'ftp://example.com/somewhere'
149
+ it "raises IllegalValueError if id in ImageResource isn't http(s) URI" do
150
+ img_resource_without_id["id"] = "ftp://example.com/somewhere"
148
151
  img_body_anno.body = img_resource_without_id
149
152
  expect { img_body_anno.validate }.to raise_error IIIF::V3::Presentation::IllegalValueError, http_uri_err_msg
150
153
  end
151
154
  end
152
155
  end
153
156
 
154
- describe 'realistic examples' do
155
- let(:anno_id) { 'http://example.org/iiif/annoation/abc666'}
156
- let(:target_id) { 'http://example.org/iiif/canvas/abc666'}
157
+ describe "realistic examples" do
158
+ let(:anno_id) { "http://example.org/iiif/annoation/abc666" }
159
+ let(:target_id) { "http://example.org/iiif/canvas/abc666" }
157
160
 
158
- describe 'stanford (purl code)' do
161
+ describe "stanford (purl code)" do
159
162
  let(:anno) {
160
163
  anno = described_class.new
161
- anno['id'] = anno_id
162
- anno['target'] = target_id
164
+ anno["id"] = anno_id
165
+ anno["target"] = target_id
163
166
  anno.body = img_content_resource
164
167
  anno
165
168
  }
166
- it 'validates' do
167
- expect{anno.validate}.not_to raise_error
169
+ it "validates" do
170
+ expect { anno.validate }.not_to raise_error
168
171
  end
169
- it 'has expected required values' do
172
+ it "has expected required values" do
170
173
  expect(anno.id).to eq anno_id
171
- expect(anno['type']).to eq 'Annotation'
172
- expect(anno['motivation']).to eq 'painting'
173
- expect(anno['target']).to eq target_id
174
+ expect(anno["type"]).to eq "Annotation"
175
+ expect(anno["motivation"]).to eq "painting"
176
+ expect(anno["target"]).to eq target_id
174
177
  end
175
- it 'has expected additional values' do
176
- expect(anno['body']).to eq img_content_resource
178
+ it "has expected additional values" do
179
+ expect(anno["body"]).to eq img_content_resource
177
180
  end
178
181
  end
179
182
 
180
- describe 'from http://prezi3.iiif.io/api/presentation/3.0' do
181
- describe 'body is image_resource with height and width' do
182
- let(:img_type) { 'dctypes:Image' }
183
- let(:img_mime) { 'image/jpeg' }
183
+ describe "from http://prezi3.iiif.io/api/presentation/3.0" do
184
+ describe "body is image_resource with height and width" do
185
+ let(:img_type) { "dctypes:Image" }
186
+ let(:img_mime) { "image/jpeg" }
184
187
  let(:img_h) { 2000 }
185
188
  let(:img_w) { 1500 }
186
- let(:img_hw_resource) do
189
+ let(:img_hw_resource) do
187
190
  IIIF::V3::Presentation::ImageResource.new(
188
- 'id' => content_id,
189
- 'type' => img_type,
190
- 'format' => img_mime,
191
- 'height' => img_h,
192
- 'width' => img_w,
193
- 'service' => [image_2_api_service]
191
+ "id" => content_id,
192
+ "type" => img_type,
193
+ "format" => img_mime,
194
+ "height" => img_h,
195
+ "width" => img_w,
196
+ "service" => [image_2_api_service]
194
197
  )
195
198
  end
196
199
  let(:my_anno) {
197
200
  anno = described_class.new
198
- anno['id'] = anno_id
199
- anno['target'] = target_id
201
+ anno["id"] = anno_id
202
+ anno["target"] = target_id
200
203
  anno.body = img_hw_resource
201
204
  anno
202
205
  }
203
- it 'validates' do
204
- expect{my_anno.validate}.not_to raise_error
206
+ it "validates" do
207
+ expect { my_anno.validate }.not_to raise_error
205
208
  end
206
- it 'has expected additional values' do
207
- expect(my_anno['body']).to eq img_hw_resource
208
- expect(my_anno['body']['height']).to eq img_h
209
- expect(my_anno['body']['width']).to eq img_w
209
+ it "has expected additional values" do
210
+ expect(my_anno["body"]).to eq img_hw_resource
211
+ expect(my_anno["body"]["height"]).to eq img_h
212
+ expect(my_anno["body"]["width"]).to eq img_w
210
213
  end
211
214
 
212
- describe 'and service with height and width and tiles' do
213
- let(:tiles_val) { [{"width" => 512, "scaleFactors" => [1,2,4,8,16]}] }
215
+ describe "and service with height and width and tiles" do
216
+ let(:tiles_val) { [{"width" => 512, "scaleFactors" => [1, 2, 4, 8, 16]}] }
214
217
  let(:service) do
215
218
  s = image_2_api_service
216
- s['height'] = 8000
217
- s['width'] = 6000
218
- s['tiles'] = tiles_val
219
+ s["height"] = 8000
220
+ s["width"] = 6000
221
+ s["tiles"] = tiles_val
219
222
  [s]
220
223
  end
221
- it 'validates' do
222
- img_hw_resource['service'] = service
223
- expect{my_anno.validate}.not_to raise_error
224
+ it "validates" do
225
+ img_hw_resource["service"] = service
226
+ expect { my_anno.validate }.not_to raise_error
224
227
  end
225
228
  it "body['service'] has expected additional values'" do
226
- annotation_service = my_anno['body']['service'].first
229
+ annotation_service = my_anno["body"]["service"].first
227
230
  expect(annotation_service).to eq service.first
228
- expect(annotation_service['height']).to eq 8000
229
- expect(annotation_service['width']).to eq 6000
230
- expect(annotation_service['tiles']).to eq tiles_val
231
+ expect(annotation_service["height"]).to eq 8000
232
+ expect(annotation_service["width"]).to eq 6000
233
+ expect(annotation_service["tiles"]).to eq tiles_val
231
234
  end
232
235
  end
233
236
  end
234
237
  end
235
238
 
236
- describe 'from digerati' do
237
- describe 'anno body is audio' do
238
- let(:body_id) { 'http://example.org/iiif/foo2.mp3' }
239
- let(:body_type) { 'Audio' }
240
- let(:audio_res) { IIIF::V3::Presentation::Resource.new(
241
- 'id' => body_id,
242
- 'type' => body_type
243
- )}
239
+ describe "from digerati" do
240
+ describe "anno body is audio" do
241
+ let(:body_id) { "http://example.org/iiif/foo2.mp3" }
242
+ let(:body_type) { "Audio" }
243
+ let(:audio_res) {
244
+ IIIF::V3::Presentation::Resource.new(
245
+ "id" => body_id,
246
+ "type" => body_type
247
+ )
248
+ }
244
249
  let(:my_anno) {
245
250
  anno = described_class.new
246
- anno['id'] = anno_id
247
- anno['target'] = target_id
251
+ anno["id"] = anno_id
252
+ anno["target"] = target_id
248
253
  anno.body = audio_res
249
254
  anno
250
255
  }
251
- it 'validates' do
252
- expect{my_anno.validate}.not_to raise_error
256
+ it "validates" do
257
+ expect { my_anno.validate }.not_to raise_error
253
258
  end
254
- it 'has expected required values' do
255
- expect(my_anno['type']).to eq 'Annotation'
259
+ it "has expected required values" do
260
+ expect(my_anno["type"]).to eq "Annotation"
256
261
  expect(my_anno.id).to eq anno_id
257
- expect(my_anno['motivation']).to eq 'painting'
258
- expect(my_anno['target']).to eq target_id
262
+ expect(my_anno["motivation"]).to eq "painting"
263
+ expect(my_anno["target"]).to eq target_id
259
264
  end
260
- it 'has expected additional values' do
261
- expect(my_anno['body']).to eq audio_res
262
- expect(my_anno['body']['type']).to eq body_type
263
- expect(my_anno['body']['id']).to eq body_id
265
+ it "has expected additional values" do
266
+ expect(my_anno["body"]).to eq audio_res
267
+ expect(my_anno["body"]["type"]).to eq body_type
268
+ expect(my_anno["body"]["id"]).to eq body_id
264
269
  end
265
270
  end
266
271
 
267
- describe 'anno body is video' do
268
- let(:body_id) { 'http://example.org/foo.webm' }
269
- let(:body_type) { 'Video' }
270
- let(:body_mime) { 'video/webm' }
271
- let(:video_res) { IIIF::V3::Presentation::Resource.new(
272
- 'id' => body_id,
273
- 'type' => body_type,
274
- 'format' => body_mime
275
- )}
272
+ describe "anno body is video" do
273
+ let(:body_id) { "http://example.org/foo.webm" }
274
+ let(:body_type) { "Video" }
275
+ let(:body_mime) { "video/webm" }
276
+ let(:video_res) {
277
+ IIIF::V3::Presentation::Resource.new(
278
+ "id" => body_id,
279
+ "type" => body_type,
280
+ "format" => body_mime
281
+ )
282
+ }
276
283
  let(:my_anno) {
277
284
  anno = described_class.new
278
- anno['id'] = anno_id
279
- anno['target'] = target_id
285
+ anno["id"] = anno_id
286
+ anno["target"] = target_id
280
287
  anno.body = video_res
281
288
  anno
282
289
  }
283
- it 'validates' do
284
- expect{my_anno.validate}.not_to raise_error
290
+ it "validates" do
291
+ expect { my_anno.validate }.not_to raise_error
285
292
  end
286
- it 'has expected body values' do
287
- expect(my_anno['body']).to eq video_res
288
- expect(my_anno['body']['type']).to eq body_type
289
- expect(my_anno['body']['id']).to eq body_id
290
- expect(my_anno['body']['format']).to eq body_mime
293
+ it "has expected body values" do
294
+ expect(my_anno["body"]).to eq video_res
295
+ expect(my_anno["body"]["type"]).to eq body_type
296
+ expect(my_anno["body"]["id"]).to eq body_id
297
+ expect(my_anno["body"]["format"]).to eq body_mime
291
298
  end
292
299
  end
293
300
 
294
- describe 'anno body is 3d object' do
295
- let(:body_id) { 'http://files.universalviewer.io/manifests/nelis/animal-skull/animal-skull.json' }
296
- let(:body_type) { 'PhysicalObject' }
297
- let(:body_mime) { 'application/vnd.threejs+json' }
298
- let(:body_label) { 'Animal Skull' }
299
- let(:body_res) { IIIF::V3::Presentation::Resource.new(
300
- 'id' => body_id,
301
- 'type' => body_type,
302
- 'format' => body_mime,
303
- 'label' => body_label
304
- )}
301
+ describe "anno body is 3d object" do
302
+ let(:body_id) { "http://files.universalviewer.io/manifests/nelis/animal-skull/animal-skull.json" }
303
+ let(:body_type) { "PhysicalObject" }
304
+ let(:body_mime) { "application/vnd.threejs+json" }
305
+ let(:body_label) { "Animal Skull" }
306
+ let(:body_res) {
307
+ IIIF::V3::Presentation::Resource.new(
308
+ "id" => body_id,
309
+ "type" => body_type,
310
+ "format" => body_mime,
311
+ "label" => body_label
312
+ )
313
+ }
305
314
  let(:my_anno) {
306
315
  anno = described_class.new
307
- anno['id'] = anno_id
308
- anno['target'] = target_id
316
+ anno["id"] = anno_id
317
+ anno["target"] = target_id
309
318
  anno.body = body_res
310
319
  anno
311
320
  }
312
- it 'validates' do
313
- expect{my_anno.validate}.not_to raise_error
321
+ it "validates" do
322
+ expect { my_anno.validate }.not_to raise_error
314
323
  end
315
- it 'has expected body values' do
316
- expect(my_anno['body']).to eq body_res
317
- expect(my_anno['body']['type']).to eq body_type
318
- expect(my_anno['body']['id']).to eq body_id
319
- expect(my_anno['body']['format']).to eq body_mime
320
- expect(my_anno['body']['label']).to eq body_label
324
+ it "has expected body values" do
325
+ expect(my_anno["body"]).to eq body_res
326
+ expect(my_anno["body"]["type"]).to eq body_type
327
+ expect(my_anno["body"]["id"]).to eq body_id
328
+ expect(my_anno["body"]["format"]).to eq body_mime
329
+ expect(my_anno["body"]["label"]).to eq body_label
321
330
  end
322
331
  end
323
332
 
324
- describe 'anno body is pdf' do
325
- let(:body_id) { 'http://example.org/iiif/some-document.pdf' }
326
- let(:body_type) { 'Document' }
327
- let(:body_mime) { 'application/pdf' }
328
- let(:body_res) { IIIF::V3::Presentation::Resource.new(
329
- 'id' => body_id,
330
- 'type' => body_type,
331
- 'format' => body_mime
332
- )}
333
+ describe "anno body is pdf" do
334
+ let(:body_id) { "http://example.org/iiif/some-document.pdf" }
335
+ let(:body_type) { "Document" }
336
+ let(:body_mime) { "application/pdf" }
337
+ let(:body_res) {
338
+ IIIF::V3::Presentation::Resource.new(
339
+ "id" => body_id,
340
+ "type" => body_type,
341
+ "format" => body_mime
342
+ )
343
+ }
333
344
  let(:my_anno) {
334
345
  anno = described_class.new
335
- anno['id'] = anno_id
336
- anno['target'] = target_id
346
+ anno["id"] = anno_id
347
+ anno["target"] = target_id
337
348
  anno.body = body_res
338
349
  anno
339
350
  }
340
- it 'validates' do
341
- expect{my_anno.validate}.not_to raise_error
351
+ it "validates" do
352
+ expect { my_anno.validate }.not_to raise_error
342
353
  end
343
- it 'has expected body values' do
344
- expect(my_anno['body']).to eq body_res
345
- expect(my_anno['body']['type']).to eq body_type
346
- expect(my_anno['body']['id']).to eq body_id
347
- expect(my_anno['body']['format']).to eq body_mime
354
+ it "has expected body values" do
355
+ expect(my_anno["body"]).to eq body_res
356
+ expect(my_anno["body"]["type"]).to eq body_type
357
+ expect(my_anno["body"]["id"]).to eq body_id
358
+ expect(my_anno["body"]["format"]).to eq body_mime
348
359
  end
349
360
  end
350
361
 
351
- describe 'anno body is choice (of 2 videos)' do
352
- let(:body_type) { 'Video' }
353
- let(:body1_id) { 'http://example.org/foo.mp4f' }
354
- let(:body1_mime) { 'video/mp4; codec..xxxxx' }
355
- let(:body1_res) { IIIF::V3::Presentation::Resource.new(
356
- 'id' => body1_id,
357
- 'type' => body_type,
358
- 'format' => body1_mime
359
- )}
360
- let(:body2_id) { 'http://example.org/foo.webm' }
361
- let(:body2_mime) { 'video/webm' }
362
- let(:body2_res) { IIIF::V3::Presentation::Resource.new(
363
- 'id' => body2_id,
364
- 'type' => body_type,
365
- 'format' => body2_mime
366
- )}
367
- let(:body_res) { IIIF::V3::Presentation::Choice.new(
368
- 'items' => [body1_res, body2_res],
369
- 'choiceHint' => 'client'
370
- )}
362
+ describe "anno body is choice (of 2 videos)" do
363
+ let(:body_type) { "Video" }
364
+ let(:body1_id) { "http://example.org/foo.mp4f" }
365
+ let(:body1_mime) { "video/mp4; codec..xxxxx" }
366
+ let(:body1_res) {
367
+ IIIF::V3::Presentation::Resource.new(
368
+ "id" => body1_id,
369
+ "type" => body_type,
370
+ "format" => body1_mime
371
+ )
372
+ }
373
+ let(:body2_id) { "http://example.org/foo.webm" }
374
+ let(:body2_mime) { "video/webm" }
375
+ let(:body2_res) {
376
+ IIIF::V3::Presentation::Resource.new(
377
+ "id" => body2_id,
378
+ "type" => body_type,
379
+ "format" => body2_mime
380
+ )
381
+ }
382
+ let(:body_res) {
383
+ IIIF::V3::Presentation::Choice.new(
384
+ "items" => [body1_res, body2_res],
385
+ "choiceHint" => "client"
386
+ )
387
+ }
371
388
  let(:my_anno) {
372
389
  anno = described_class.new
373
- anno['id'] = anno_id
374
- anno['target'] = target_id
390
+ anno["id"] = anno_id
391
+ anno["target"] = target_id
375
392
  anno.body = body_res
376
393
  anno
377
394
  }
378
- it 'validates' do
379
- expect{my_anno.validate}.not_to raise_error
395
+ it "validates" do
396
+ expect { my_anno.validate }.not_to raise_error
380
397
  end
381
- it 'has expected body values' do
382
- expect(my_anno['body']).to eq body_res
383
- expect(my_anno['body'].keys.size).to eq 3
384
- expect(my_anno['body']['type']).to eq 'Choice'
385
- expect(my_anno['body'].choiceHint).to eq 'client'
386
- expect(my_anno['body']['items']).to eq [body1_res, body2_res]
398
+ it "has expected body values" do
399
+ expect(my_anno["body"]).to eq body_res
400
+ expect(my_anno["body"].keys.size).to eq 3
401
+ expect(my_anno["body"]["type"]).to eq "Choice"
402
+ expect(my_anno["body"].choiceHint).to eq "client"
403
+ expect(my_anno["body"]["items"]).to eq [body1_res, body2_res]
387
404
  end
388
405
  end
389
406
  end
390
407
  end
391
-
392
408
  end