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,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('type')
4
+ expect(subject.required_keys).not_to include("type")
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
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 '#uri_only_keys' do
24
- it '@context' do
25
- expect(subject.uri_only_keys).to include('@context')
22
+ describe "#uri_only_keys" do
23
+ it "@context" do
24
+ expect(subject.uri_only_keys).to include("@context")
26
25
  end
27
- it '@id' do
28
- expect(subject.uri_only_keys).to include('@id')
26
+ it "@id" do
27
+ expect(subject.uri_only_keys).to include("@id")
29
28
  end
30
- it 'id' do
31
- expect(subject.uri_only_keys).to include('id')
29
+ it "id" do
30
+ expect(subject.uri_only_keys).to include("id")
32
31
  end
33
32
  end
34
33
 
35
- describe '#any_type_keys' do
36
- it 'profile' do
37
- expect(subject.any_type_keys).to include('profile')
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 '#initialize' do
44
- it 'assigns hash values passed in' do
45
- label_val = 'foo'
46
- inner_service_id = 'http://example.org/whatever'
47
- inner_service_profile = 'http://iiif.io/api/auth/1/token'
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
- 'id' => inner_service_id,
50
- 'profile' => inner_service_profile
51
- })
48
+ "id" => inner_service_id,
49
+ "profile" => inner_service_profile
50
+ })
52
51
  service_obj = described_class.new({
53
- 'type' => described_class::IIIF_IMAGE_V2_TYPE,
54
- 'id' => id_uri,
55
- 'profile' => described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE,
56
- 'label' => label_val,
57
- 'service' => [inner_service_val]
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['id']).to eq id_uri
61
- expect(service_obj['type']).to eq described_class::IIIF_IMAGE_V2_TYPE
62
- expect(service_obj['profile']).to eq described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE
63
- expect(service_obj['label']).to eq label_val
64
- expect(service_obj['service'][0]['id']).to eq inner_service_id
65
- expect(service_obj['service'][0]['profile']).to eq inner_service_profile
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
- 'id' => id_uri,
71
- '@id' => id_uri
69
+ "id" => id_uri,
70
+ "@id" => id_uri
72
71
  })
73
72
  expect(service_obj.keys.size).to eq 2
74
- expect(service_obj['id']).to eq id_uri
75
- expect(service_obj['@id']).to eq id_uri
73
+ expect(service_obj["id"]).to eq id_uri
74
+ expect(service_obj["@id"]).to eq id_uri
76
75
  end
