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,118 +1,115 @@
1
1
  describe IIIF::V3::Presentation::ImageResource do
2
2
  vcr_options = {
3
- cassette_name: 'pul_loris_cassette_v3',
3
+ cassette_name: "pul_loris_cassette_v3",
4
4
  record: :new_episodes,
5
5
  serialize_with: :json
6
6
  }
7
7
 
8
- describe 'self#create_image_api_image_resource', vcr: vcr_options do
9
-
10
- let(:image_server) { 'https://libimages.princeton.edu/loris' }
8
+ describe "self#create_image_api_image_resource", vcr: vcr_options do
9
+ let(:image_server) { "https://libimages.princeton.edu/loris" }
11
10
 
12
11
  let(:valid_service_id) {
13
- id = 'pudl0001%2F4612422%2F00000001.jp2'
12
+ id = "pudl0001%2F4612422%2F00000001.jp2"
14
13
  "#{image_server}/#{id}"
15
14
  }
16
15
 
17
16
  let(:invalid_service_id) {
18
- id = 'xxxx%2F4612422%2F00000001.jp2'
17
+ id = "xxxx%2F4612422%2F00000001.jp2"
19
18
  "#{image_server}/#{id}"
20
19
  }
21
20
 
22
- it 'returns an ImageResource' do
21
+ it "returns an ImageResource" do
23
22
  instance = described_class.create_image_api_image_resource(service_id: valid_service_id)
24
23
  expect(instance.class).to be described_class
25
24
  end
26
25
 
27
-
28
- describe 'has expected values from our fixture' do
29
- it 'when copy_info is false' do
30
- opts = { service_id: valid_service_id }
26
+ describe "has expected values from our fixture" do
27
+ it "when copy_info is false" do
28
+ opts = {service_id: valid_service_id}
31
29
  resource = described_class.create_image_api_image_resource(opts)
32
- expect(resource['id']).to eq 'https://libimages.princeton.edu/loris/pudl0001%2F4612422%2F00000001.jp2/full/!200,200/0/default.jpg'
33
- expect(resource['type']).to eq 'Image'
30
+ expect(resource["id"]).to eq "https://libimages.princeton.edu/loris/pudl0001%2F4612422%2F00000001.jp2/full/!200,200/0/default.jpg"
31
+ expect(resource["type"]).to eq "Image"
34
32
  expect(resource.format).to eq "image/jpeg"
35
33
  expect(resource.width).to eq 3047
36
34
  expect(resource.height).to eq 7200
37
- expect(resource.service.first['id']).to eq 'https://libimages.princeton.edu/loris/pudl0001%2F4612422%2F00000001.jp2'
38
- expect(resource.service.first['profile']).to eq 'http://iiif.io/api/image/2/level2.json'
35
+ expect(resource.service.first["id"]).to eq "https://libimages.princeton.edu/loris/pudl0001%2F4612422%2F00000001.jp2"
36
+ expect(resource.service.first["profile"]).to eq "http://iiif.io/api/image/2/level2.json"
39
37
  end
40
- it 'copies over all teh infos (when copy_info is true)' do
41
- opts = { service_id: valid_service_id, copy_info: true }
38
+ it "copies over all teh infos (when copy_info is true)" do
39
+ opts = {service_id: valid_service_id, copy_info: true}
42
40
  resource = described_class.create_image_api_image_resource(opts)
43
41
 
44
- expect(resource['id']).to eq 'https://libimages.princeton.edu/loris/pudl0001%2F4612422%2F00000001.jp2/full/!200,200/0/default.jpg'
45
- expect(resource['type']).to eq 'Image'
42
+ expect(resource["id"]).to eq "https://libimages.princeton.edu/loris/pudl0001%2F4612422%2F00000001.jp2/full/!200,200/0/default.jpg"
43
+ expect(resource["type"]).to eq "Image"
46
44
  expect(resource.format).to eq "image/jpeg"
47
45
  expect(resource.width).to eq 3047
48
46
  expect(resource.height).to eq 7200
