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,38 +1,34 @@
|
|
|
1
1
|
describe IIIF::Presentation::Layer do
|
|
2
|
-
|
|
3
2
|
let(:fixed_values) do
|
|
4
3
|
{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
"@context" => "http://iiif.io/api/presentation/2/context.json",
|
|
5
|
+
"@id" => "http://www.example.org/iiif/book1/layer/transcription",
|
|
6
|
+
"@type" => "sc:Layer",
|
|
7
|
+
"label" => "Diplomatic Transcription",
|
|
8
|
+
"otherContent" => [
|
|
9
|
+
"http://www.example.org/iiif/book1/list/l1",
|
|
10
|
+
"http://www.example.org/iiif/book1/list/l2",
|
|
11
|
+
"http://www.example.org/iiif/book1/list/l3",
|
|
12
|
+
"http://www.example.org/iiif/book1/list/l4"
|
|
14
13
|
]
|
|
15
14
|
}
|
|
16
15
|
end
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
expect(subject['@type']).to eq 'sc:Layer'
|
|
17
|
+
describe "#initialize" do
|
|
18
|
+
it "sets @type" do
|
|
19
|
+
expect(subject["@type"]).to eq "sc:Layer"
|
|
22
20
|
end
|
|
23
21
|
end
|
|
24
22
|
|
|
25
23
|
describe "#{described_class}.define_methods_for_string_only_keys" do
|
|
26
|
-
it_behaves_like
|
|
24
|
+
it_behaves_like "it has the appropriate methods for string-only keys"
|
|
27
25
|
end
|
|
28
|
-
|
|
26
|
+
|
|
29
27
|
describe "#{described_class}.define_methods_for_array_only_keys" do
|
|
30
|
-
it_behaves_like
|
|
28
|
+
it_behaves_like "it has the appropriate methods for array-only keys"
|
|
31
29
|
end
|
|
32
30
|
|
|
33
31
|
describe "#{described_class}.define_methods_for_any_type_keys" do
|
|
34
|
-
it_behaves_like
|
|
32
|
+
it_behaves_like "it has the appropriate methods for any-type keys"
|
|
35
33
|
end
|
|
36
|
-
|
|
37
34
|
end
|
|
38
|
-
|
|
@@ -1,89 +1,86 @@
|
|
|
1
1
|
describe IIIF::Presentation::Manifest do
|
|
2
|
-
|
|
3
2
|
let(:subclass_subject) do
|
|
4
3
|
Class.new(IIIF::Presentation::Manifest) do
|
|
5
|
-
def initialize(
|
|
6
|
-
|
|
7
|
-
super(hsh)
|
|
4
|
+
def initialize(_hsh = {})
|
|
5
|
+
super({"@type" => "a:SubClass"})
|
|
8
6
|
end
|
|
9
7
|
end
|
|
10
8
|
end
|
|
11
9
|
|
|
12
10
|
let(:fixed_values) do
|
|
13
11
|
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
"type" => "a:SubClass",
|
|
13
|
+
"id" => "http://example.com/prefix/manifest/123",
|
|
14
|
+
"context" => IIIF::Presentation::CONTEXT,
|
|
15
|
+
"label" => {"en" => ["Book 1"]},
|
|
16
|
+
"description" => "A longer description of this example book. It should give some real information.",
|
|
17
|
+
"thumbnail" => {
|
|
18
|
+
"@id" => "http://www.example.org/images/book1-page1/full/80,100/0/default.jpg",
|
|
19
|
+
"service" => {
|
|
20
|
+
"@context" => "http://iiif.io/api/image/2/context.json",
|
|
21
|
+
"@id" => "http://www.example.org/images/book1-page1",
|
|
22
|
+
"profile" => "http://iiif.io/api/image/2/level1.json"
|
|
25
23
|
}
|
|
26
24
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
"attribution" => "Provided by Example Organization",
|
|
26
|
+
"license" => "http://www.example.org/license.html",
|
|
27
|
+
"logo" => "http://www.example.org/logos/institution1.jpg",
|
|
28
|
+
"see_also" => "http://www.example.org/library/catalog/book1.xml",
|
|
29
|
+
"service" => {
|
|
30
|
+
"@context" => "http://example.org/ns/jsonld/context.json",
|
|
31
|
+
"@id" => "http://example.org/service/example",
|
|
32
|
+
"profile" => "http://example.org/docs/example-service.html"
|
|
35
33
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
"related" => {
|
|
35
|
+
"@id" => "http://www.example.org/videos/video-book1.mpg",
|
|
36
|
+
"format" => "video/mpeg"
|
|
39
37
|
},
|
|
40
|
-
|
|
38
|
+
"within" => "http://www.example.org/collections/books/"
|
|
41
39
|
}
|
|
42
40
|
end
|
|
43
41
|
|
|
44
|
-
describe
|
|
45
|
-
it
|
|
46
|
-
expect(subject[
|
|
42
|
+
describe "#initialize" do
|
|
43
|
+
it "sets @type to sc:Manifest by default" do
|
|
44
|
+
expect(subject["@type"]).to eq "sc:Manifest"
|
|
47
45
|
end
|
|
48
|
-
it
|
|
46
|
+
it "allows subclasses to override @type" do
|
|
49
47
|
sub = subclass_subject.new
|
|
50
|
-
expect(sub[
|
|
48
|
+
expect(sub["@type"]).to eq "a:SubClass"
|
|
51
49
|
end
|
|
52
50
|
end
|
|
53
51
|
|
|
54
|
-
describe
|
|
55
|
-
it
|
|
56
|
-
expect(subject.required_keys).to eq %w
|
|
52
|
+
describe "#required_keys" do
|
|
53
|
+
it "accumulates" do
|
|
54
|
+
expect(subject.required_keys).to eq %w[@type @id label]
|
|
57
55
|
end
|
|
58
56
|
end
|
|
59
57
|
|
|
60
|
-
describe
|
|
61
|
-
it
|
|
62
|
-
subject.label =
|
|
58
|
+
describe "#validate" do
|
|
59
|
+
it "raises an error if there is no @id" do
|
|
60
|
+
subject.label = "Book 1"
|
|
63
61
|
expect { subject.validate }.to raise_error IIIF::Presentation::MissingRequiredKeyError
|
|
64
62
|
end
|
|
65
|
-
it
|
|
66
|
-
subject[
|
|
63
|
+
it "raises an error if there is no label" do
|
|
64
|
+
subject["@id"] = "http://www.example.org/iiif/book1/manifest"
|
|
67
65
|
expect { subject.validate }.to raise_error IIIF::Presentation::MissingRequiredKeyError
|
|
68
66
|
end
|
|
69
|
-
it
|
|
70
|
-
subject.delete(
|
|
71
|
-
subject.label =
|
|
72
|
-
subject[
|
|
67
|
+
it "raises an error if there is no @type" do
|
|
68
|
+
subject.delete("@type")
|
|
69
|
+
subject.label = "Book 1"
|
|
70
|
+
subject["@id"] = "http://www.example.org/iiif/book1/manifest"
|
|
73
71
|
expect { subject.validate }.to raise_error IIIF::Presentation::MissingRequiredKeyError
|
|
74
72
|
end
|
|
75
73
|
end
|
|
76
74
|
|
|
77
75
|
describe "#{described_class}.define_methods_for_array_only_keys" do
|
|
78
|
-
it_behaves_like
|
|
76
|
+
it_behaves_like "it has the appropriate methods for array-only keys"
|
|
79
77
|
end
|
|
80
78
|
|
|
81
79
|
describe "#{described_class}.define_methods_for_string_only_keys" do
|
|
82
|
-
it_behaves_like
|
|
80
|
+
it_behaves_like "it has the appropriate methods for string-only keys"
|
|
83
81
|
end
|
|
84
82
|
|
|
85
83
|
describe "#{described_class}.define_methods_for_any_type_keys" do
|
|
86
|
-
it_behaves_like
|
|
84
|
+
it_behaves_like "it has the appropriate methods for any-type keys"
|
|
87
85
|
end
|
|
88
|
-
|
|
89
86
|
end
|
|
@@ -1,43 +1,39 @@
|
|
|
1
1
|
describe IIIF::Presentation::Range do
|
|
2
|
-
|
|
3
|
-
let(:fixed_values) do
|
|
2
|
+
let(:fixed_values) do
|
|
4
3
|
{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
"@id" => "http://www.example.org/iiif/book1/range/r1",
|
|
5
|
+
"@type" => "sc:Range",
|
|
6
|
+
"label" => "Introduction",
|
|
7
|
+
"ranges" => [
|
|
8
|
+
"http://www.example.org/iiif/book1/range/r1-1",
|
|
9
|
+
"http://www.example.org/iiif/book1/range/r1-2"
|
|
11
10
|
],
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
"canvases" => [
|
|
12
|
+
"http://www.example.org/iiif/book1/canvas/p1",
|
|
13
|
+
"http://www.example.org/iiif/book1/canvas/p2",
|
|
14
|
+
"http://www.example.org/iiif/book1/canvas/p3#xywh=0,0,750,300"
|
|
16
15
|
]
|
|
17
16
|
}
|
|
18
17
|
end
|
|
19
18
|
|
|
20
|
-
describe
|
|
21
|
-
it
|
|
22
|
-
expect(subject[
|
|
19
|
+
describe "#initialize" do
|
|
20
|
+
it "sets @type to sc:Range by default" do
|
|
21
|
+
expect(subject["@type"]).to eq "sc:Range"
|
|
23
22
|
end
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
describe "#{described_class}.define_methods_for_array_only_keys" do
|
|
27
|
-
it_behaves_like
|
|
26
|
+
it_behaves_like "it has the appropriate methods for array-only keys"
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
describe "#{described_class}.define_methods_for_string_only_keys" do
|
|
31
|
-
it_behaves_like
|
|
30
|
+
it_behaves_like "it has the appropriate methods for string-only keys"
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
describe "#{described_class}.define_methods_for_any_type_keys" do
|
|
35
|
-
it_behaves_like
|
|
34
|
+
it_behaves_like "it has the appropriate methods for any-type keys"
|
|
36
35
|
end
|
|
37
36
|
|
|
38
|
-
describe
|
|
37
|
+
describe "#validate" do
|
|
39
38
|
end
|
|
40
|
-
|
|
41
39
|
end
|
|
42
|
-
|
|
43
|
-
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
describe IIIF::Presentation::Resource do
|
|
2
|
-
|
|
3
2
|
describe "#{described_class}.define_methods_for_abstract_resource_only_keys" do
|
|
4
|
-
it_behaves_like
|
|
3
|
+
it_behaves_like "it has the appropriate methods for abstract_resource_only_keys"
|
|
5
4
|
end
|
|
6
5
|
|
|
7
6
|
describe "#{described_class}.int_only_keys" do
|
|
8
|
-
it_behaves_like
|
|
7
|
+
it_behaves_like "it has the appropriate methods for integer-only keys"
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
describe "#{described_class}.define_methods_for_string_only_keys" do
|
|
12
|
-
it_behaves_like
|
|
11
|
+
it_behaves_like "it has the appropriate methods for string-only keys"
|
|
13
12
|
end
|
|
14
|
-
|
|
15
13
|
end
|
|
16
|
-
|
|
@@ -1,110 +1,105 @@
|
|
|
1
1
|
describe IIIF::Presentation::Sequence do
|
|
2
|
-
|
|
3
2
|
let(:subclass_subject) do
|
|
4
3
|
Class.new(IIIF::Presentation::Sequence) do
|
|
5
|
-
def initialize(
|
|
6
|
-
|
|
7
|
-
super(hsh)
|
|
4
|
+
def initialize(_hsh = {})
|
|
5
|
+
super({"@type" => "a:SubClass"})
|
|
8
6
|
end
|
|
9
7
|
end
|
|
10
8
|
end
|
|
11
9
|
|
|
12
10
|
let(:fixed_values) do
|
|
13
11
|
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
"@type" => "sc:Sequence",
|
|
13
|
+
"@id" => "http://example.com/prefix/sequence/456",
|
|
14
|
+
"@context" => IIIF::Presentation::CONTEXT,
|
|
15
|
+
"label" => "Book 1",
|
|
16
|
+
"description" => "A longer description of this example book. It should give some real information.",
|
|
17
|
+
"thumbnail" => {
|
|
18
|
+
"@id" => "http://www.example.org/images/book1-page1/full/80,100/0/default.jpg",
|
|
19
|
+
"service" => {
|
|
20
|
+
"@context" => "http://iiif.io/api/image/2/context.json",
|
|
21
|
+
"@id" => "http://www.example.org/images/book1-page1",
|
|
22
|
+
"profile" => "http://iiif.io/api/image/2/level1.json"
|
|
25
23
|
}
|
|
26
24
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
"attribution" => "Provided by Example Organization",
|
|
26
|
+
"license" => "http://www.example.org/license.html",
|
|
27
|
+
"logo" => "http://www.example.org/logos/institution1.jpg",
|
|
28
|
+
"see_also" => "http://www.example.org/library/catalog/book1.xml",
|
|
29
|
+
"service" => {
|
|
30
|
+
"@context" => "http://example.org/ns/jsonld/context.json",
|
|
31
|
+
"@id" => "http://example.org/service/example",
|
|
32
|
+
"profile" => "http://example.org/docs/example-service.html"
|
|
35
33
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
"related" => {
|
|
35
|
+
"@id" => "http://www.example.org/videos/video-book1.mpg",
|
|
36
|
+
"format" => "video/mpeg"
|
|
39
37
|
},
|
|
40
|
-
|
|
38
|
+
"within" => "http://www.example.org/collections/books/",
|
|
41
39
|
# Sequence
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
"metadata" => [{"label" => "Author", "value" => "Anne Author"}],
|
|
41
|
+
"canvases" => [{
|
|
42
|
+
"@id" => "http://www.example.org/iiif/book1/canvas/p1",
|
|
43
|
+
"@type" => "sc:Canvas",
|
|
44
|
+
"label" => "p. 1",
|
|
45
|
+
"height" => 1000,
|
|
46
|
+
"width" => 750,
|
|
47
|
+
"images" => []
|
|
50
48
|
}],
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
"viewing_hint" => "paged",
|
|
50
|
+
"start_canvas" => "http://www.example.org/iiif/book1/canvas/p2",
|
|
51
|
+
"viewing_direction" => "right-to-left"
|
|
54
52
|
}
|
|
55
53
|
end
|
|
56
54
|
|
|
57
|
-
describe
|
|
58
|
-
it
|
|
59
|
-
expect(subject[
|
|
55
|
+
describe "#initialize" do
|
|
56
|
+
it "sets @type to sc:Sequence by default" do
|
|
57
|
+
expect(subject["@type"]).to eq "sc:Sequence"
|
|
60
58
|
end
|
|
61
|
-
it
|
|
59
|
+
it "allows subclasses to override @type" do
|
|
62
60
|
sub = subclass_subject.new
|
|
63
|
-
expect(sub[
|
|
61
|
+
expect(sub["@type"]).to eq "a:SubClass"
|
|
64
62
|
end
|
|
65
63
|
end
|
|
66
64
|
|
|
67
|
-
describe
|
|
68
|
-
it
|
|
69
|
-
expect(subject.required_keys).to eq %w
|
|
65
|
+
describe "#required_keys" do
|
|
66
|
+
it "accumulates from the superclass" do
|
|
67
|
+
expect(subject.required_keys).to eq %w[@type]
|
|
70
68
|
end
|
|
71
69
|
end
|
|
72
70
|
|
|
73
|
-
describe
|
|
74
|
-
it
|
|
75
|
-
expect(subject.string_only_keys).to eq %w
|
|
71
|
+
describe "#string_only_keys" do
|
|
72
|
+
it "accumulates from the superclass" do
|
|
73
|
+
expect(subject.string_only_keys).to eq %w[viewing_hint start_canvas viewing_direction]
|
|
76
74
|
end
|
|
77
75
|
end
|
|
78
76
|
|
|
79
|
-
describe
|
|
80
|
-
it
|
|
81
|
-
expect(subject.array_only_keys).to eq %w
|
|
77
|
+
describe "#array_only_keys" do
|
|
78
|
+
it "accumulates from the superclass" do
|
|
79
|
+
expect(subject.array_only_keys).to eq %w[metadata canvases]
|
|
82
80
|
end
|
|
83
81
|
end
|
|
84
82
|
|
|
85
83
|
describe "#{described_class}.define_methods_for_array_only_keys" do
|
|
86
|
-
it_behaves_like
|
|
84
|
+
it_behaves_like "it has the appropriate methods for array-only keys"
|
|
87
85
|
end
|
|
88
86
|
|
|
89
87
|
describe "#{described_class}.define_methods_for_string_only_keys" do
|
|
90
|
-
it_behaves_like
|
|
88
|
+
it_behaves_like "it has the appropriate methods for string-only keys"
|
|
91
89
|
end
|
|
92
90
|
|
|
93
91
|
describe "#{described_class}.define_methods_for_any_type_keys" do
|
|
94
|
-
it_behaves_like
|
|
92
|
+
it_behaves_like "it has the appropriate methods for any-type keys"
|
|
95
93
|
end
|
|
96
94
|
|
|
97
|
-
describe
|
|
98
|
-
it
|
|
99
|
-
subject[
|
|
95
|
+
describe "#validate" do
|
|
96
|
+
it "raises an error if viewing_hint isn't an allowable value" do
|
|
97
|
+
subject["viewing_hint"] = "foo"
|
|
100
98
|
expect { subject.validate }.to raise_error IIIF::Presentation::IllegalValueError
|
|
101
99
|
end
|
|
102
|
-
it
|
|
103
|
-
subject[
|
|
100
|
+
it "raises an error if viewing_directon isn't an allowable value" do
|
|
101
|
+
subject["viewing_direction"] = "foo-to-bar"
|
|
104
102
|
expect { subject.validate }.to raise_error IIIF::Presentation::IllegalValueError
|
|
105
103
|
end
|
|
106
104
|
end
|
|
107
|
-
|
|
108
|
-
|
|
109
105
|
end
|
|
110
|
-
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
shared_examples 'it has the appropriate methods for abstract_resource_only_keys' do
|
|
4
|
-
|
|
1
|
+
shared_examples "it has the appropriate methods for abstract_resource_only_keys" do
|
|
5
2
|
described_class.new.abstract_resource_only_keys.each do |entry|
|
|
6
|
-
|
|
7
3
|
describe "#{entry[:key]}=" do
|
|
8
4
|
it "sets #{entry[:key]}" do
|
|
9
5
|
@ex = entry[:type].new
|
|
@@ -19,11 +15,11 @@ shared_examples 'it has the appropriate methods for abstract_resource_only_keys'
|
|
|
19
15
|
end
|
|
20
16
|
it "raises an exception when attempting to set it to something other than an #{entry[:type]}" do
|
|
21
17
|
e = IIIF::Presentation::IllegalValueError
|
|
22
|
-
expect { subject.send("#{entry[:key]}=",
|
|
18
|
+
expect { subject.send("#{entry[:key]}=", "Foo") }.to raise_error e
|
|
23
19
|
end
|
|
24
20
|
end
|
|
25
21
|
|
|
26
|
-
describe
|
|
22
|
+
describe entry[:key].to_s do
|
|
27
23
|
it "gets #{entry[:key]}" do
|
|
28
24
|
@ex = entry[:type].new
|
|
29
25
|
subject[entry[:key]] = @ex
|
|
@@ -33,11 +29,9 @@ shared_examples 'it has the appropriate methods for abstract_resource_only_keys'
|
|
|
33
29
|
it "is aliased as ##{entry[:key].camelize(:lower)}" do
|
|
34
30
|
@ex = entry[:type].new
|
|
35
31
|
subject[entry[:key]] = @ex
|
|
36
|
-
expect(subject.send(
|
|
32
|
+
expect(subject.send(entry[:key].camelize(:lower).to_s)).to eq @ex
|
|
37
33
|
end
|
|
38
34
|
end
|
|
39
35
|
end
|
|
40
|
-
|
|
41
36
|
end
|
|
42
|
-
|
|
43
37
|
end
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
shared_examples 'it has the appropriate methods for any-type keys' do
|
|
4
|
-
|
|
1
|
+
shared_examples "it has the appropriate methods for any-type keys" do
|
|
5
2
|
described_class.new.any_type_keys.each do |prop|
|
|
6
3
|
describe "##{prop}=" do
|
|
7
4
|
it "sets self['#{prop}']" do
|
|
@@ -18,16 +15,15 @@ shared_examples 'it has the appropriate methods for any-type keys' do
|
|
|
18
15
|
|
|
19
16
|
describe "##{prop}" do
|
|
20
17
|
it "gets self[#{prop}]" do
|
|
21
|
-
subject.send(
|
|
22
|
-
expect(subject.send(
|
|
18
|
+
subject.send(:[]=, prop, fixed_values[prop])
|
|
19
|
+
expect(subject.send(prop.to_s)).to eq fixed_values[prop]
|
|
23
20
|
end
|
|
24
21
|
if prop.camelize(:lower) != prop
|
|
25
22
|
it "is aliased as ##{prop.camelize(:lower)}" do
|
|
26
|
-
subject.send(
|
|
27
|
-
expect(subject.send(
|
|
23
|
+
subject.send(:[]=, prop, fixed_values[prop])
|
|
24
|
+
expect(subject.send(prop.camelize(:lower).to_s)).to eq fixed_values[prop]
|
|
28
25
|
end
|
|
29
26
|
end
|
|
30
27
|
end
|
|
31
28
|
end
|
|
32
|
-
|
|
33
29
|
end
|
|
@@ -1,44 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
shared_examples 'it has the appropriate methods for array-only keys' do
|
|
4
|
-
|
|
1
|
+
shared_examples "it has the appropriate methods for array-only keys" do
|
|
5
2
|
described_class.new.array_only_keys.each do |prop|
|
|
6
|
-
|
|
7
3
|
describe "#{prop}=" do
|
|
8
4
|
it "sets #{prop}" do
|
|
9
|
-
ex = [{
|
|
5
|
+
ex = [{"label" => "XYZ"}]
|
|
10
6
|
subject.send("#{prop}=", ex)
|
|
11
7
|
expect(subject[prop]).to eq ex
|
|
12
8
|
end
|
|
13
9
|
if prop.camelize(:lower) != prop
|
|
14
10
|
it "is aliased as ##{prop.camelize(:lower)}=" do
|
|
15
|
-
ex = [{
|
|
11
|
+
ex = [{"label" => "XYZ"}]
|
|
16
12
|
subject.send("#{prop.camelize(:lower)}=", ex)
|
|
17
13
|
expect(subject[prop]).to eq ex
|
|
18
14
|
end
|
|
19
15
|
end
|
|
20
|
-
it
|
|
21
|
-
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::Presentation::IllegalValueError
|
|
22
18
|
end
|
|
23
19
|
end
|
|
24
20
|
|
|
25
|
-
describe
|
|
21
|
+
describe prop.to_s do
|
|
26
22
|
it "gets #{prop}" do
|
|
27
|
-
ex = [{
|
|
23
|
+
ex = [{"label" => "XYZ"}]
|
|
28
24
|
subject[prop] = ex
|
|
29
25
|
expect(subject.send(prop)).to eq ex
|
|
30
26
|
end
|
|
31
27
|
if prop.camelize(:lower) != prop
|
|
32
28
|
it "is aliased as ##{prop.camelize(:lower)}" do
|
|
33
|
-
ex = [{
|
|
29
|
+
ex = [{"label" => "XYZ"}]
|
|
34
30
|
subject[prop] = ex
|
|
35
|
-
expect(subject.send(
|
|
31
|
+
expect(subject.send(prop.camelize(:lower).to_s)).to eq ex
|
|
36
32
|
end
|
|
37
33
|
end
|
|
38
34
|
end
|
|
39
|
-
|
|
40
35
|
end
|
|
41
|
-
|
|
42
36
|
end
|
|
43
|
-
|
|
44
|
-
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
shared_examples 'it has the appropriate methods for integer-only keys' do
|
|
4
|
-
|
|
1
|
+
shared_examples "it has the appropriate methods for integer-only keys" do
|
|
5
2
|
described_class.new.int_only_keys.each do |prop|
|
|
6
|
-
|
|
7
3
|
describe "#{prop}=" do
|
|
8
4
|
before(:all) do
|
|
9
5
|
@ex = 7200
|
|
@@ -18,15 +14,15 @@ shared_examples 'it has the appropriate methods for integer-only keys' do
|
|
|
18
14
|
expect(subject[prop]).to eq @ex
|
|
19
15
|
end
|
|
20
16
|
end
|
|
21
|
-
it
|
|
22
|
-
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::Presentation::IllegalValueError
|
|
23
19
|
end
|
|
24
|
-
it
|
|
20
|
+
it "raises an exception when attempting to set it to a negative number" do
|
|
25
21
|
expect { subject.send("#{prop}=", -1) }.to raise_error IIIF::Presentation::IllegalValueError
|
|
26
22
|
end
|
|
27
23
|
end
|
|
28
24
|
|
|
29
|
-
describe
|
|
25
|
+
describe prop.to_s do
|
|
30
26
|
before(:all) do
|
|
31
27
|
@ex = 7200
|
|
32
28
|
end
|
|
@@ -37,13 +33,9 @@ shared_examples 'it has the appropriate methods for integer-only keys' do
|
|
|
37
33
|
if prop.camelize(:lower) != prop
|
|
38
34
|
it "is aliased as ##{prop.camelize(:lower)}" do
|
|
39
35
|
subject[prop] = @ex
|
|
40
|
-
expect(subject.send(
|
|
36
|
+
expect(subject.send(prop.camelize(:lower).to_s)).to eq @ex
|
|
41
37
|
end
|
|
42
38
|
end
|
|
43
39
|
end
|
|
44
|
-
|
|
45
40
|
end
|
|
46
|
-
|
|
47
41
|
end
|
|
48
|
-
|
|
49
|
-
|