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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +8 -1
- data/.standard.yml +1 -0
- data/Gemfile +5 -5
- data/README.md +1 -1
- data/Rakefile +4 -2
- data/VERSION +1 -1
- data/bin/standardrb +16 -0
- data/iiif-presentation.gemspec +23 -23
- data/lib/iiif/hash_behaviours.rb +29 -33
- data/lib/iiif/ordered_hash.rb +33 -33
- data/lib/iiif/presentation/abstract_resource.rb +17 -22
- data/lib/iiif/presentation/annotation.rb +9 -11
- data/lib/iiif/presentation/annotation_list.rb +8 -10
- data/lib/iiif/presentation/canvas.rb +11 -13
- data/lib/iiif/presentation/collection.rb +7 -9
- data/lib/iiif/presentation/image_resource.rb +33 -35
- data/lib/iiif/presentation/layer.rb +8 -10
- data/lib/iiif/presentation/manifest.rb +9 -12
- data/lib/iiif/presentation/range.rb +8 -10
- data/lib/iiif/presentation/resource.rb +5 -7
- data/lib/iiif/presentation/sequence.rb +8 -11
- data/lib/iiif/presentation/service.rb +1 -2
- data/lib/iiif/presentation.rb +7 -7
- data/lib/iiif/service.rb +121 -102
- data/lib/iiif/v3/abstract_resource.rb +127 -130
- data/lib/iiif/v3/presentation/annotation.rb +20 -21
- data/lib/iiif/v3/presentation/annotation_collection.rb +7 -9
- data/lib/iiif/v3/presentation/annotation_page.rb +14 -15
- data/lib/iiif/v3/presentation/canvas.rb +21 -22
- data/lib/iiif/v3/presentation/choice.rb +14 -15
- data/lib/iiif/v3/presentation/collection.rb +7 -8
- data/lib/iiif/v3/presentation/image_resource.rb +21 -22
- data/lib/iiif/v3/presentation/manifest.rb +18 -19
- data/lib/iiif/v3/presentation/nav_place.rb +125 -29
- data/lib/iiif/v3/presentation/range.rb +10 -10
- data/lib/iiif/v3/presentation/resource.rb +4 -5
- data/lib/iiif/v3/presentation/sequence.rb +10 -11
- data/lib/iiif/v3/presentation/service.rb +12 -13
- data/lib/iiif/v3/presentation.rb +8 -8
- data/spec/integration/iiif/presentation/image_resource_spec.rb +54 -58
- data/spec/integration/iiif/service_spec.rb +76 -77
- data/spec/integration/iiif/v3/abstract_resource_spec.rb +72 -73
- data/spec/integration/iiif/v3/presentation/image_resource_spec.rb +53 -56
- data/spec/spec_helper.rb +56 -64
- data/spec/unit/iiif/hash_behaviours_spec.rb +384 -387
- data/spec/unit/iiif/ordered_hash_spec.rb +86 -91
- data/spec/unit/iiif/presentation/abstract_resource_spec.rb +64 -70
- data/spec/unit/iiif/presentation/annotation_list_spec.rb +1 -3
- data/spec/unit/iiif/presentation/annotation_spec.rb +1 -3
- data/spec/unit/iiif/presentation/canvas_spec.rb +11 -14
- data/spec/unit/iiif/presentation/collection_spec.rb +26 -33
- data/spec/unit/iiif/presentation/image_resource_spec.rb +4 -6
- data/spec/unit/iiif/presentation/layer_spec.rb +16 -20
- data/spec/unit/iiif/presentation/manifest_spec.rb +45 -48
- data/spec/unit/iiif/presentation/range_spec.rb +18 -22
- data/spec/unit/iiif/presentation/resource_spec.rb +3 -6
- data/spec/unit/iiif/presentation/sequence_spec.rb +58 -63
- data/spec/unit/iiif/presentation/shared_examples/abstract_resource_only_keys.rb +4 -10
- data/spec/unit/iiif/presentation/shared_examples/any_type_keys.rb +5 -9
- data/spec/unit/iiif/presentation/shared_examples/array_only_keys.rb +9 -17
- data/spec/unit/iiif/presentation/shared_examples/int_only_keys.rb +6 -14
- data/spec/unit/iiif/presentation/shared_examples/string_only_keys.rb +6 -13
- data/spec/unit/iiif/service_spec.rb +8 -13
- data/spec/unit/iiif/v3/abstract_resource_define_methods_for_spec.rb +39 -37
- data/spec/unit/iiif/v3/abstract_resource_spec.rb +124 -131
- data/spec/unit/iiif/v3/presentation/annotation_collection_spec.rb +14 -17
- data/spec/unit/iiif/v3/presentation/annotation_page_spec.rb +71 -69
- data/spec/unit/iiif/v3/presentation/annotation_spec.rb +249 -233
- data/spec/unit/iiif/v3/presentation/canvas_spec.rb +211 -193
- data/spec/unit/iiif/v3/presentation/choice_spec.rb +81 -77
- data/spec/unit/iiif/v3/presentation/collection_spec.rb +24 -29
- data/spec/unit/iiif/v3/presentation/image_resource_spec.rb +70 -71
- data/spec/unit/iiif/v3/presentation/manifest_spec.rb +248 -235
- data/spec/unit/iiif/v3/presentation/nav_place_spec.rb +249 -49
- data/spec/unit/iiif/v3/presentation/range_spec.rb +28 -29
- data/spec/unit/iiif/v3/presentation/resource_spec.rb +83 -82
- data/spec/unit/iiif/v3/presentation/sequence_spec.rb +125 -119
- data/spec/unit/iiif/v3/presentation/service_spec.rb +123 -124
- data/spec/unit/iiif/v3/presentation/shared_examples/abstract_resource_only_keys.rb +4 -8
- data/spec/unit/iiif/v3/presentation/shared_examples/any_type_keys.rb +5 -7
- data/spec/unit/iiif/v3/presentation/shared_examples/array_only_keys.rb +9 -13
- data/spec/unit/iiif/v3/presentation/shared_examples/hash_only_keys.rb +9 -13
- data/spec/unit/iiif/v3/presentation/shared_examples/int_only_keys.rb +6 -10
- data/spec/unit/iiif/v3/presentation/shared_examples/numeric_only_keys.rb +6 -10
- data/spec/unit/iiif/v3/presentation/shared_examples/string_only_keys.rb +6 -10
- data/spec/unit/iiif/v3/presentation/shared_examples/uri_only_keys.rb +9 -13
- 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
|
-
|
|
4
|
-
|
|
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
|
|
27
|
-
it
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
41
|
-
it
|
|
42
|
-
expect(subject.any_type_keys).to include(
|
|
43
|
+
describe "#any_type_keys" do
|
|
44
|
+
it "body" do
|
|
45
|
+
expect(subject.any_type_keys).to include("body")
|
|
43
46
|
end
|
|
44
|
-
it
|
|
45
|
-
expect(subject.any_type_keys).to include(
|
|
47
|
+
it "target" do
|
|
48
|
+
expect(subject.any_type_keys).to include("target")
|
|
46
49
|
end
|
|
47
50
|
end
|
|
48
51
|
|
|
49
|
-
describe
|
|
50
|
-
it
|
|
51
|
-
expect(subject.uri_only_keys).to include(
|
|
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
|
|
56
|
-
it
|
|
57
|
-
expect(subject.string_only_keys).to include(
|
|
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
|
|
62
|
-
it
|
|
63
|
-
expect(subject.legal_time_mode_values).to contain_exactly(
|
|
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
|
|
68
|
-
it
|
|
69
|
-
expect(subject.legal_viewing_hint_values).to contain_exactly(
|
|
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
|
|
74
|
-
it
|
|
75
|
-
expect(subject[
|
|
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
|
|
80
|
+
it "allows subclasses to override type" do
|
|
78
81
|
subclass = Class.new(described_class) do
|
|
79
|
-
def initialize(
|
|
80
|
-
|
|
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[
|
|
87
|
+
expect(sub["type"]).to eq "a:SubClass"
|
|
86
88
|
end
|
|
87
|
-
it
|
|
88
|
-
expect(subject[
|
|
89
|
+
it "sets motivation to painting by default" do
|
|
90
|
+
expect(subject["motivation"]).to eq "painting"
|
|
89
91
|
end
|
|
90
|
-
it
|
|
91
|
-
my_anno = described_class.new(
|
|
92
|
-
expect(my_anno.motivation).to eq
|
|
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
|
|
95
|
-
my_anno = described_class.new(
|
|
96
|
-
expect(my_anno.type).to eq
|
|
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
|
|
102
|
+
describe "#validate" do
|
|
101
103
|
before(:each) do
|
|
102
|
-
subject[
|
|
103
|
-
subject[
|
|
104
|
+
subject["id"] = "http://example.org/iiif/anno/1s"
|
|
105
|
+
subject["target"] = "foo"
|
|
104
106
|
end
|
|
105
|
-
it
|
|
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[
|
|
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
|
|
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[
|
|
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
|
|
119
|
+
describe "body is a kind of IIIF::V3::Presentation::ImageResource" do
|
|
118
120
|
let(:img_body_anno) {
|
|
119
|
-
subject[
|
|
120
|
-
subject[
|
|
121
|
-
subject[
|
|
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[
|
|
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
|
-
|
|
132
|
-
|
|
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
|
|
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
|
|
142
|
-
img_resource_without_id[
|
|
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
|
|
147
|
-
img_resource_without_id[
|
|
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
|
|
155
|
-
let(:anno_id) {
|
|
156
|
-
let(:target_id) {
|
|
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
|
|
161
|
+
describe "stanford (purl code)" do
|
|
159
162
|
let(:anno) {
|
|
160
163
|
anno = described_class.new
|
|
161
|
-
anno[
|
|
162
|
-
anno[
|
|
164
|
+
anno["id"] = anno_id
|
|
165
|
+
anno["target"] = target_id
|
|
163
166
|
anno.body = img_content_resource
|
|
164
167
|
anno
|
|
165
168
|
}
|
|
166
|
-
it
|
|
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
|
|
172
|
+
it "has expected required values" do
|
|
170
173
|
expect(anno.id).to eq anno_id
|
|
171
|
-
expect(anno[
|
|
172
|
-
expect(anno[
|
|
173
|
-
expect(anno[
|
|
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
|
|
176
|
-
expect(anno[
|
|
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
|
|
181
|
-
describe
|
|
182
|
-
let(:img_type) {
|
|
183
|
-
let(:img_mime) {
|
|
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)
|
|
189
|
+
let(:img_hw_resource) do
|
|
187
190
|
IIIF::V3::Presentation::ImageResource.new(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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[
|
|
199
|
-
anno[
|
|
201
|
+
anno["id"] = anno_id
|
|
202
|
+
anno["target"] = target_id
|
|
200
203
|
anno.body = img_hw_resource
|
|
201
204
|
anno
|
|
202
205
|
}
|
|
203
|
-
it
|
|
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
|
|
207
|
-
expect(my_anno[
|
|
208
|
-
expect(my_anno[
|
|
209
|
-
expect(my_anno[
|
|
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
|
|
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[
|
|
217
|
-
s[
|
|
218
|
-
s[
|
|
219
|
+
s["height"] = 8000
|
|
220
|
+
s["width"] = 6000
|
|
221
|
+
s["tiles"] = tiles_val
|
|
219
222
|
[s]
|
|
220
223
|
end
|
|
221
|
-
it
|
|
222
|
-
img_hw_resource[
|
|
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[
|
|
229
|
+
annotation_service = my_anno["body"]["service"].first
|
|
227
230
|
expect(annotation_service).to eq service.first
|
|
228
|
-
expect(annotation_service[
|
|
229
|
-
expect(annotation_service[
|
|
230
|
-
expect(annotation_service[
|
|
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
|
|
237
|
-
describe
|
|
238
|
-
let(:body_id) {
|
|
239
|
-
let(:body_type) {
|
|
240
|
-
let(:audio_res) {
|
|
241
|
-
|
|
242
|
-
|
|
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[
|
|
247
|
-
anno[
|
|
251
|
+
anno["id"] = anno_id
|
|
252
|
+
anno["target"] = target_id
|
|
248
253
|
anno.body = audio_res
|
|
249
254
|
anno
|
|
250
255
|
}
|
|
251
|
-
it
|
|
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
|
|
255
|
-
expect(my_anno[
|
|
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[
|
|
258
|
-
expect(my_anno[
|
|
262
|
+
expect(my_anno["motivation"]).to eq "painting"
|
|
263
|
+
expect(my_anno["target"]).to eq target_id
|
|
259
264
|
end
|
|
260
|
-
it
|
|
261
|
-
expect(my_anno[
|
|
262
|
-
expect(my_anno[
|
|
263
|
-
expect(my_anno[
|
|
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
|
|
268
|
-
let(:body_id) {
|
|
269
|
-
let(:body_type) {
|
|
270
|
-
let(:body_mime) {
|
|
271
|
-
let(:video_res) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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[
|
|
279
|
-
anno[
|
|
285
|
+
anno["id"] = anno_id
|
|
286
|
+
anno["target"] = target_id
|
|
280
287
|
anno.body = video_res
|
|
281
288
|
anno
|
|
282
289
|
}
|
|
283
|
-
it
|
|
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
|
|
287
|
-
expect(my_anno[
|
|
288
|
-
expect(my_anno[
|
|
289
|
-
expect(my_anno[
|
|
290
|
-
expect(my_anno[
|
|
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
|
|
295
|
-
let(:body_id) {
|
|
296
|
-
let(:body_type) {
|
|
297
|
-
let(:body_mime) {
|
|
298
|
-
let(:body_label) {
|
|
299
|
-
let(:body_res) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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[
|
|
308
|
-
anno[
|
|
316
|
+
anno["id"] = anno_id
|
|
317
|
+
anno["target"] = target_id
|
|
309
318
|
anno.body = body_res
|
|
310
319
|
anno
|
|
311
320
|
}
|
|
312
|
-
it
|
|
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
|
|
316
|
-
expect(my_anno[
|
|
317
|
-
expect(my_anno[
|
|
318
|
-
expect(my_anno[
|
|
319
|
-
expect(my_anno[
|
|
320
|
-
expect(my_anno[
|
|
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
|
|
325
|
-
let(:body_id) {
|
|
326
|
-
let(:body_type) {
|
|
327
|
-
let(:body_mime) {
|
|
328
|
-
let(:body_res) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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[
|
|
336
|
-
anno[
|
|
346
|
+
anno["id"] = anno_id
|
|
347
|
+
anno["target"] = target_id
|
|
337
348
|
anno.body = body_res
|
|
338
349
|
anno
|
|
339
350
|
}
|
|
340
|
-
it
|
|
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
|
|
344
|
-
expect(my_anno[
|
|
345
|
-
expect(my_anno[
|
|
346
|
-
expect(my_anno[
|
|
347
|
-
expect(my_anno[
|
|
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
|
|
352
|
-
let(:body_type) {
|
|
353
|
-
let(:body1_id) {
|
|
354
|
-
let(:body1_mime) {
|
|
355
|
-
let(:body1_res) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
let(:
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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[
|
|
374
|
-
anno[
|
|
390
|
+
anno["id"] = anno_id
|
|
391
|
+
anno["target"] = target_id
|
|
375
392
|
anno.body = body_res
|
|
376
393
|
anno
|
|
377
394
|
}
|
|
378
|
-
it
|
|
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
|
|
382
|
-
expect(my_anno[
|
|
383
|
-
expect(my_anno[
|
|
384
|
-
expect(my_anno[
|
|
385
|
-
expect(my_anno[
|
|
386
|
-
expect(my_anno[
|
|
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
|