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.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +8 -1
  3. data/.standard.yml +1 -0
  4. data/Gemfile +5 -5
  5. data/README.md +1 -1
  6. data/Rakefile +4 -2
  7. data/VERSION +1 -1
  8. data/bin/standardrb +16 -0
  9. data/iiif-presentation.gemspec +23 -23
  10. data/lib/iiif/hash_behaviours.rb +29 -33
  11. data/lib/iiif/ordered_hash.rb +33 -33
  12. data/lib/iiif/presentation/abstract_resource.rb +17 -22
  13. data/lib/iiif/presentation/annotation.rb +9 -11
  14. data/lib/iiif/presentation/annotation_list.rb +8 -10
  15. data/lib/iiif/presentation/canvas.rb +11 -13
  16. data/lib/iiif/presentation/collection.rb +7 -9
  17. data/lib/iiif/presentation/image_resource.rb +33 -35
  18. data/lib/iiif/presentation/layer.rb +8 -10
  19. data/lib/iiif/presentation/manifest.rb +9 -12
  20. data/lib/iiif/presentation/range.rb +8 -10
  21. data/lib/iiif/presentation/resource.rb +5 -7
  22. data/lib/iiif/presentation/sequence.rb +8 -11
  23. data/lib/iiif/presentation/service.rb +1 -2
  24. data/lib/iiif/presentation.rb +7 -7
  25. data/lib/iiif/service.rb +121 -102
  26. data/lib/iiif/v3/abstract_resource.rb +127 -130
  27. data/lib/iiif/v3/presentation/annotation.rb +20 -21
  28. data/lib/iiif/v3/presentation/annotation_collection.rb +7 -9
  29. data/lib/iiif/v3/presentation/annotation_page.rb +14 -15
  30. data/lib/iiif/v3/presentation/canvas.rb +21 -22
  31. data/lib/iiif/v3/presentation/choice.rb +14 -15
  32. data/lib/iiif/v3/presentation/collection.rb +7 -8
  33. data/lib/iiif/v3/presentation/image_resource.rb +21 -22
  34. data/lib/iiif/v3/presentation/manifest.rb +18 -19
  35. data/lib/iiif/v3/presentation/nav_place.rb +125 -29
  36. data/lib/iiif/v3/presentation/range.rb +10 -10
  37. data/lib/iiif/v3/presentation/resource.rb +4 -5
  38. data/lib/iiif/v3/presentation/sequence.rb +10 -11
  39. data/lib/iiif/v3/presentation/service.rb +12 -13
  40. data/lib/iiif/v3/presentation.rb +8 -8
  41. data/spec/integration/iiif/presentation/image_resource_spec.rb +54 -58
  42. data/spec/integration/iiif/service_spec.rb +76 -77
  43. data/spec/integration/iiif/v3/abstract_resource_spec.rb +72 -73
  44. data/spec/integration/iiif/v3/presentation/image_resource_spec.rb +53 -56
  45. data/spec/spec_helper.rb +56 -64
  46. data/spec/unit/iiif/hash_behaviours_spec.rb +384 -387
  47. data/spec/unit/iiif/ordered_hash_spec.rb +86 -91
  48. data/spec/unit/iiif/presentation/abstract_resource_spec.rb +64 -70
  49. data/spec/unit/iiif/presentation/annotation_list_spec.rb +1 -3
  50. data/spec/unit/iiif/presentation/annotation_spec.rb +1 -3
  51. data/spec/unit/iiif/presentation/canvas_spec.rb +11 -14
  52. data/spec/unit/iiif/presentation/collection_spec.rb +26 -33
  53. data/spec/unit/iiif/presentation/image_resource_spec.rb +4 -6
  54. data/spec/unit/iiif/presentation/layer_spec.rb +16 -20
  55. data/spec/unit/iiif/presentation/manifest_spec.rb +45 -48
  56. data/spec/unit/iiif/presentation/range_spec.rb +18 -22
  57. data/spec/unit/iiif/presentation/resource_spec.rb +3 -6
  58. data/spec/unit/iiif/presentation/sequence_spec.rb +58 -63
  59. data/spec/unit/iiif/presentation/shared_examples/abstract_resource_only_keys.rb +4 -10
  60. data/spec/unit/iiif/presentation/shared_examples/any_type_keys.rb +5 -9
  61. data/spec/unit/iiif/presentation/shared_examples/array_only_keys.rb +9 -17
  62. data/spec/unit/iiif/presentation/shared_examples/int_only_keys.rb +6 -14
  63. data/spec/unit/iiif/presentation/shared_examples/string_only_keys.rb +6 -13
  64. data/spec/unit/iiif/service_spec.rb +8 -13
  65. data/spec/unit/iiif/v3/abstract_resource_define_methods_for_spec.rb +39 -37
  66. data/spec/unit/iiif/v3/abstract_resource_spec.rb +124 -131
  67. data/spec/unit/iiif/v3/presentation/annotation_collection_spec.rb +14 -17
  68. data/spec/unit/iiif/v3/presentation/annotation_page_spec.rb +71 -69
  69. data/spec/unit/iiif/v3/presentation/annotation_spec.rb +249 -233
  70. data/spec/unit/iiif/v3/presentation/canvas_spec.rb +211 -193
  71. data/spec/unit/iiif/v3/presentation/choice_spec.rb +81 -77
  72. data/spec/unit/iiif/v3/presentation/collection_spec.rb +24 -29
  73. data/spec/unit/iiif/v3/presentation/image_resource_spec.rb +70 -71
  74. data/spec/unit/iiif/v3/presentation/manifest_spec.rb +248 -235
  75. data/spec/unit/iiif/v3/presentation/nav_place_spec.rb +249 -49
  76. data/spec/unit/iiif/v3/presentation/range_spec.rb +28 -29
  77. data/spec/unit/iiif/v3/presentation/resource_spec.rb +83 -82
  78. data/spec/unit/iiif/v3/presentation/sequence_spec.rb +125 -119
  79. data/spec/unit/iiif/v3/presentation/service_spec.rb +123 -124
  80. data/spec/unit/iiif/v3/presentation/shared_examples/abstract_resource_only_keys.rb +4 -8
  81. data/spec/unit/iiif/v3/presentation/shared_examples/any_type_keys.rb +5 -7
  82. data/spec/unit/iiif/v3/presentation/shared_examples/array_only_keys.rb +9 -13
  83. data/spec/unit/iiif/v3/presentation/shared_examples/hash_only_keys.rb +9 -13
  84. data/spec/unit/iiif/v3/presentation/shared_examples/int_only_keys.rb +6 -10
  85. data/spec/unit/iiif/v3/presentation/shared_examples/numeric_only_keys.rb +6 -10
  86. data/spec/unit/iiif/v3/presentation/shared_examples/string_only_keys.rb +6 -10
  87. data/spec/unit/iiif/v3/presentation/shared_examples/uri_only_keys.rb +9 -13
  88. 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