77
- it 'allows non-URI profile value' do
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" => [ "gif", "pdf" ],
84
- "qualities" => [ "color", "gray" ],
85
- "supports" => [ "canonicalLinkHeader", "rotationArbitrary", "http://example.com/feature" ]
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 '#validate' do
94
- describe 'type = IIIF_IMAGE_API_V2_TYPE' do
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
- 'type' => described_class::IIIF_IMAGE_V2_TYPE,
98
- 'nope' => id_uri,
99
- 'profile' => described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE
100
- })
101
- exp_err_msg = 'id or @id values are required for IIIF::V3::Presentation::Service with type or @type ImageService2'
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 'should have a profile' do
103
+ it "should have a profile" do
105
104
  service_obj = described_class.new({
106
- '@type' => described_class::IIIF_IMAGE_V2_TYPE,
107
- '@id' => id_uri
108
- })
109
- exp_err_msg = 'profile should be present for IIIF::V3::Presentation::Service with type or @type ImageService2'
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
- '@type' => described_class::IIIF_IMAGE_V2_TYPE,
115
- '@id' => id_uri,
116
- 'id' => "#{id_uri}/foo",
117
- 'profile' => described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE
118
- })
119
- exp_err_msg = 'id and @id values must match for IIIF::V3::Presentation::Service with type or @type ImageService2'
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 'realistic examples' do
126
- describe 'from Stanford purl manifests' do
127
- it 'iiif image v2 service' do
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
- 'type' => described_class::IIIF_IMAGE_V2_TYPE,
130
- 'id' => id_uri,
131
- '@id' => id_uri,
132
- 'profile' => described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE
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('type', '@id', 'id', 'profile')
137
- expect(service_obj['type']).to eq described_class::IIIF_IMAGE_V2_TYPE
138
- expect(service_obj['id']).to eq id_uri
139
- expect(service_obj['@id']).to eq id_uri
140
- expect(service_obj['profile']).to eq described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE
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 'login service' do
141
+ it "login service" do
143
142
  token_service = described_class.new({
144
- 'id' => 'https://example.org/image/iiif/token',
145
- 'profile' => described_class::IIIF_AUTHENTICATION_V1_TOKEN_PROFILE
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('id', 'profile')
151
- expect(token_service['id']).to eq 'https://example.org/image/iiif/token'
152
- expect(token_service['profile']).to eq described_class::IIIF_AUTHENTICATION_V1_TOKEN_PROFILE
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
- 'id' => 'https://example.org/auth/iiif',
155
- 'profile' => described_class::IIIF_AUTHENTICATION_V1_LOGIN_PROFILE,
156
- 'label' => 'label value',
157
- 'service' => [token_service]
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('id', 'profile', 'label', 'service')
162
- expect(service_obj['id']).to eq 'https://example.org/auth/iiif'
163
- expect(service_obj['profile']).to eq described_class::IIIF_AUTHENTICATION_V1_LOGIN_PROFILE
164
- expect(service_obj['label']).to eq 'label value'
165
- inner_service = service_obj['service'][0]
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('id', 'profile')
170
- expect(inner_service['id']).to eq 'https://example.org/image/iiif/token'
171
- expect(inner_service['profile']).to eq described_class::IIIF_AUTHENTICATION_V1_TOKEN_PROFILE
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 'triply nested service' do
172
+ it "triply nested service" do
174
173
  inner = described_class.new({
175
- 'id' => 'https://example.org/image/iiif/token',
176
- 'profile' => described_class::IIIF_AUTHENTICATION_V1_TOKEN_PROFILE
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
- "@type" => described_class::IIIF_IMAGE_V2_TYPE,
188
- "@id" => "https://example.org/iiif/yy816tv6021_img_1",
189
- "id" => "https://example.org/iiif/yy816tv6021_img_1",
190
- "profile" => described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE,
191
- "service" => [middle]
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 'example from http://prezi3.iiif.io/api/presentation/3.0' do
197
- it 'iiif image v2' do
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['type']).to eq described_class::IIIF_IMAGE_V2_TYPE
209
- expect(service_obj['id']).to eq 'http://example.org/images/book1-page2'
210
- expect(service_obj['@id']).to eq 'http://example.org/images/book1-page2'
211
- expect(service_obj['profile']).to eq described_class::IIIF_IMAGE_V2_LEVEL1_PROFILE
212
- expect(service_obj['height']).to eq 8000
213
- expect(service_obj['width']).to eq 6000
214
- expect(service_obj['tiles']).to eq [{"width" => 512, "scaleFactors" => [1,2,4,8,16]}]
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 'it has the appropriate methods for abstract_resource_only_keys v3' do
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]}=", 'Foo') }.to raise_error e
18
+ expect { subject.send("#{entry[:key]}=", "Foo") }.to raise_error e
21
19
  end
22
20
  end
23
21
 
24
- describe "#{entry[:key]}" do
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("#{entry[:key].camelize(:lower)}")).to eq @ex
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 'it has the appropriate methods for any-type keys v3' do
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("[]=", prop, fixed_values[prop])
20
- expect(subject.send("#{prop}")).to eq fixed_values[prop]
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("[]=", prop, fixed_values[prop])
25
- expect(subject.send("#{prop.camelize(:lower)}")).to eq fixed_values[prop]
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 'it has the appropriate methods for array-only keys v3' do
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 = [{'label' => 'XYZ'}]
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 = [{'label' => 'XYZ'}]
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 'raises an exception when attempting to set it to something other than an Array' do
19
- expect { subject.send("#{prop}=", 'Foo') }.to raise_error IIIF::V3::Presentation::IllegalValueError
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 "#{prop}" do
21
+ describe prop.to_s do
24
22
  it "gets #{prop}" do
25
- ex = [{'label' => 'XYZ'}]
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 = [{'label' => 'XYZ'}]
29
+ ex = [{"label" => "XYZ"}]
32
30
  subject[prop] = ex
33
- expect(subject.send("#{prop.camelize(:lower)}")).to eq ex
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 'it has the appropriate methods for hash-only keys v3' do
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 = {'label' => 'XYZ', 'fooBar' => 'bar'}
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 = {'label' => 'XYZ'}
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 'raises an exception when attempting to set it to something other than a Hash' do
19
- expect { subject.send("#{prop}=", ['Foo']) }.to raise_error IIIF::V3::Presentation::IllegalValueError
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 "#{prop}" do
21
+ describe prop.to_s do
24
22
  it "gets #{prop}" do
25
- ex = {'label' => 'XYZ', 'fooBar' => 'bar'}
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 = {'fooBar' => 'bar'}
29
+ ex = {"fooBar" => "bar"}
32
30
  subject[prop] = ex
33
- expect(subject.send("#{prop.camelize(:lower)}")).to eq ex
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 'it has the appropriate methods for integer-only keys v3' do
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 'raises an exception when attempting to set it to something other than an Integer' do
20
- expect { subject.send("#{prop}=", 'Foo') }.to raise_error IIIF::V3::Presentation::IllegalValueError
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 'raises an exception when attempting to set it to a negative number' do
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 "#{prop}" do
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("#{prop.camelize(:lower)}")).to eq @ex
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 'it has the appropriate methods for numeric-only keys v3' do
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 'raises an exception when attempting to set it to something other than an Integer' do
20
- expect { subject.send("#{prop}=", 'Foo') }.to raise_error IIIF::V3::Presentation::IllegalValueError
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 'raises an exception when attempting to set it to a negative number' do
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 "#{prop}" do
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("#{prop.camelize(:lower)}")).to eq @ex
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 'it has the appropriate methods for string-only keys v3' do
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 = 'foo'
5
+ ex = "foo"
8
6
  subject.send("#{prop}=", ex)
9
7
  expect(subject[prop]).to eq ex
10
8
  end
11
- it 'raises an exception when attempting to set it to something other than a String' do
12
- expect { subject.send("#{prop}=", ['Foo']) }.to raise_error IIIF::V3::Presentation::IllegalValueError
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 "#{prop}" do
14
+ describe prop.to_s do
17
15
  it "gets #{prop}" do
18
- ex = 'bar'
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