iiif-presentation 1.4.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +8 -1
- data/.standard.yml +1 -0
- data/Gemfile +5 -5
- data/README.md +1 -1
- data/Rakefile +4 -2
- data/VERSION +1 -1
- data/bin/standardrb +16 -0
- data/iiif-presentation.gemspec +23 -23
- data/lib/iiif/hash_behaviours.rb +29 -33
- data/lib/iiif/ordered_hash.rb +33 -33
- data/lib/iiif/presentation/abstract_resource.rb +17 -22
- data/lib/iiif/presentation/annotation.rb +9 -11
- data/lib/iiif/presentation/annotation_list.rb +8 -10
- data/lib/iiif/presentation/canvas.rb +11 -13
- data/lib/iiif/presentation/collection.rb +7 -9
- data/lib/iiif/presentation/image_resource.rb +33 -35
- data/lib/iiif/presentation/layer.rb +8 -10
- data/lib/iiif/presentation/manifest.rb +9 -12
- data/lib/iiif/presentation/range.rb +8 -10
- data/lib/iiif/presentation/resource.rb +5 -7
- data/lib/iiif/presentation/sequence.rb +8 -11
- data/lib/iiif/presentation/service.rb +1 -2
- data/lib/iiif/presentation.rb +7 -7
- data/lib/iiif/service.rb +121 -102
- data/lib/iiif/v3/abstract_resource.rb +127 -130
- data/lib/iiif/v3/presentation/annotation.rb +20 -21
- data/lib/iiif/v3/presentation/annotation_collection.rb +7 -9
- data/lib/iiif/v3/presentation/annotation_page.rb +14 -15
- data/lib/iiif/v3/presentation/canvas.rb +21 -22
- data/lib/iiif/v3/presentation/choice.rb +14 -15
- data/lib/iiif/v3/presentation/collection.rb +7 -8
- data/lib/iiif/v3/presentation/image_resource.rb +21 -22
- data/lib/iiif/v3/presentation/manifest.rb +18 -19
- data/lib/iiif/v3/presentation/nav_place.rb +125 -29
- data/lib/iiif/v3/presentation/range.rb +10 -10
- data/lib/iiif/v3/presentation/resource.rb +4 -5
- data/lib/iiif/v3/presentation/sequence.rb +10 -11
- data/lib/iiif/v3/presentation/service.rb +12 -13
- data/lib/iiif/v3/presentation.rb +8 -8
- data/spec/integration/iiif/presentation/image_resource_spec.rb +54 -58
- data/spec/integration/iiif/service_spec.rb +76 -77
- data/spec/integration/iiif/v3/abstract_resource_spec.rb +72 -73
- data/spec/integration/iiif/v3/presentation/image_resource_spec.rb +53 -56
- data/spec/spec_helper.rb +56 -64
- data/spec/unit/iiif/hash_behaviours_spec.rb +384 -387
- data/spec/unit/iiif/ordered_hash_spec.rb +86 -91
- data/spec/unit/iiif/presentation/abstract_resource_spec.rb +64 -70
- data/spec/unit/iiif/presentation/annotation_list_spec.rb +1 -3
- data/spec/unit/iiif/presentation/annotation_spec.rb +1 -3
- data/spec/unit/iiif/presentation/canvas_spec.rb +11 -14
- data/spec/unit/iiif/presentation/collection_spec.rb +26 -33
- data/spec/unit/iiif/presentation/image_resource_spec.rb +4 -6
- data/spec/unit/iiif/presentation/layer_spec.rb +16 -20
- data/spec/unit/iiif/presentation/manifest_spec.rb +45 -48
- data/spec/unit/iiif/presentation/range_spec.rb +18 -22
- data/spec/unit/iiif/presentation/resource_spec.rb +3 -6
- data/spec/unit/iiif/presentation/sequence_spec.rb +58 -63
- data/spec/unit/iiif/presentation/shared_examples/abstract_resource_only_keys.rb +4 -10
- data/spec/unit/iiif/presentation/shared_examples/any_type_keys.rb +5 -9
- data/spec/unit/iiif/presentation/shared_examples/array_only_keys.rb +9 -17
- data/spec/unit/iiif/presentation/shared_examples/int_only_keys.rb +6 -14
- data/spec/unit/iiif/presentation/shared_examples/string_only_keys.rb +6 -13
- data/spec/unit/iiif/service_spec.rb +8 -13
- data/spec/unit/iiif/v3/abstract_resource_define_methods_for_spec.rb +39 -37
- data/spec/unit/iiif/v3/abstract_resource_spec.rb +124 -131
- data/spec/unit/iiif/v3/presentation/annotation_collection_spec.rb +14 -17
- data/spec/unit/iiif/v3/presentation/annotation_page_spec.rb +71 -69
- data/spec/unit/iiif/v3/presentation/annotation_spec.rb +249 -233
- data/spec/unit/iiif/v3/presentation/canvas_spec.rb +211 -193
- data/spec/unit/iiif/v3/presentation/choice_spec.rb +81 -77
- data/spec/unit/iiif/v3/presentation/collection_spec.rb +24 -29
- data/spec/unit/iiif/v3/presentation/image_resource_spec.rb +70 -71
- data/spec/unit/iiif/v3/presentation/manifest_spec.rb +248 -235
- data/spec/unit/iiif/v3/presentation/nav_place_spec.rb +249 -49
- data/spec/unit/iiif/v3/presentation/range_spec.rb +28 -29
- data/spec/unit/iiif/v3/presentation/resource_spec.rb +83 -82
- data/spec/unit/iiif/v3/presentation/sequence_spec.rb +125 -119
- data/spec/unit/iiif/v3/presentation/service_spec.rb +123 -124
- data/spec/unit/iiif/v3/presentation/shared_examples/abstract_resource_only_keys.rb +4 -8
- data/spec/unit/iiif/v3/presentation/shared_examples/any_type_keys.rb +5 -7
- data/spec/unit/iiif/v3/presentation/shared_examples/array_only_keys.rb +9 -13
- data/spec/unit/iiif/v3/presentation/shared_examples/hash_only_keys.rb +9 -13
- data/spec/unit/iiif/v3/presentation/shared_examples/int_only_keys.rb +6 -10
- data/spec/unit/iiif/v3/presentation/shared_examples/numeric_only_keys.rb +6 -10
- data/spec/unit/iiif/v3/presentation/shared_examples/string_only_keys.rb +6 -10
- data/spec/unit/iiif/v3/presentation/shared_examples/uri_only_keys.rb +9 -13
- metadata +26 -65
|
@@ -1,118 +1,115 @@
|
|
|
1
1
|
describe IIIF::V3::Presentation::ImageResource do
|
|
2
2
|
vcr_options = {
|
|
3
|
-
cassette_name:
|
|
3
|
+
cassette_name: "pul_loris_cassette_v3",
|
|
4
4
|
record: :new_episodes,
|
|
5
5
|
serialize_with: :json
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
describe
|
|
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 =
|
|
12
|
+
id = "pudl0001%2F4612422%2F00000001.jp2"
|
|
14
13
|
"#{image_server}/#{id}"
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
let(:invalid_service_id) {
|
|
18
|
-
id =
|
|
17
|
+
id = "xxxx%2F4612422%2F00000001.jp2"
|
|
19
18
|
"#{image_server}/#{id}"
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
it
|
|
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
|
-
|
|
29
|
-
|
|
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[
|
|
33
|
-
expect(resource[
|
|
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[
|
|
38
|
-
expect(resource.service.first[
|
|
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
|
|
41
|
-
opts = {
|
|
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[
|
|
45
|
-
expect(resource[
|
|
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[
|
|
50
|
-
|
|
47
|
+
expect(resource.service.first["profile"]).to eq [
|
|
48
|
+
"http://iiif.io/api/image/2/level2.json",
|
|
51
49
|
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
"supports" => [
|
|
51
|
+
"canonicalLinkHeader", "profileLinkHeader", "mirroring",
|
|
52
|
+
"rotationArbitrary", "regionSquare", "sizeAboveFull"
|
|
55
53
|
],
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
"qualities" => ["default", "bitonal", "gray", "color"],
|
|
55
|
+
"formats" => ["jpg", "png", "gif", "webp"]
|
|
58
56
|
}
|
|
59
57
|
]
|
|
60
|
-
expect(resource.service.first[
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
expect(resource.service.first[
|
|
65
|
-
{
|
|
66
|
-
{
|
|
67
|
-
{
|
|
68
|
-
{
|
|
69
|
-
{
|
|
70
|
-
{
|
|
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[
|
|
73
|
-
expect(resource.service.first).not_to have_key(
|
|
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
|
|
78
|
-
it
|
|
79
|
-
r_id =
|
|
80
|
-
opts = {
|
|
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[
|
|
80
|
+
expect(resource["id"]).to eq r_id
|
|
83
81
|
end
|
|
84
|
-
it
|
|
82
|
+
it ":width" do
|
|
85
83
|
width = 42
|
|
86
|
-
opts = {
|
|
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
|
|
88
|
+
it ":height" do
|
|
91
89
|
height = 42
|
|
92
|
-
opts = {
|
|
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
|
|
97
|
-
profile =
|
|
98
|
-
opts = {
|
|
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[
|
|
98
|
+
expect(resource.service.first["profile"]).to eq profile
|
|
101
99
|
end
|
|
102
100
|
end
|
|
103
101
|
|
|
104
|
-
describe
|
|
105
|
-
it
|
|
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
|
|
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
|
-
|
|
2
|
-
require
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
require
|
|
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
|
|
13
|
-
require
|
|
14
|
+
require "vcr"
|
|
15
|
+
require "webmock/rspec"
|
|
14
16
|
|
|
15
17
|
VCR.configure do |c|
|
|
16
|
-
c.cassette_library_dir =
|
|
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
|
-
|
|
72
|
-
#
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
config.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
# - http://
|
|
82
|
-
# - http://
|
|
83
|
-
#
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
#
|
|
91
|
-
#
|
|
92
|
-
#
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
#
|
|
101
|
-
#
|
|
102
|
-
#
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
#
|
|
106
|
-
#
|
|
107
|
-
#
|
|
108
|
-
#
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
#
|
|
112
|
-
#
|
|
113
|
-
#
|
|
114
|
-
#
|
|
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
|