iiif-presentation 1.4.1 → 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 +132 -144
- 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 +73 -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 +128 -143
- 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 -237
- 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 +126 -120
- 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 +27 -69
|
@@ -1,88 +1,87 @@
|
|
|
1
1
|
describe IIIF::V3::Presentation::Service do
|
|
2
|
-
|
|
3
|
-
describe '#required_keys' do
|
|
2
|
+
describe "#required_keys" do
|
|
4
3
|
it '"type" is not required' do
|
|
5
|
-
expect(subject.required_keys).not_to include(
|
|
4
|
+
expect(subject.required_keys).not_to include("type")
|
|
6
5
|
end
|
|
7
6
|
end
|
|
8
7
|
|
|
9
|
-
describe
|
|
10
|
-
it
|
|
8
|
+
describe "#prohibited_keys" do
|
|
9
|
+
it "contains the expected key names" do
|
|
11
10
|
keys = described_class::CONTENT_RESOURCE_PROPERTIES +
|
|
12
11
|
described_class::PAGING_PROPERTIES +
|
|
13
|
-
%w
|
|
12
|
+
%w[
|
|
14
13
|
nav_date
|
|
15
14
|
viewing_direction
|
|
16
15
|
start_canvas
|
|
17
16
|
content_annotations
|
|
18
|
-
|
|
17
|
+
]
|
|
19
18
|
expect(subject.prohibited_keys).to include(*keys)
|
|
20
19
|
end
|
|
21
20
|
end
|
|
22
21
|
|
|
23
|
-
describe
|
|
24
|
-
it
|
|
25
|
-
expect(subject.uri_only_keys).to include(
|
|
22
|
+
describe "#uri_only_keys" do
|
|
23
|
+
it "@context" do
|
|
24
|
+
expect(subject.uri_only_keys).to include("@context")
|
|
26
25
|
end
|
|
27
|
-
it
|
|
28
|
-
expect(subject.uri_only_keys).to include(
|
|
26
|
+
it "@id" do
|
|
27
|
+
expect(subject.uri_only_keys).to include("@id")
|
|
29
28
|
end
|
|
30
|
-
it
|
|
31
|
-
expect(subject.uri_only_keys).to include(
|
|
29
|
+
it "id" do
|
|
30
|
+
expect(subject.uri_only_keys).to include("id")
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
33
|
|
|
35
|
-
describe
|
|
36
|
-
it
|
|
37
|
-
expect(subject.any_type_keys).to include(
|
|
34
|
+
describe "#any_type_keys" do
|
|
35
|
+
it "profile" do
|
|
36
|
+
expect(subject.any_type_keys).to include("profile")
|
|
38
37
|
end
|
|
39
38
|
end
|
|
40
39
|
|
|
41
40
|
let(:id_uri) { "https://example.org/image1" }
|
|
42
41
|
|
|
43
|
-
describe
|
|
44
|
-
it
|
|
45
|
-
label_val =
|
|
46
|
-
inner_service_id =
|
|
47
|
-
inner_service_profile =
|
|
42
|
+
describe "#initialize" do
|
|
43
|
+
it "assigns hash values passed in" do
|
|
44
|
+
label_val = "foo"
|
|
45
|
+
inner_service_id = "http://example.org/whatever"
|
|
46
|
+
inner_service_profile = "http://iiif.io/api/auth/1/token"
|
|
48
47
|
inner_service_val = described_class.new({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
"id" => inner_service_id,
|
|
49
|
+
"profile" => inner_service_profile
|
|
50
|
+
})
|
|
52
51
|
service_obj = described_class.new({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
"type" => described_class::IIIF_IMAGE_V2_TYPE,
|
|
53
|
+
"id" => id_uri,
|
|
54
|
+
"profile" => described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE,
|
|
55
|
+
"label" => label_val,
|
|
56
|
+
"service" => [inner_service_val]
|
|
58
57
|
})
|
|
59
58
|
expect(service_obj.keys.size).to eq 5
|
|
60
|
-
expect(service_obj[
|
|
61
|
-
expect(service_obj[
|
|
62
|
-
expect(service_obj[
|
|
63
|
-
expect(service_obj[
|
|
64
|
-
expect(service_obj[
|
|
65
|
-
expect(service_obj[
|
|
59
|
+
expect(service_obj["id"]).to eq id_uri
|
|
60
|
+
expect(service_obj["type"]).to eq described_class::IIIF_IMAGE_V2_TYPE
|
|
61
|
+
expect(service_obj["profile"]).to eq described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE
|
|
62
|
+
expect(service_obj["label"]).to eq label_val
|
|
63
|
+
expect(service_obj["service"][0]["id"]).to eq inner_service_id
|
|
64
|
+
expect(service_obj["service"][0]["profile"]).to eq inner_service_profile
|
|
66
65
|
end
|
|
67
66
|
it 'allows both "id" and "@id" as keys' do
|
|
68
67
|
id_uri = "https://stacks.stanford.edu/image/iiif/wy534zh7137%2FSULAIR_rosette"
|
|
69
68
|
service_obj = described_class.new({
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
"id" => id_uri,
|
|
70
|
+
"@id" => id_uri
|
|
72
71
|
})
|
|
73
72
|
expect(service_obj.keys.size).to eq 2
|
|
74
|
-
expect(service_obj[
|
|
75
|
-
expect(service_obj[
|
|
73
|
+
expect(service_obj["id"]).to eq id_uri
|
|
74
|
+
expect(service_obj["@id"]).to eq id_uri
|
|
76
75
|
end
|
|
77
|
-
it
|
|
78
|
-
expect{
|
|
76
|
+
it "allows non-URI profile value" do
|
|
77
|
+
expect {
|
|
79
78
|
described_class.new({
|
|
80
79
|
"profile" => [
|
|
81
80
|
"http://iiif.io/api/image/2/level2.json",
|
|
82
81
|
{
|
|
83
|
-
"formats" => [
|
|
84
|
-
"qualities" => [
|
|
85
|
-
"supports" => [
|
|
82
|
+
"formats" => ["gif", "pdf"],
|
|
83
|
+
"qualities" => ["color", "gray"],
|
|
84
|
+
"supports" => ["canonicalLinkHeader", "rotationArbitrary", "http://example.com/feature"]
|
|
86
85
|
}
|
|
87
86
|
]
|
|
88
87
|
})
|
|
@@ -90,111 +89,111 @@ describe IIIF::V3::Presentation::Service do
|
|
|
90
89
|
end
|
|
91
90
|
end
|
|
92
91
|
|
|
93
|
-
describe
|
|
94
|
-
describe
|
|
92
|
+
describe "#validate" do
|
|
93
|
+
describe "type = IIIF_IMAGE_API_V2_TYPE" do
|
|
95
94
|
it 'must have a "@id" or "id"' do
|
|
96
95
|
service_obj = described_class.new({
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
exp_err_msg =
|
|
102
|
-
expect{service_obj.validate}.to raise_error(IIIF::V3::Presentation::MissingRequiredKeyError, exp_err_msg)
|
|
96
|
+
"type" => described_class::IIIF_IMAGE_V2_TYPE,
|
|
97
|
+
"nope" => id_uri,
|
|
98
|
+
"profile" => described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE
|
|
99
|
+
})
|
|
100
|
+
exp_err_msg = "id or @id values are required for IIIF::V3::Presentation::Service with type or @type ImageService2"
|
|
101
|
+
expect { service_obj.validate }.to raise_error(IIIF::V3::Presentation::MissingRequiredKeyError, exp_err_msg)
|
|
103
102
|
end
|
|
104
|
-
it
|
|
103
|
+
it "should have a profile" do
|
|
105
104
|
service_obj = described_class.new({
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
exp_err_msg =
|
|
110
|
-
expect{service_obj.validate}.to raise_error(IIIF::V3::Presentation::MissingRequiredKeyError, exp_err_msg)
|
|
105
|
+
"@type" => described_class::IIIF_IMAGE_V2_TYPE,
|
|
106
|
+
"@id" => id_uri
|
|
107
|
+
})
|
|
108
|
+
exp_err_msg = "profile should be present for IIIF::V3::Presentation::Service with type or @type ImageService2"
|
|
109
|
+
expect { service_obj.validate }.to raise_error(IIIF::V3::Presentation::MissingRequiredKeyError, exp_err_msg)
|
|
111
110
|
end
|
|
112
111
|
it 'should have matching values for "@id" and "id" if both are specified' do
|
|
113
112
|
service_obj = described_class.new({
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
exp_err_msg =
|
|
120
|
-
expect{service_obj.validate}.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_err_msg)
|
|
113
|
+
"@type" => described_class::IIIF_IMAGE_V2_TYPE,
|
|
114
|
+
"@id" => id_uri,
|
|
115
|
+
"id" => "#{id_uri}/foo",
|
|
116
|
+
"profile" => described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE
|
|
117
|
+
})
|
|
118
|
+
exp_err_msg = "id and @id values must match for IIIF::V3::Presentation::Service with type or @type ImageService2"
|
|
119
|
+
expect { service_obj.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_err_msg)
|
|
121
120
|
end
|
|
122
121
|
end
|
|
123
122
|
end
|
|
124
123
|
|
|
125
|
-
describe
|
|
126
|
-
describe
|
|
127
|
-
it
|
|
124
|
+
describe "realistic examples" do
|
|
125
|
+
describe "from Stanford purl manifests" do
|
|
126
|
+
it "iiif image v2 service" do
|
|
128
127
|
service_obj = described_class.new({
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
"type" => described_class::IIIF_IMAGE_V2_TYPE,
|
|
129
|
+
"id" => id_uri,
|
|
130
|
+
"@id" => id_uri,
|
|
131
|
+
"profile" => described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE
|
|
133
132
|
})
|
|
134
|
-
expect{service_obj.validate}.not_to raise_error
|
|
133
|
+
expect { service_obj.validate }.not_to raise_error
|
|
135
134
|
expect(service_obj.keys.size).to eq 4
|
|
136
|
-
expect(service_obj.keys).to include(
|
|
137
|
-
expect(service_obj[
|
|
138
|
-
expect(service_obj[
|
|
139
|
-
expect(service_obj[
|
|
140
|
-
expect(service_obj[
|
|
135
|
+
expect(service_obj.keys).to include("type", "@id", "id", "profile")
|
|
136
|
+
expect(service_obj["type"]).to eq described_class::IIIF_IMAGE_V2_TYPE
|
|
137
|
+
expect(service_obj["id"]).to eq id_uri
|
|
138
|
+
expect(service_obj["@id"]).to eq id_uri
|
|
139
|
+
expect(service_obj["profile"]).to eq described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE
|
|
141
140
|
end
|
|
142
|
-
it
|
|
141
|
+
it "login service" do
|
|
143
142
|
token_service = described_class.new({
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
"id" => "https://example.org/image/iiif/token",
|
|
144
|
+
"profile" => described_class::IIIF_AUTHENTICATION_V1_TOKEN_PROFILE
|
|
146
145
|
})
|
|
147
|
-
expect{token_service.validate}.not_to raise_error
|
|
146
|
+
expect { token_service.validate }.not_to raise_error
|
|
148
147
|
expect(token_service.class).to eq described_class
|
|
149
148
|
expect(token_service.keys.size).to eq 2
|
|
150
|
-
expect(token_service.keys).to include(
|
|
151
|
-
expect(token_service[
|
|
152
|
-
expect(token_service[
|
|
149
|
+
expect(token_service.keys).to include("id", "profile")
|
|
150
|
+
expect(token_service["id"]).to eq "https://example.org/image/iiif/token"
|
|
151
|
+
expect(token_service["profile"]).to eq described_class::IIIF_AUTHENTICATION_V1_TOKEN_PROFILE
|
|
153
152
|
service_obj = described_class.new(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
153
|
+
"id" => "https://example.org/auth/iiif",
|
|
154
|
+
"profile" => described_class::IIIF_AUTHENTICATION_V1_LOGIN_PROFILE,
|
|
155
|
+
"label" => "label value",
|
|
156
|
+
"service" => [token_service]
|
|
158
157
|
)
|
|
159
|
-
expect{service_obj.validate}.not_to raise_error
|
|
158
|
+
expect { service_obj.validate }.not_to raise_error
|
|
160
159
|
expect(service_obj.keys.size).to eq 4
|
|
161
|
-
expect(service_obj.keys).to include(
|
|
162
|
-
expect(service_obj[
|
|
163
|
-
expect(service_obj[
|
|
164
|
-
expect(service_obj[
|
|
165
|
-
inner_service = service_obj[
|
|
160
|
+
expect(service_obj.keys).to include("id", "profile", "label", "service")
|
|
161
|
+
expect(service_obj["id"]).to eq "https://example.org/auth/iiif"
|
|
162
|
+
expect(service_obj["profile"]).to eq described_class::IIIF_AUTHENTICATION_V1_LOGIN_PROFILE
|
|
163
|
+
expect(service_obj["label"]).to eq "label value"
|
|
164
|
+
inner_service = service_obj["service"][0]
|
|
166
165
|
expect(inner_service.class).to eq described_class
|
|
167
|
-
expect{inner_service.validate}.not_to raise_error
|
|
166
|
+
expect { inner_service.validate }.not_to raise_error
|
|
168
167
|
expect(inner_service.keys.size).to eq 2
|
|
169
|
-
expect(inner_service.keys).to include(
|
|
170
|
-
expect(inner_service[
|
|
171
|
-
expect(inner_service[
|
|
168
|
+
expect(inner_service.keys).to include("id", "profile")
|
|
169
|
+
expect(inner_service["id"]).to eq "https://example.org/image/iiif/token"
|
|
170
|
+
expect(inner_service["profile"]).to eq described_class::IIIF_AUTHENTICATION_V1_TOKEN_PROFILE
|
|
172
171
|
end
|
|
173
|
-
it
|
|
172
|
+
it "triply nested service" do
|
|
174
173
|
inner = described_class.new({
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
expect{inner.validate}.not_to raise_error
|
|
174
|
+
"id" => "https://example.org/image/iiif/token",
|
|
175
|
+
"profile" => described_class::IIIF_AUTHENTICATION_V1_TOKEN_PROFILE
|
|
176
|
+
})
|
|
177
|
+
expect { inner.validate }.not_to raise_error
|
|
179
178
|
middle = described_class.new({
|
|
180
179
|
"id" => "https://example.org/auth/iiif",
|
|
181
180
|
"profile" => described_class::IIIF_AUTHENTICATION_V1_LOGIN_PROFILE,
|
|
182
181
|
"label" => "Stanford-affiliated? Login to view",
|
|
183
182
|
"service" => [inner]
|
|
184
|
-
|
|
185
|
-
expect{middle.validate}.not_to raise_error
|
|
183
|
+
})
|
|
184
|
+
expect { middle.validate }.not_to raise_error
|
|
186
185
|
outer = described_class.new({
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
expect{outer.validate}.not_to raise_error
|
|
186
|
+
"@type" => described_class::IIIF_IMAGE_V2_TYPE,
|
|
187
|
+
"@id" => "https://example.org/iiif/yy816tv6021_img_1",
|
|
188
|
+
"id" => "https://example.org/iiif/yy816tv6021_img_1",
|
|
189
|
+
"profile" => described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE,
|
|
190
|
+
"service" => [middle]
|
|
191
|
+
})
|
|
192
|
+
expect { outer.validate }.not_to raise_error
|
|
194
193
|
end
|
|
195
194
|
end
|
|
196
|
-
describe
|
|
197
|
-
it
|
|
195
|
+
describe "example from http://prezi3.iiif.io/api/presentation/3.0" do
|
|
196
|
+
it "iiif image v2" do
|
|
198
197
|
service_obj = described_class.new({
|
|
199
198
|
"type" => described_class::IIIF_IMAGE_V2_TYPE,
|
|
200
199
|
"id" => "http://example.org/images/book1-page2",
|
|
@@ -202,16 +201,16 @@ describe IIIF::V3::Presentation::Service do
|
|
|
202
201
|
"profile" => "http://iiif.io/api/image/2/level1.json",
|
|
203
202
|
"height" => 8000,
|
|
204
203
|
"width" => 6000,
|
|
205
|
-
"tiles" => [{"width" => 512, "scaleFactors" => [1,2,4,8,16]}]
|
|
204
|
+
"tiles" => [{"width" => 512, "scaleFactors" => [1, 2, 4, 8, 16]}]
|
|
206
205
|
})
|
|
207
206
|
expect(service_obj.keys.size).to eq 7
|
|
208
|
-
expect(service_obj[
|
|
209
|
-
expect(service_obj[
|
|
210
|
-
expect(service_obj[
|
|
211
|
-
expect(service_obj[
|
|
212
|
-
expect(service_obj[
|
|
213
|
-
expect(service_obj[
|
|
214
|
-
expect(service_obj[
|
|
207
|
+
expect(service_obj["type"]).to eq described_class::IIIF_IMAGE_V2_TYPE
|
|
208
|
+
expect(service_obj["id"]).to eq "http://example.org/images/book1-page2"
|
|
209
|
+
expect(service_obj["@id"]).to eq "http://example.org/images/book1-page2"
|
|
210
|
+
expect(service_obj["profile"]).to eq described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE
|
|
211
|
+
expect(service_obj["height"]).to eq 8000
|
|
212
|
+
expect(service_obj["width"]).to eq 6000
|
|
213
|
+
expect(service_obj["tiles"]).to eq [{"width" => 512, "scaleFactors" => [1, 2, 4, 8, 16]}]
|
|
215
214
|
# TODO: note that this won't validate because "height is a prohibited key in IIIF::V3::Presentation::Service"
|
|
216
215
|
# expect{service_obj.validate}.not_to raise_error
|
|
217
216
|
end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
shared_examples
|
|
2
|
-
|
|
1
|
+
shared_examples "it has the appropriate methods for abstract_resource_only_keys v3" do
|
|
3
2
|
described_class.new.abstract_resource_only_keys.each do |entry|
|
|
4
|
-
|
|
5
3
|
describe "#{entry[:key]}=" do
|
|
6
4
|
it "sets #{entry[:key]}" do
|
|
7
5
|
@ex = entry[:type].new
|
|
@@ -17,11 +15,11 @@ shared_examples 'it has the appropriate methods for abstract_resource_only_keys
|
|
|
17
15
|
end
|
|
18
16
|
it "raises an exception when attempting to set it to something other than an #{entry[:type]}" do
|
|
19
17
|
e = IIIF::V3::Presentation::IllegalValueError
|
|
20
|
-
expect { subject.send("#{entry[:key]}=",
|
|
18
|
+
expect { subject.send("#{entry[:key]}=", "Foo") }.to raise_error e
|
|
21
19
|
end
|
|
22
20
|
end
|
|
23
21
|
|
|
24
|
-
describe
|
|
22
|
+
describe entry[:key].to_s do
|
|
25
23
|
it "gets #{entry[:key]}" do
|
|
26
24
|
@ex = entry[:type].new
|
|
27
25
|
subject[entry[:key]] = @ex
|
|
@@ -31,11 +29,9 @@ shared_examples 'it has the appropriate methods for abstract_resource_only_keys
|
|
|
31
29
|
it "is aliased as ##{entry[:key].camelize(:lower)}" do
|
|
32
30
|
@ex = entry[:type].new
|
|
33
31
|
subject[entry[:key]] = @ex
|
|
34
|
-
expect(subject.send(
|
|
32
|
+
expect(subject.send(entry[:key].camelize(:lower).to_s)).to eq @ex
|
|
35
33
|
end
|
|
36
34
|
end
|
|
37
35
|
end
|
|
38
|
-
|
|
39
36
|
end
|
|
40
|
-
|
|
41
37
|
end
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
shared_examples
|
|
2
|
-
|
|
1
|
+
shared_examples "it has the appropriate methods for any-type keys v3" do
|
|
3
2
|
described_class.new.any_type_keys.each do |prop|
|
|
4
3
|
describe "##{prop}=" do
|
|
5
4
|
it "sets self['#{prop}']" do
|
|
@@ -16,16 +15,15 @@ shared_examples 'it has the appropriate methods for any-type keys v3' do
|
|
|
16
15
|
|
|
17
16
|
describe "##{prop}" do
|
|
18
17
|
it "gets self[#{prop}]" do
|
|
19
|
-
subject.send(
|
|
20
|
-
expect(subject.send(
|
|
18
|
+
subject.send(:[]=, prop, fixed_values[prop])
|
|
19
|
+
expect(subject.send(prop.to_s)).to eq fixed_values[prop]
|
|
21
20
|
end
|
|
22
21
|
if prop.camelize(:lower) != prop
|
|
23
22
|
it "is aliased as ##{prop.camelize(:lower)}" do
|
|
24
|
-
subject.send(
|
|
25
|
-
expect(subject.send(
|
|
23
|
+
subject.send(:[]=, prop, fixed_values[prop])
|
|
24
|
+
expect(subject.send(prop.camelize(:lower).to_s)).to eq fixed_values[prop]
|
|
26
25
|
end
|
|
27
26
|
end
|
|
28
27
|
end
|
|
29
28
|
end
|
|
30
|
-
|
|
31
29
|
end
|
|
@@ -1,40 +1,36 @@
|
|
|
1
|
-
shared_examples
|
|
2
|
-
|
|
1
|
+
shared_examples "it has the appropriate methods for array-only keys v3" do
|
|
3
2
|
described_class.new.array_only_keys.each do |prop|
|
|
4
|
-
|
|
5
3
|
describe "#{prop}=" do
|
|
6
4
|
it "sets #{prop}" do
|
|
7
|
-
ex = [{
|
|
5
|
+
ex = [{"label" => "XYZ"}]
|
|
8
6
|
subject.send("#{prop}=", ex)
|
|
9
7
|
expect(subject[prop]).to eq ex
|
|
10
8
|
end
|
|
11
9
|
if prop.camelize(:lower) != prop
|
|
12
10
|
it "is aliased as ##{prop.camelize(:lower)}=" do
|
|
13
|
-
ex = [{
|
|
11
|
+
ex = [{"label" => "XYZ"}]
|
|
14
12
|
subject.send("#{prop.camelize(:lower)}=", ex)
|
|
15
13
|
expect(subject[prop]).to eq ex
|
|
16
14
|
end
|
|
17
15
|
end
|
|
18
|
-
it
|
|
19
|
-
expect { subject.send("#{prop}=",
|
|
16
|
+
it "raises an exception when attempting to set it to something other than an Array" do
|
|
17
|
+
expect { subject.send("#{prop}=", "Foo") }.to raise_error IIIF::V3::Presentation::IllegalValueError
|
|
20
18
|
end
|
|
21
19
|
end
|
|
22
20
|
|
|
23
|
-
describe
|
|
21
|
+
describe prop.to_s do
|
|
24
22
|
it "gets #{prop}" do
|
|
25
|
-
ex = [{
|
|
23
|
+
ex = [{"label" => "XYZ"}]
|
|
26
24
|
subject[prop] = ex
|
|
27
25
|
expect(subject.send(prop)).to eq ex
|
|
28
26
|
end
|
|
29
27
|
if prop.camelize(:lower) != prop
|
|
30
28
|
it "is aliased as ##{prop.camelize(:lower)}" do
|
|
31
|
-
ex = [{
|
|
29
|
+
ex = [{"label" => "XYZ"}]
|
|
32
30
|
subject[prop] = ex
|
|
33
|
-
expect(subject.send(
|
|
31
|
+
expect(subject.send(prop.camelize(:lower).to_s)).to eq ex
|
|
34
32
|
end
|
|
35
33
|
end
|
|
36
34
|
end
|
|
37
|
-
|
|
38
35
|
end
|
|
39
|
-
|
|
40
36
|
end
|
|
@@ -1,40 +1,36 @@
|
|
|
1
|
-
shared_examples
|
|
2
|
-
|
|
1
|
+
shared_examples "it has the appropriate methods for hash-only keys v3" do
|
|
3
2
|
described_class.new.hash_only_keys.each do |prop|
|
|
4
|
-
|
|
5
3
|
describe "#{prop}=" do
|
|
6
4
|
it "sets #{prop}" do
|
|
7
|
-
ex = {
|
|
5
|
+
ex = {"label" => "XYZ", "fooBar" => "bar"}
|
|
8
6
|
subject.send("#{prop}=", ex)
|
|
9
7
|
expect(subject[prop]).to eq ex
|
|
10
8
|
end
|
|
11
9
|
if prop.camelize(:lower) != prop
|
|
12
10
|
it "is aliased as ##{prop.camelize(:lower)}=" do
|
|
13
|
-
ex = {
|
|
11
|
+
ex = {"label" => "XYZ"}
|
|
14
12
|
subject.send("#{prop.camelize(:lower)}=", ex)
|
|
15
13
|
expect(subject[prop]).to eq ex
|
|
16
14
|
end
|
|
17
15
|
end
|
|
18
|
-
it
|
|
19
|
-
expect { subject.send("#{prop}=", [
|
|
16
|
+
it "raises an exception when attempting to set it to something other than a Hash" do
|
|
17
|
+
expect { subject.send("#{prop}=", ["Foo"]) }.to raise_error IIIF::V3::Presentation::IllegalValueError
|
|
20
18
|
end
|
|
21
19
|
end
|
|
22
20
|
|
|
23
|
-
describe
|
|
21
|
+
describe prop.to_s do
|
|
24
22
|
it "gets #{prop}" do
|
|
25
|
-
ex = {
|
|
23
|
+
ex = {"label" => "XYZ", "fooBar" => "bar"}
|
|
26
24
|
subject[prop] = ex
|
|
27
25
|
expect(subject.send(prop)).to eq ex
|
|
28
26
|
end
|
|
29
27
|
if prop.camelize(:lower) != prop
|
|
30
28
|
it "is aliased as ##{prop.camelize(:lower)}" do
|
|
31
|
-
ex = {
|
|
29
|
+
ex = {"fooBar" => "bar"}
|
|
32
30
|
subject[prop] = ex
|
|
33
|
-
expect(subject.send(
|
|
31
|
+
expect(subject.send(prop.camelize(:lower).to_s)).to eq ex
|
|
34
32
|
end
|
|
35
33
|
end
|
|
36
34
|
end
|
|
37
|
-
|
|
38
35
|
end
|
|
39
|
-
|
|
40
36
|
end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
shared_examples
|
|
2
|
-
|
|
1
|
+
shared_examples "it has the appropriate methods for integer-only keys v3" do
|
|
3
2
|
described_class.new.int_only_keys.each do |prop|
|
|
4
|
-
|
|
5
3
|
describe "#{prop}=" do
|
|
6
4
|
before(:all) do
|
|
7
5
|
@ex = 7200
|
|
@@ -16,15 +14,15 @@ shared_examples 'it has the appropriate methods for integer-only keys v3' do
|
|
|
16
14
|
expect(subject[prop]).to eq @ex
|
|
17
15
|
end
|
|
18
16
|
end
|
|
19
|
-
it
|
|
20
|
-
expect { subject.send("#{prop}=",
|
|
17
|
+
it "raises an exception when attempting to set it to something other than an Integer" do
|
|
18
|
+
expect { subject.send("#{prop}=", "Foo") }.to raise_error IIIF::V3::Presentation::IllegalValueError
|
|
21
19
|
end
|
|
22
|
-
it
|
|
20
|
+
it "raises an exception when attempting to set it to a negative number" do
|
|
23
21
|
expect { subject.send("#{prop}=", -1) }.to raise_error IIIF::V3::Presentation::IllegalValueError
|
|
24
22
|
end
|
|
25
23
|
end
|
|
26
24
|
|
|
27
|
-
describe
|
|
25
|
+
describe prop.to_s do
|
|
28
26
|
before(:all) do
|
|
29
27
|
@ex = 7200
|
|
30
28
|
end
|
|
@@ -35,11 +33,9 @@ shared_examples 'it has the appropriate methods for integer-only keys v3' do
|
|
|
35
33
|
if prop.camelize(:lower) != prop
|
|
36
34
|
it "is aliased as ##{prop.camelize(:lower)}" do
|
|
37
35
|
subject[prop] = @ex
|
|
38
|
-
expect(subject.send(
|
|
36
|
+
expect(subject.send(prop.camelize(:lower).to_s)).to eq @ex
|
|
39
37
|
end
|
|
40
38
|
end
|
|
41
39
|
end
|
|
42
|
-
|
|
43
40
|
end
|
|
44
|
-
|
|
45
41
|
end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
shared_examples
|
|
2
|
-
|
|
1
|
+
shared_examples "it has the appropriate methods for numeric-only keys v3" do
|
|
3
2
|
described_class.new.numeric_only_keys.each do |prop|
|
|
4
|
-
|
|
5
3
|
describe "#{prop}=" do
|
|
6
4
|
before(:all) do
|
|
7
5
|
@ex = 7200.0
|
|
@@ -16,15 +14,15 @@ shared_examples 'it has the appropriate methods for numeric-only keys v3' do
|
|
|
16
14
|
expect(subject[prop]).to eq @ex
|
|
17
15
|
end
|
|
18
16
|
end
|
|
19
|
-
it
|
|
20
|
-
expect { subject.send("#{prop}=",
|
|
17
|
+
it "raises an exception when attempting to set it to something other than an Integer" do
|
|
18
|
+
expect { subject.send("#{prop}=", "Foo") }.to raise_error IIIF::V3::Presentation::IllegalValueError
|
|
21
19
|
end
|
|
22
|
-
it
|
|
20
|
+
it "raises an exception when attempting to set it to a negative number" do
|
|
23
21
|
expect { subject.send("#{prop}=", -1.0) }.to raise_error IIIF::V3::Presentation::IllegalValueError
|
|
24
22
|
end
|
|
25
23
|
end
|
|
26
24
|
|
|
27
|
-
describe
|
|
25
|
+
describe prop.to_s do
|
|
28
26
|
before(:all) do
|
|
29
27
|
@ex = 7200.0
|
|
30
28
|
end
|
|
@@ -35,11 +33,9 @@ shared_examples 'it has the appropriate methods for numeric-only keys v3' do
|
|
|
35
33
|
if prop.camelize(:lower) != prop
|
|
36
34
|
it "is aliased as ##{prop.camelize(:lower)}" do
|
|
37
35
|
subject[prop] = @ex
|
|
38
|
-
expect(subject.send(
|
|
36
|
+
expect(subject.send(prop.camelize(:lower).to_s)).to eq @ex
|
|
39
37
|
end
|
|
40
38
|
end
|
|
41
39
|
end
|
|
42
|
-
|
|
43
40
|
end
|
|
44
|
-
|
|
45
41
|
end
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
shared_examples
|
|
2
|
-
|
|
1
|
+
shared_examples "it has the appropriate methods for string-only keys v3" do
|
|
3
2
|
described_class.new.string_only_keys.each do |prop|
|
|
4
|
-
|
|
5
3
|
describe "#{prop}=" do
|
|
6
4
|
it "sets #{prop}" do
|
|
7
|
-
ex =
|
|
5
|
+
ex = "foo"
|
|
8
6
|
subject.send("#{prop}=", ex)
|
|
9
7
|
expect(subject[prop]).to eq ex
|
|
10
8
|
end
|
|
11
|
-
it
|
|
12
|
-
expect { subject.send("#{prop}=", [
|
|
9
|
+
it "raises an exception when attempting to set it to something other than a String" do
|
|
10
|
+
expect { subject.send("#{prop}=", ["Foo"]) }.to raise_error IIIF::V3::Presentation::IllegalValueError
|
|
13
11
|
end
|
|
14
12
|
end
|
|
15
13
|
|
|
16
|
-
describe
|
|
14
|
+
describe prop.to_s do
|
|
17
15
|
it "gets #{prop}" do
|
|
18
|
-
ex =
|
|
16
|
+
ex = "bar"
|
|
19
17
|
subject[prop] = ex
|
|
20
18
|
expect(subject.send(prop)).to eq ex
|
|
21
19
|
end
|
|
22
20
|
end
|
|
23
|
-
|
|
24
21
|
end
|
|
25
|
-
|
|
26
22
|
end
|