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,119 +1,123 @@
|
|
|
1
1
|
describe IIIF::V3::Presentation::Choice do
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
it 'contains the expected key names' do
|
|
2
|
+
describe "#prohibited_keys" do
|
|
3
|
+
it "contains the expected key names" do
|
|
5
4
|
keys = described_class::PAGING_PROPERTIES +
|
|
6
5
|
described_class::CONTENT_RESOURCE_PROPERTIES +
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
%w[
|
|
7
|
+
nav_date
|
|
8
|
+
viewing_direction
|
|
9
|
+
start_canvas
|
|
10
|
+
content_annotations
|
|
11
|
+
]
|
|
12
|
+
expect(subject.prohibited_keys).to include(*keys)
|
|
13
|
+
end
|
|
15
14
|
end
|
|
16
15
|
|
|
17
|
-
describe
|
|
18
|
-
it
|
|
19
|
-
expect(subject.any_type_keys).to include(
|
|
16
|
+
describe "#any_type_keys" do
|
|
17
|
+
it "default" do
|
|
18
|
+
expect(subject.any_type_keys).to include("default")
|
|
20
19
|
end
|
|
21
20
|
end
|
|
22
21
|
|
|
23
|
-
describe
|
|
24
|
-
it
|
|
25
|
-
expect(subject.string_only_keys).to include(
|
|
22
|
+
describe "#string_only_keys" do
|
|
23
|
+
it "choice_hint" do
|
|
24
|
+
expect(subject.string_only_keys).to include("choice_hint")
|
|
26
25
|
end
|
|
27
26
|
end
|
|
28
27
|
|
|
29
|
-
describe
|
|
30
|
-
it
|
|
31
|
-
expect(subject.array_only_keys).to include(
|
|
28
|
+
describe "#array_only_keys" do
|
|
29
|
+
it "items" do
|
|
30
|
+
expect(subject.array_only_keys).to include("items")
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
33
|
|
|
35
|
-
describe
|
|
36
|
-
it
|
|
37
|
-
expect(subject.legal_choice_hint_values).to contain_exactly(
|
|
34
|
+
describe "#legal_choice_hint_values" do
|
|
35
|
+
it "contains the expected values" do
|
|
36
|
+
expect(subject.legal_choice_hint_values).to contain_exactly("client", "user")
|
|
38
37
|
end
|
|
39
38
|
end
|
|
40
39
|
|
|
41
|
-
describe
|
|
42
|
-
it
|
|
43
|
-
expect(subject.legal_viewing_hint_values).to contain_exactly(
|
|
40
|
+
describe "#legal_viewing_hint_values" do
|
|
41
|
+
it "contains none" do
|
|
42
|
+
expect(subject.legal_viewing_hint_values).to contain_exactly("none")
|
|
44
43
|
end
|
|
45
44
|
end
|
|
46
45
|
|
|
47
|
-
describe
|
|
48
|
-
it
|
|
49
|
-
expect(subject[
|
|
46
|
+
describe "#initialize" do
|
|
47
|
+
it "sets type to Choice by default" do
|
|
48
|
+
expect(subject["type"]).to eq "Choice"
|
|
50
49
|
end
|
|
51
|
-
it
|
|
50
|
+
it "allows subclasses to override type" do
|
|
52
51
|
subclass = Class.new(described_class) do
|
|
53
|
-
def initialize(
|
|
54
|
-
|
|
55
|
-
super(hsh)
|
|
52
|
+
def initialize(_hsh = {})
|
|
53
|
+
super({"type" => "a:SubClass"})
|
|
56
54
|
end
|
|
57
55
|
end
|
|
58
56
|
sub = subclass.new
|
|
59
|
-
expect(sub[
|
|
57
|
+
expect(sub["type"]).to eq "a:SubClass"
|
|
60
58
|
end
|
|
61
|
-
it
|
|
62
|
-
my_choice = described_class.new(
|
|
63
|
-
expect(my_choice.type).to eq
|
|
59
|
+
it "allows type to be passed in" do
|
|
60
|
+
my_choice = described_class.new("type" => "bar")
|
|
61
|
+
expect(my_choice.type).to eq "bar"
|
|
64
62
|
end
|
|
65
63
|
end
|
|
66
64
|
|
|
67
|
-
describe
|
|
68
|
-
it
|
|
65
|
+
describe "#validate" do
|
|
66
|
+
it "raises an IllegalValueError if choice_hint isn't an allowable value" do
|
|
69
67
|
exp_err_msg = "choiceHint for #{described_class} must be one of [\"client\", \"user\"]."
|
|
70
|
-
subject[
|
|
68
|
+
subject["choice_hint"] = "foo"
|
|
71
69
|
expect { subject.validate }.to raise_error IIIF::V3::Presentation::IllegalValueError, exp_err_msg
|
|
72
70
|
end
|
|
73
71
|
end
|
|
74
72
|
|
|
75
|
-
describe
|
|
76
|
-
describe
|
|
77
|
-
let(:item_type) {
|
|
78
|
-
let(:item1_id) {
|
|
79
|
-
let(:item1_mime) {
|
|
80
|
-
let(:item1_res) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
let(:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
73
|
+
describe "realistic examples" do
|
|
74
|
+
describe "from digerati" do
|
|
75
|
+
let(:item_type) { "Video" }
|
|
76
|
+
let(:item1_id) { "http://example.org/foo.mp4f" }
|
|
77
|
+
let(:item1_mime) { "video/mp4" }
|
|
78
|
+
let(:item1_res) {
|
|
79
|
+
IIIF::V3::Presentation::Resource.new(
|
|
80
|
+
"id" => item1_id,
|
|
81
|
+
"type" => item_type,
|
|
82
|
+
"format" => item1_mime
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
let(:item2_id) { "http://example.org/foo.webm" }
|
|
86
|
+
let(:item2_mime) { "video/webm" }
|
|
87
|
+
let(:item2_res) {
|
|
88
|
+
IIIF::V3::Presentation::Resource.new(
|
|
89
|
+
"id" => item2_id,
|
|
90
|
+
"type" => item_type,
|
|
91
|
+
"format" => item2_mime
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
let(:choice) {
|
|
95
|
+
IIIF::V3::Presentation::Choice.new(
|
|
96
|
+
"choiceHint" => "client",
|
|
97
|
+
"items" => [item1_res, item2_res]
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
it "validates" do
|
|
101
|
+
expect { choice.validate }.not_to raise_error
|
|
98
102
|
end
|
|
99
|
-
it
|
|
100
|
-
expect(choice[
|
|
103
|
+
it "has expected required values" do
|
|
104
|
+
expect(choice["type"]).to eq "Choice"
|
|
101
105
|
end
|
|
102
|
-
it
|
|
106
|
+
it "has expected additional values" do
|
|
103
107
|
expect(choice.id).to be_nil
|
|
104
|
-
expect(choice[
|
|
105
|
-
expect(choice.choiceHint).to eq
|
|
106
|
-
expect(choice[
|
|
107
|
-
first = choice[
|
|
108
|
+
expect(choice["choice_hint"]).to eq "client"
|
|
109
|
+
expect(choice.choiceHint).to eq "client"
|
|
110
|
+
expect(choice["items"]).to eq [item1_res, item2_res]
|
|
111
|
+
first = choice["items"].first
|
|
108
112
|
expect(first.keys.size).to eq 3
|
|
109
|
-
expect(first[
|
|
110
|
-
expect(first[
|
|
111
|
-
expect(first[
|
|
112
|
-
second = choice[
|
|
113
|
+
expect(first["id"]).to eq item1_id
|
|
114
|
+
expect(first["type"]).to eq item_type
|
|
115
|
+
expect(first["format"]).to eq item1_mime
|
|
116
|
+
second = choice["items"].last
|
|
113
117
|
expect(second.keys.size).to eq 3
|
|
114
|
-
expect(second[
|
|
115
|
-
expect(second[
|
|
116
|
-
expect(second[
|
|
118
|
+
expect(second["id"]).to eq item2_id
|
|
119
|
+
expect(second["type"]).to eq item_type
|
|
120
|
+
expect(second["format"]).to eq item2_mime
|
|
117
121
|
end
|
|
118
122
|
end
|
|
119
123
|
end
|
|
@@ -1,55 +1,50 @@
|
|
|
1
1
|
describe IIIF::V3::Presentation::Collection do
|
|
2
|
-
|
|
3
2
|
let(:fixed_values) do
|
|
4
3
|
{
|
|
5
4
|
"@context" => [
|
|
6
5
|
"http://iiif.io/api/presentation/3/context.json",
|
|
7
6
|
"http://www.w3.org/ns/anno.jsonld"
|
|
8
7
|
],
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
'label' => 'Sub Collection 2'
|
|
23
|
-
}
|
|
8
|
+
"id" => "http://example.org/iiif/collection/top",
|
|
9
|
+
"type" => "Collection",
|
|
10
|
+
"label" => "Top Level Collection for Example Organization",
|
|
11
|
+
"description" => "Description of Collection",
|
|
12
|
+
"attribution" => "Provided by Example Organization",
|
|
13
|
+
|
|
14
|
+
"collections" => [
|
|
15
|
+
{"id" => "http://example.org/iiif/collection/part1",
|
|
16
|
+
"type" => "Collection",
|
|
17
|
+
"label" => "Sub Collection 1"},
|
|
18
|
+
{"id" => "http://example.org/iiif/collection/part2",
|
|
19
|
+
"type" => "Collection",
|
|
20
|
+
"label" => "Sub Collection 2"}
|
|
24
21
|
],
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
22
|
+
"manifests" => [
|
|
23
|
+
{"id" => "http://example.org/iiif/book1/manifest",
|
|
24
|
+
"type" => "Manifest",
|
|
25
|
+
"label" => "Book 1"}
|
|
30
26
|
]
|
|
31
27
|
}
|
|
32
28
|
end
|
|
33
29
|
|
|
34
|
-
describe
|
|
35
|
-
it
|
|
36
|
-
expect(subject[
|
|
30
|
+
describe "#initialize" do
|
|
31
|
+
it "sets type to Collection by default" do
|
|
32
|
+
expect(subject["type"]).to eq "Collection"
|
|
37
33
|
end
|
|
38
34
|
end
|
|
39
35
|
|
|
40
36
|
describe "#{described_class}.define_methods_for_array_only_keys" do
|
|
41
|
-
it_behaves_like
|
|
37
|
+
it_behaves_like "it has the appropriate methods for array-only keys v3"
|
|
42
38
|
end
|
|
43
39
|
|
|
44
40
|
describe "#{described_class}.define_methods_for_string_only_keys" do
|
|
45
|
-
it_behaves_like
|
|
41
|
+
it_behaves_like "it has the appropriate methods for string-only keys v3"
|
|
46
42
|
end
|
|
47
43
|
|
|
48
44
|
describe "#{described_class}.define_methods_for_any_type_keys" do
|
|
49
|
-
it_behaves_like
|
|
45
|
+
it_behaves_like "it has the appropriate methods for any-type keys v3"
|
|
50
46
|
end
|
|
51
47
|
|
|
52
|
-
describe
|
|
48
|
+
describe "#validate" do
|
|
53
49
|
end
|
|
54
|
-
|
|
55
50
|
end
|
|
@@ -1,155 +1,154 @@
|
|
|
1
1
|
describe IIIF::V3::Presentation::ImageResource do
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
expect(subject['type']).to eq 'Image'
|
|
2
|
+
describe "#initialize" do
|
|
3
|
+
it "sets type to Image" do
|
|
4
|
+
expect(subject["type"]).to eq "Image"
|
|
6
5
|
end
|
|
7
6
|
end
|
|
8
7
|
|
|
9
|
-
describe
|
|
10
|
-
let(:img_id) {
|
|
8
|
+
describe "realistic examples" do
|
|
9
|
+
let(:img_id) { "https://example.org/image/iiif/abc666" }
|
|
11
10
|
let(:image_v2_service) {
|
|
12
11
|
IIIF::V3::Presentation::Service.new(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
"@context" => "http://iiif.io/api/image/2/context.json",
|
|
13
|
+
"@id" => img_id,
|
|
14
|
+
"id" => img_id,
|
|
15
|
+
"profile" => "http://iiif.io/api/image/2/level1.json"
|
|
17
16
|
)
|
|
18
17
|
}
|
|
19
|
-
let(:img_mimetype) {
|
|
18
|
+
let(:img_mimetype) { "image/jpeg" }
|
|
20
19
|
let(:width) { 999 }
|
|
21
20
|
let(:height) { 666 }
|
|
22
|
-
describe
|
|
23
|
-
describe
|
|
21
|
+
describe "stanford" do
|
|
22
|
+
describe "thumbnail per purl code" do
|
|
24
23
|
let(:thumb_id) { "#{img_id}/full/!400,400/0/default.jpg" }
|
|
25
24
|
let(:thumb_object) {
|
|
26
25
|
thumb = IIIF::V3::Presentation::ImageResource.new
|
|
27
|
-
thumb[
|
|
28
|
-
thumb[
|
|
26
|
+
thumb["type"] = "Image"
|
|
27
|
+
thumb["id"] = thumb_id
|
|
29
28
|
thumb.format = img_mimetype
|
|
30
29
|
thumb.service = [image_v2_service]
|
|
31
30
|
thumb
|
|
32
31
|
}
|
|
33
|
-
it
|
|
34
|
-
expect{thumb_object.validate}.not_to raise_error
|
|
32
|
+
it "validates" do
|
|
33
|
+
expect { thumb_object.validate }.not_to raise_error
|
|
35
34
|
end
|
|
36
|
-
it
|
|
37
|
-
expect(thumb_object.type).to eq
|
|
35
|
+
it "has expected required values" do
|
|
36
|
+
expect(thumb_object.type).to eq "Image"
|
|
38
37
|
expect(thumb_object.id).to eq thumb_id
|
|
39
38
|
end
|
|
40
|
-
it
|
|
39
|
+
it "has expected additional values" do
|
|
41
40
|
expect(thumb_object.format).to eq img_mimetype
|
|
42
41
|
expect(thumb_object.service.first).to eq image_v2_service
|
|
43
42
|
end
|
|
44
43
|
end
|
|
45
|
-
describe
|
|
44
|
+
describe "full size per purl code" do
|
|
46
45
|
let(:full_id) { "#{img_id}/full/full/0/default.jpg" }
|
|
47
46
|
let(:image_object) {
|
|
48
47
|
img = IIIF::V3::Presentation::ImageResource.new
|
|
49
|
-
img[
|
|
48
|
+
img["id"] = full_id
|
|
50
49
|
img.format = img_mimetype
|
|
51
50
|
img.height = height
|
|
52
51
|
img.width = width
|
|
53
52
|
img.service = [image_v2_service]
|
|
54
53
|
img
|
|
55
54
|
}
|
|
56
|
-
describe
|
|
57
|
-
it
|
|
58
|
-
expect{image_object.validate}.not_to raise_error
|
|
55
|
+
describe "world visible" do
|
|
56
|
+
it "validates" do
|
|
57
|
+
expect { image_object.validate }.not_to raise_error
|
|
59
58
|
end
|
|
60
|
-
it
|
|
61
|
-
expect(image_object.type).to eq
|
|
59
|
+
it "has expected required values" do
|
|
60
|
+
expect(image_object.type).to eq "Image"
|
|
62
61
|
expect(image_object.id).to eq full_id
|
|
63
62
|
end
|
|
64
|
-
it
|
|
63
|
+
it "has expected additional values" do
|
|
65
64
|
expect(image_object.format).to eq img_mimetype
|
|
66
65
|
expect(image_object.height).to eq height
|
|
67
66
|
expect(image_object.width).to eq width
|
|
68
67
|
expect(image_object.service.first).to eq image_v2_service
|
|
69
68
|
end
|
|
70
|
-
it
|
|
69
|
+
it "has expected service value" do
|
|
71
70
|
img_service_obj = image_object.service.first
|
|
72
71
|
expect(img_service_obj.class).to eq IIIF::V3::Presentation::Service
|
|
73
72
|
expect(img_service_obj.keys.size).to eq 4
|
|
74
73
|
expect(img_service_obj.id).to eq img_id
|
|
75
|
-
expect(img_service_obj[
|
|
74
|
+
expect(img_service_obj["@id"]).to eq img_id
|
|
76
75
|
expect(img_service_obj.profile).to eq IIIF::V3::Presentation::Service::IIIF_IMAGE_V2_LEVEL1_PROFILE
|
|
77
76
|
end
|
|
78
77
|
end
|
|
79
|
-
describe
|
|
80
|
-
let(:service_label) {
|
|
81
|
-
let(:token_service_id) {
|
|
78
|
+
describe "requires login" do
|
|
79
|
+
let(:service_label) { "login message" }
|
|
80
|
+
let(:token_service_id) { "https://example.org/iiif/token" }
|
|
82
81
|
let(:login_service) {
|
|
83
82
|
IIIF::V3::Presentation::Service.new(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
"id" => "https://example.org/auth/iiif",
|
|
84
|
+
"profile" => "http://iiif.io/api/auth/1/login",
|
|
85
|
+
"label" => service_label,
|
|
86
|
+
"service" => [{
|
|
87
|
+
"id" => token_service_id,
|
|
88
|
+
"profile" => "http://iiif.io/api/auth/1/token"
|
|
90
89
|
}]
|
|
91
90
|
)
|
|
92
91
|
}
|
|
93
92
|
let(:image_object_w_login) {
|
|
94
93
|
img = image_object
|
|
95
|
-
img.service.first[
|
|
94
|
+
img.service.first["service"] = [login_service]
|
|
96
95
|
img
|
|
97
96
|
}
|
|
98
|
-
it
|
|
99
|
-
expect{image_object_w_login.validate}.not_to raise_error
|
|
97
|
+
it "validates" do
|
|
98
|
+
expect { image_object_w_login.validate }.not_to raise_error
|
|
100
99
|
end
|
|
101
|
-
it
|
|
100
|
+
it "has expected service value" do
|
|
102
101
|
img_service_obj = image_object_w_login.service.first
|
|
103
102
|
expect(img_service_obj.class).to eq IIIF::V3::Presentation::Service
|
|
104
103
|
expect(img_service_obj.keys.size).to eq 5
|
|
105
104
|
expect(img_service_obj.id).to eq img_id
|
|
106
|
-
expect(img_service_obj[
|
|
105
|
+
expect(img_service_obj["@id"]).to eq img_id
|
|
107
106
|
expect(img_service_obj.profile).to eq IIIF::V3::Presentation::Service::IIIF_IMAGE_V2_LEVEL1_PROFILE
|
|
108
107
|
expect(img_service_obj.service.class).to eq Array
|
|
109
108
|
expect(img_service_obj.service.size).to eq 1
|
|
110
109
|
|
|
111
110
|
login_service_obj = img_service_obj.service.first
|
|
112
111
|
expect(login_service_obj.keys.size).to eq 4
|
|
113
|
-
expect(login_service.id).to eq
|
|
112
|
+
expect(login_service.id).to eq "https://example.org/auth/iiif"
|
|
114
113
|
expect(login_service.profile).to eq IIIF::V3::Presentation::Service::IIIF_AUTHENTICATION_V1_LOGIN_PROFILE
|
|
115
114
|
expect(login_service.label).to eq service_label
|
|
116
115
|
expect(login_service.service.class).to eq Array
|
|
117
116
|
expect(login_service.service.size).to eq 1
|
|
118
117
|
|
|
119
118
|
token_service_obj = login_service_obj.service.first
|
|
120
|
-
expect(token_service_obj[
|
|
121
|
-
expect(token_service_obj[
|
|
119
|
+
expect(token_service_obj["id"]).to eq token_service_id
|
|
120
|
+
expect(token_service_obj["profile"]).to eq IIIF::V3::Presentation::Service::IIIF_AUTHENTICATION_V1_TOKEN_PROFILE
|
|
122
121
|
end
|
|
123
122
|
end
|
|
124
123
|
end
|
|
125
124
|
end
|
|
126
|
-
describe
|
|
125
|
+
describe "image examples from http://prezi3.iiif.io/api/presentation/3.0" do
|
|
127
126
|
let(:image_object) {
|
|
128
127
|
IIIF::V3::Presentation::ImageResource.new({
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
"id" => "#{img_id}/full/full/0/default.jpg",
|
|
129
|
+
"type" => "dctypes:Image",
|
|
130
|
+
"format" => img_mimetype,
|
|
131
|
+
"height" => height,
|
|
132
|
+
"width" => width,
|
|
133
|
+
"service" => [image_v2_service]
|
|
134
|
+
})
|
|
136
135
|
}
|
|
137
|
-
describe
|
|
138
|
-
it
|
|
139
|
-
expect{image_object.validate}.not_to raise_error
|
|
136
|
+
describe "simpler" do
|
|
137
|
+
it "validates" do
|
|
138
|
+
expect { image_object.validate }.not_to raise_error
|
|
140
139
|
end
|
|
141
|
-
it
|
|
140
|
+
it "has expected required values" do
|
|
142
141
|
expect(image_object.id).to eq "#{img_id}/full/full/0/default.jpg"
|
|
143
|
-
expect(image_object.type).to eq
|
|
142
|
+
expect(image_object.type).to eq "dctypes:Image"
|
|
144
143
|
end
|
|
145
|
-
it
|
|
144
|
+
it "has expected additional values" do
|
|
146
145
|
expect(image_object.format).to eq img_mimetype
|
|
147
146
|
expect(image_object.height).to eq height
|
|
148
147
|
expect(image_object.width).to eq width
|
|
149
148
|
expect(image_object.service.first).to eq image_v2_service
|
|
150
149
|
end
|
|
151
150
|
end
|
|
152
|
-
describe
|
|
151
|
+
describe "height and width in service" do
|
|
153
152
|
# {
|
|
154
153
|
# "id": "http://example.org/images/book1-page2/full/1500,2000/0/default.jpg",
|
|
155
154
|
# "type": "dctypes:Image",
|
|
@@ -167,21 +166,21 @@ describe IIIF::V3::Presentation::ImageResource do
|
|
|
167
166
|
# }
|
|
168
167
|
let(:img_obj) {
|
|
169
168
|
img = image_object
|
|
170
|
-
img.service.first[
|
|
171
|
-
img.service.first[
|
|
172
|
-
img.service.first[
|
|
169
|
+
img.service.first["height"] = 6666
|
|
170
|
+
img.service.first["width"] = 9999
|
|
171
|
+
img.service.first["tiles"] = [{"width" => 512, "scaleFactors" => [1, 2, 4, 8, 16]}]
|
|
173
172
|
img
|
|
174
173
|
}
|
|
175
|
-
it
|
|
176
|
-
expect{img_obj.validate}.not_to raise_error
|
|
174
|
+
it "validates" do
|
|
175
|
+
expect { img_obj.validate }.not_to raise_error
|
|
177
176
|
end
|
|
178
|
-
it
|
|
177
|
+
it "has expected service value" do
|
|
179
178
|
service_obj = img_obj.service.first
|
|
180
179
|
expect(service_obj.class).to eq IIIF::V3::Presentation::Service
|
|
181
180
|
expect(service_obj.keys.size).to eq 7
|
|
182
|
-
expect(service_obj[
|
|
183
|
-
expect(service_obj[
|
|
184
|
-
expect(service_obj[
|
|
181
|
+
expect(service_obj["height"]).to eq 6666
|
|
182
|
+
expect(service_obj["width"]).to eq 9999
|
|
183
|
+
expect(service_obj["tiles"]).to eq [{"width" => 512, "scaleFactors" => [1, 2, 4, 8, 16]}]
|
|
185
184
|
end
|
|
186
185
|
end
|
|
187
186
|
end
|