49
- expect(resource.service.first['profile']).to eq [
50
- 'http://iiif.io/api/image/2/level2.json',
47
+ expect(resource.service.first["profile"]).to eq [
48
+ "http://iiif.io/api/image/2/level2.json",
51
49
  {
52
- 'supports' => [
53
- 'canonicalLinkHeader', 'profileLinkHeader', 'mirroring',
54
- 'rotationArbitrary', 'regionSquare', 'sizeAboveFull'
50
+ "supports" => [
51
+ "canonicalLinkHeader", "profileLinkHeader", "mirroring",
52
+ "rotationArbitrary", "regionSquare", "sizeAboveFull"
55
53
  ],
56
- 'qualities' => ['default', 'bitonal', 'gray', 'color'],
57
- 'formats'=>['jpg', 'png', 'gif', 'webp']
54
+ "qualities" => ["default", "bitonal", "gray", "color"],
55
+ "formats" => ["jpg", "png", "gif", "webp"]
58
56
  }
59
57
  ]
60
- expect(resource.service.first['tiles']).to eq [ {
61
- 'width' => 1024,
62
- 'scaleFactors' => [ 1, 2, 4, 8, 16, 32 ]
63
- } ]
64
- expect(resource.service.first['sizes']).to eq [
65
- {'width' => 96, 'height' => 225 },
66
- {'width' => 191, 'height' => 450 },
67
- {'width' => 381, 'height' => 900 },
68
- {'width' => 762, 'height' => 1800 },
69
- {'width' => 1524, 'height' => 3600 },
70
- {'width' => 3047, 'height' => 7200 }
58
+ expect(resource.service.first["tiles"]).to eq [{
59
+ "width" => 1024,
60
+ "scaleFactors" => [1, 2, 4, 8, 16, 32]
61
+ }]
62
+ expect(resource.service.first["sizes"]).to eq [
63
+ {"width" => 96, "height" => 225},
64
+ {"width" => 191, "height" => 450},
65
+ {"width" => 381, "height" => 900},
66
+ {"width" => 762, "height" => 1800},
67
+ {"width" => 1524, "height" => 3600},
68
+ {"width" => 3047, "height" => 7200}
71
69
  ]
72
- expect(resource.service.first['id']).to eq 'https://libimages.princeton.edu/loris/pudl0001%2F4612422%2F00000001.jp2'
73
- expect(resource.service.first).not_to have_key('@id')
70
+ expect(resource.service.first["id"]).to eq "https://libimages.princeton.edu/loris/pudl0001%2F4612422%2F00000001.jp2"
71
+ expect(resource.service.first).not_to have_key("@id")
74
72
  end
75
73
  end
76
74
 
77
- describe 'respects the params we supply' do
78
- it ':resource_id' do
79
- r_id = 'http://example.edu/images/some.jpg'
80
- opts = { service_id: valid_service_id, resource_id: r_id}
75
+ describe "respects the params we supply" do
76
+ it ":resource_id" do
77
+ r_id = "http://example.edu/images/some.jpg"
78
+ opts = {service_id: valid_service_id, resource_id: r_id}
81
79
  resource = described_class.create_image_api_image_resource(opts)
82
- expect(resource['id']).to eq r_id
80
+ expect(resource["id"]).to eq r_id
83
81
  end
84
- it ':width' do
82
+ it ":width" do
85
83
  width = 42
86
- opts = { service_id: valid_service_id, width: width}
84
+ opts = {service_id: valid_service_id, width: width}
87
85
  resource = described_class.create_image_api_image_resource(opts)
88
86
  expect(resource.width).to eq width
89
87
  end
90
- it ':height' do
88
+ it ":height" do
91
89
  height = 42
92
- opts = { service_id: valid_service_id, height: height}
90
+ opts = {service_id: valid_service_id, height: height}
93
91
  resource = described_class.create_image_api_image_resource(opts)
94
92
  expect(resource.height).to eq height
95
93
  end
96
- it ':profile (service[\'profile\'])' do
97
- profile = 'http://iiif.io/api/image/2/level1.json'
98
- opts = { service_id: valid_service_id, profile: profile}
94
+ it ":profile (service['profile'])" do
95
+ profile = "http://iiif.io/api/image/2/level1.json"
96
+ opts = {service_id: valid_service_id, profile: profile}
99
97
  resource = described_class.create_image_api_image_resource(opts)
100
- expect(resource.service.first['profile']).to eq profile
98
+ expect(resource.service.first["profile"]).to eq profile
101
99
  end
102
100
  end
103
101
 
104
- describe 'errors' do
105
- it 'raises if :service_id is not included' do
102
+ describe "errors" do
103
+ it "raises if :service_id is not included" do
106
104
  expect {
107
105
  described_class.create_image_api_image_resource
108
106
  }.to raise_error
109
107
  end
110
- it 'raises if the info can\'t be pulled in' do
108
+ it "raises if the info can't be pulled in" do
111
109
  expect {
112
110
  described_class.create_image_api_image_resource(service_id: invalid_service_id)
113
111
  }.to raise_error
114
112
  end
115
113
  end
116
-
117
114
  end
118
115
  end
data/spec/spec_helper.rb CHANGED
@@ -1,31 +1,25 @@
1
- require 'iiif/presentation'
2
- require 'iiif/v3/presentation'
3
- require 'simplecov'
4
- require 'coveralls'
5
- require 'debug'
1
+ # SimpleCov must start before any library code is loaded, or that code isn't tracked.
2
+ require "simplecov"
3
+ SimpleCov.start
4
+
5
+ require "iiif/presentation"
6
+ require "iiif/v3/presentation"
7
+ require "debug"
6
8
  Dir["#{File.dirname(__FILE__)}/unit/iiif/presentation/shared_examples/*.rb"].each do |f|
7
9
  require f
8
10
  end
9
11
  Dir["#{File.dirname(__FILE__)}/unit/iiif/v3/presentation/shared_examples/*.rb"].each do |f|
10
12
  require f
11
13
  end
12
- require 'vcr'
13
- require 'webmock/rspec'
14
+ require "vcr"
15
+ require "webmock/rspec"
14
16
 
15
17
  VCR.configure do |c|
16
- c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
18
+ c.cassette_library_dir = "spec/fixtures/vcr_cassettes"
17
19
  c.hook_into :faraday
18
20
  c.configure_rspec_metadata!
19
21
  end
20
22
 
21
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
22
- SimpleCov::Formatter::HTMLFormatter,
23
- Coveralls::SimpleCov::Formatter
24
- ]
25
- SimpleCov.start do
26
- add_filter 'spec/'
27
- end
28
-
29
23
  # This file was generated by the `rspec --init` command. Conventionally, all
30
24
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
31
25
  # The generated `.rspec` file contains `--require spec_helper` which will cause this
@@ -66,52 +60,50 @@ RSpec.configure do |config|
66
60
  mocks.verify_partial_doubles = true
67
61
  end
68
62
 
69
- # The settings below are suggested to provide a good initial experience
70
- # with RSpec, but feel free to customize to your heart's content.
71
- =begin
72
- # These two settings work together to allow you to limit a spec run
73
- # to individual examples or groups you care about by tagging them with
74
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
75
- # get run.
76
- config.filter_run :focus
77
- config.run_all_when_everything_filtered = true
78
-
79
- # Limits the available syntax to the non-monkey patched syntax that is recommended.
80
- # For more details, see:
81
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
82
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
83
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
84
- config.disable_monkey_patching!
85
-
86
- # This setting enables warnings. It's recommended, but in some cases may
87
- # be too noisy due to issues in dependencies.
88
- config.warnings = true
89
-
90
- # Many RSpec users commonly either run the entire suite or an individual
91
- # file, and it's useful to allow more verbose output when running an
92
- # individual spec file.
93
- if config.files_to_run.one?
94
- # Use the documentation formatter for detailed output,
95
- # unless a formatter has already been configured
96
- # (e.g. via a command-line flag).
97
- config.default_formatter = 'doc'
98
- end
99
-
100
- # Print the 10 slowest examples and example groups at the
101
- # end of the spec run, to help surface which specs are running
102
- # particularly slow.
103
- config.profile_examples = 10
104
-
105
- # Run specs in random order to surface order dependencies. If you find an
106
- # order dependency and want to debug it, you can fix the order by providing
107
- # the seed, which is printed after each run.
108
- # --seed 1234
109
- config.order = :random
110
-
111
- # Seed global randomization in this process using the `--seed` CLI option.
112
- # Setting this allows you to use `--seed` to deterministically reproduce
113
- # test failures related to randomization by passing the same `--seed` value
114
- # as the one that triggered the failure.
115
- Kernel.srand config.seed
116
- =end
63
+ # The settings below are suggested to provide a good initial experience
64
+ # with RSpec, but feel free to customize to your heart's content.
65
+ # # These two settings work together to allow you to limit a spec run
66
+ # # to individual examples or groups you care about by tagging them with
67
+ # # `:focus` metadata. When nothing is tagged with `:focus`, all examples
68
+ # # get run.
69
+ # config.filter_run :focus
70
+ # config.run_all_when_everything_filtered = true
71
+ #
72
+ # # Limits the available syntax to the non-monkey patched syntax that is recommended.
73
+ # # For more details, see:
74
+ # # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
75
+ # # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
76
+ # # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
77
+ # config.disable_monkey_patching!
78
+ #
79
+ # # This setting enables warnings. It's recommended, but in some cases may
80
+ # # be too noisy due to issues in dependencies.
81
+ # config.warnings = true
82
+ #
83
+ # # Many RSpec users commonly either run the entire suite or an individual
84
+ # # file, and it's useful to allow more verbose output when running an
85
+ # # individual spec file.
86
+ # if config.files_to_run.one?
87
+ # # Use the documentation formatter for detailed output,
88
+ # # unless a formatter has already been configured
89
+ # # (e.g. via a command-line flag).
90
+ # config.default_formatter = 'doc'
91
+ # end
92
+ #
93
+ # # Print the 10 slowest examples and example groups at the
94
+ # # end of the spec run, to help surface which specs are running
95
+ # # particularly slow.
96
+ # config.profile_examples = 10
97
+ #
98
+ # # Run specs in random order to surface order dependencies. If you find an
99
+ # # order dependency and want to debug it, you can fix the order by providing
100
+ # # the seed, which is printed after each run.
101
+ # # --seed 1234
102
+ # config.order = :random
103
+ #
104
+ # # Seed global randomization in this process using the `--seed` CLI option.
105
+ # # Setting this allows you to use `--seed` to deterministically reproduce
106
+ # # test failures related to randomization by passing the same `--seed` value
107
+ # # as the one that triggered the failure.
108
+ # Kernel.srand config.seed
117
109
  end