- '@context' => [
6
- 'http://iiif.io/api/presentation/3/context.json',
7
- 'http://www.w3.org/ns/anno.jsonld'
4
+ "@context" => [
5
+ "http://iiif.io/api/presentation/3/context.json",
6
+ "http://www.w3.org/ns/anno.jsonld"
8
7
  ],
9
- 'id' => 'http://www.example.org/iiif/book1/annoColl/transcription',
10
- 'type' => 'AnnotationCollection',
11
- 'label' => 'Diplomatic Transcription',
12
- 'first' => 'http://www.example.org/iiif/book1/list/l1',
13
- 'last' => 'http://www.example.org/iiif/book1/list/l4',
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
- describe '#initialize' do
19
- it 'sets type' do
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 'it has the appropriate methods for string-only keys v3'
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 'it has the appropriate methods for array-only keys v3'
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 'it has the appropriate methods for any-type keys v3'
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
- describe '#required_keys' do
4
- it 'id' do
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 '#prohibited_keys' do
10
- it 'contains the expected key names' do
8
+ describe "#prohibited_keys" do
9
+ it "contains the expected key names" do
11
10
  keys = described_class::CONTENT_RESOURCE_PROPERTIES +
12
- %w{
13
- first
14
- last
15
- total
16
- nav_date
17
- viewing_direction
18
- start_canvas
19
- content_annotations
20
- }
21
- expect(subject.prohibited_keys).to include(*keys)
22
- end
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 '#uri_only_keys' do
26
- it 'id' do
27
- expect(subject.uri_only_keys).to include('id')
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 '#array_only_keys' do
32
- it 'items' do
33
- expect(subject.array_only_keys).to include('items')
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 '#legal_viewing_hint_values' do
38
- it 'contains none' do
39
- expect(subject.legal_viewing_hint_values).to contain_exactly('none')
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 '#initialize' do
44
- it 'sets type to AnnotationPage by default' do
45
- expect(subject['type']).to eq 'AnnotationPage'
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 'allows subclasses to override type' do
46
+ it "allows subclasses to override type" do
48
47
  subclass = Class.new(described_class) do
49
- def initialize(hsh={})
50
- hsh = { 'type' => 'a:SubClass' }
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['type']).to eq 'a:SubClass'
53
+ expect(sub["type"]).to eq "a:SubClass"
56
54
  end
