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,36 +1,33 @@
|
|
|
1
1
|
describe IIIF::V3::Presentation::AnnotationCollection do
|
|
2
|
-
|
|
3
2
|
let(:fixed_values) do
|
|
4
3
|
{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
"@context" => [
|
|
5
|
+
"http://iiif.io/api/presentation/3/context.json",
|
|
6
|
+
"http://www.w3.org/ns/anno.jsonld"
|
|
8
7
|
],
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
"id" => "http://www.example.org/iiif/book1/annoColl/transcription",
|
|
9
|
+
"type" => "AnnotationCollection",
|
|
10
|
+
"label" => "Diplomatic Transcription",
|
|
11
|
+
"first" => "http://www.example.org/iiif/book1/list/l1",
|
|
12
|
+
"last" => "http://www.example.org/iiif/book1/list/l4"
|
|
14
13
|
}
|
|
15
14
|
end
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
expect(subject['type']).to eq 'AnnotationCollection'
|
|
16
|
+
describe "#initialize" do
|
|
17
|
+
it "sets type" do
|
|
18
|
+
expect(subject["type"]).to eq "AnnotationCollection"
|
|
21
19
|
end
|
|
22
20
|
end
|
|
23
21
|
|
|
24
22
|
describe "#{described_class}.define_methods_for_string_only_keys" do
|
|
25
|
-
it_behaves_like
|
|
23
|
+
it_behaves_like "it has the appropriate methods for string-only keys v3"
|
|
26
24
|
end
|
|
27
25
|
|
|
28
26
|
describe "#{described_class}.define_methods_for_array_only_keys" do
|
|
29
|
-
it_behaves_like
|
|
27
|
+
it_behaves_like "it has the appropriate methods for array-only keys v3"
|
|
30
28
|
end
|
|
31
29
|
|
|
32
30
|
describe "#{described_class}.define_methods_for_any_type_keys" do
|
|
33
|
-
it_behaves_like
|
|
31
|
+
it_behaves_like "it has the appropriate methods for any-type keys v3"
|
|
34
32
|
end
|
|
35
|
-
|
|
36
33
|
end
|
|
@@ -1,129 +1,131 @@
|
|
|
1
1
|
describe IIIF::V3::Presentation::AnnotationPage do
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
expect(subject.required_keys).to include('id')
|
|
2
|
+
describe "#required_keys" do
|
|
3
|
+
it "id" do
|
|
4
|
+
expect(subject.required_keys).to include("id")
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
%w[
|
|
12
|
+
first
|
|
13
|
+
last
|
|
14
|
+
total
|
|
15
|
+
nav_date
|
|
16
|
+
viewing_direction
|
|
17
|
+
start_canvas
|
|
18
|
+
content_annotations
|
|
19
|
+
]
|
|
20
|
+
expect(subject.prohibited_keys).to include(*keys)
|
|
21
|
+
end
|
|
23
22
|
end
|
|
24
23
|
|
|
25
|
-
describe
|
|
26
|
-
it
|
|
27
|
-
expect(subject.uri_only_keys).to include(
|
|
24
|
+
describe "#uri_only_keys" do
|
|
25
|
+
it "id" do
|
|
26
|
+
expect(subject.uri_only_keys).to include("id")
|
|
28
27
|
end
|
|
29
28
|
end
|
|
30
29
|
|
|
31
|
-
describe
|
|
32
|
-
it
|
|
33
|
-
expect(subject.array_only_keys).to include(
|
|
30
|
+
describe "#array_only_keys" do
|
|
31
|
+
it "items" do
|
|
32
|
+
expect(subject.array_only_keys).to include("items")
|
|
34
33
|
end
|
|
35
34
|
end
|
|
36
35
|
|
|
37
|
-
describe
|
|
38
|
-
it
|
|
39
|
-
expect(subject.legal_viewing_hint_values).to contain_exactly(
|
|
36
|
+
describe "#legal_viewing_hint_values" do
|
|
37
|
+
it "contains none" do
|
|
38
|
+
expect(subject.legal_viewing_hint_values).to contain_exactly("none")
|
|
40
39
|
end
|
|
41
40
|
end
|
|
42
41
|
|
|
43
|
-
describe
|
|
44
|
-
it
|
|
45
|
-
expect(subject[
|
|
42
|
+
describe "#initialize" do
|
|
43
|
+
it "sets type to AnnotationPage by default" do
|
|
44
|
+
expect(subject["type"]).to eq "AnnotationPage"
|
|
46
45
|
end
|
|
47
|
-
it
|
|
46
|
+
it "allows subclasses to override type" do
|
|
48
47
|
subclass = Class.new(described_class) do
|
|
49
|
-
def initialize(
|
|
50
|
-
|
|
51
|
-
super(hsh)
|
|
48
|
+
def initialize(_hsh = {})
|
|
49
|
+
super({"type" => "a:SubClass"})
|
|
52
50
|
end
|
|
53
51
|
end
|
|
54
52
|
sub = subclass.new
|
|
55
|
-
expect(sub[
|
|
53
|
+
expect(sub["type"]).to eq "a:SubClass"
|
|
56
54
|
end
|
|
57
|
-
it
|
|
58
|
-
ap = described_class.new(
|
|
59
|
-
expect(ap.type).to eq
|
|
55
|
+
it "allows type to be passed in" do
|
|
56
|
+
ap = described_class.new("type" => "bar")
|
|
57
|
+
expect(ap.type).to eq "bar"
|
|
60
58
|
end
|
|
61
59
|
end
|
|
62
60
|
|
|
63
|
-
describe
|
|
64
|
-
it
|
|
61
|
+
describe "#validate" do
|
|
62
|
+
it "raises IllegalValueError if id is not URI" do
|
|
65
63
|
exp_err_msg = "id value must be a String containing a URI for #{described_class}"
|
|
66
|
-
subject[
|
|
64
|
+
subject["id"] = "foo"
|
|
67
65
|
expect { subject.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_err_msg)
|
|
68
66
|
end
|
|
69
|
-
it
|
|
70
|
-
subject[
|
|
67
|
+
it "raises IllegalValueError if id is not http(s)" do
|
|
68
|
+
subject["id"] = "ftp://www.example.org"
|
|
71
69
|
exp_err_msg = "id must be an http(s) URI for #{described_class}"
|
|
72
70
|
expect { subject.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_err_msg)
|
|
73
71
|
end
|
|
74
|
-
it
|
|
75
|
-
subject[
|
|
76
|
-
subject[
|
|
72
|
+
it "raises IllegalValueError for items entry that is not an Annotation" do
|
|
73
|
+
subject["id"] = "http://example.com/iiif3/annotation_page/666"
|
|
74
|
+
subject["items"] = [IIIF::V3::Presentation::ImageResource.new, IIIF::V3::Presentation::Annotation.new]
|
|
77
75
|
exp_err_msg = "All entries in the items list must be a IIIF::V3::Presentation::Annotation"
|
|
78
76
|
expect { subject.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_err_msg)
|
|
79
77
|
end
|
|
80
78
|
end
|
|
81
79
|
|
|
82
|
-
describe
|
|
83
|
-
let(:ap_id) {
|
|
84
|
-
let(:anno) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
describe "realistic examples" do
|
|
81
|
+
let(:ap_id) { "http://example.com/iiif3/annotation_page/666" }
|
|
82
|
+
let(:anno) {
|
|
83
|
+
IIIF::V3::Presentation::Annotation.new(
|
|
84
|
+
"id" => "http://example.com/anno/666",
|
|
85
|
+
"target" => "http://example.com/canvas/abc"
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
88
|
|
|
89
|
-
describe
|
|
89
|
+
describe "stanford (purl code)" do
|
|
90
90
|
let(:anno_page) {
|
|
91
91
|
anno_page = described_class.new
|
|
92
|
-
anno_page[
|
|
92
|
+
anno_page["id"] = ap_id
|
|
93
93
|
anno_page.items << anno
|
|
94
94
|
anno_page
|
|
95
95
|
}
|
|
96
|
-
it
|
|
97
|
-
expect{anno_page.validate}.not_to raise_error
|
|
96
|
+
it "validates" do
|
|
97
|
+
expect { anno_page.validate }.not_to raise_error
|
|
98
98
|
end
|
|
99
|
-
it
|
|
99
|
+
it "has expected required values" do
|
|
100
100
|
expect(anno_page.id).to eq ap_id
|
|
101
|
-
expect(anno_page[
|
|
101
|
+
expect(anno_page["type"]).to eq "AnnotationPage"
|
|
102
102
|
end
|
|
103
|
-
it
|
|
103
|
+
it "has expected additional values" do
|
|
104
104
|
expect(anno_page.items).to eq [anno]
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
-
describe
|
|
109
|
-
let(:anno2) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
describe "two items" do
|
|
109
|
+
let(:anno2) {
|
|
110
|
+
IIIF::V3::Presentation::Annotation.new(
|
|
111
|
+
"id" => "http://example.com/anno/333",
|
|
112
|
+
"target" => "http://example.com/canvas/abc"
|
|
113
|
+
)
|
|
114
|
+
}
|
|
113
115
|
let(:anno_page) {
|
|
114
116
|
anno_page = described_class.new
|
|
115
|
-
anno_page[
|
|
117
|
+
anno_page["id"] = ap_id
|
|
116
118
|
anno_page.items = [anno, anno2]
|
|
117
119
|
anno_page
|
|
118
120
|
}
|
|
119
|
-
it
|
|
120
|
-
expect{anno_page.validate}.not_to raise_error
|
|
121
|
+
it "validates" do
|
|
122
|
+
expect { anno_page.validate }.not_to raise_error
|
|
121
123
|
end
|
|
122
|
-
it
|
|
124
|
+
it "has expected required values" do
|
|
123
125
|
expect(anno_page.id).to eq ap_id
|
|
124
|
-
expect(anno_page[
|
|
126
|
+
expect(anno_page["type"]).to eq "AnnotationPage"
|
|
125
127
|
end
|
|
126
|
-
it
|
|
128
|
+
it "has expected additional values" do
|
|
127
129
|
expect(anno_page.items).to eq [anno, anno2]
|
|
128
130
|
end
|
|
129
131
|
end
|