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