57
- it 'allows type to be passed in' do
58
- ap = described_class.new('type' => 'bar')
59
- expect(ap.type).to eq 'bar'
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 '#validate' do
64
- it 'raises IllegalValueError if id is not URI' do
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['id'] = 'foo'
64
+ subject["id"] = "foo"
67
65
  expect { subject.validate }.to raise_error(IIIF::V3::Presentation::IllegalValueError, exp_err_msg)
68
66
  end
69
- it 'raises IllegalValueError if id is not http(s)' do
70
- subject['id'] = 'ftp://www.example.org'
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 'raises IllegalValueError for items entry that is not an Annotation' do
75
- subject['id'] = 'http://example.com/iiif3/annotation_page/666'
76
- subject['items'] = [IIIF::V3::Presentation::ImageResource.new, IIIF::V3::Presentation::Annotation.new]
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 'realistic examples' do
83
- let(:ap_id) { 'http://example.com/iiif3/annotation_page/666' }
84
- let(:anno) { IIIF::V3::Presentation::Annotation.new(
85
- 'id' => 'http://example.com/anno/666',
86
- 'target' => 'http://example.com/canvas/abc'
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 'stanford (purl code)' do
89
+ describe "stanford (purl code)" do
90
90
  let(:anno_page) {
91
91
  anno_page = described_class.new
92
- anno_page['id'] = ap_id
92
+ anno_page["id"] = ap_id
93
93
  anno_page.items << anno
94
94
  anno_page
95
95
  }
96
- it 'validates' do
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 'has expected required values' do
99
+ it "has expected required values" do
100
100
  expect(anno_page.id).to eq ap_id
101
- expect(anno_page['type']).to eq 'AnnotationPage'
101
+ expect(anno_page["type"]).to eq "AnnotationPage"
102
102
  end
103
- it 'has expected additional values' do
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 'two items' do
109
- let(:anno2) { IIIF::V3::Presentation::Annotation.new(
110
- 'id' => 'http://example.com/anno/333',
111
- 'target' => 'http://example.com/canvas/abc'
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['id'] = ap_id
117
+ anno_page["id"] = ap_id
116
118
  anno_page.items = [anno, anno2]
117
119
  anno_page
118
120
  }
119
- it 'validates' do
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 'has expected required values' do
124
+ it "has expected required values" do
123
125
  expect(anno_page.id).to eq ap_id
124
- expect(anno_page['type']).to eq 'AnnotationPage'
126
+ expect(anno_page["type"]).to eq "AnnotationPage"
125
127
  end
126
- it 'has expected additional values' do
128
+ it "has expected additional values" do
127
129
  expect(anno_page.items).to eq [anno, anno2]
128
130
  end
129
131
  end