Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility with Ruby 3 #53

Merged
merged 4 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ workflows:
version: 2
ci:
jobs:
- test:
name: "ruby3-0"
ruby_version: "3.0.0"
- test:
name: "ruby2-7"
ruby_version: "2.7.0"
Expand Down
4 changes: 2 additions & 2 deletions lib/iiif_manifest/manifest_service_locator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ def iiif_autocomplete_service_factory

class InjectedFactory
attr_reader :factory, :hash_args
def initialize(factory, hash_args)
def initialize(factory, **hash_args)
@hash_args = hash_args
@factory = factory
end

def new(*args)
factory.new(*args, hash_args)
factory.new(*args, **hash_args)
end
end
end
Expand Down
8 changes: 0 additions & 8 deletions spec/lib/iiif_manifest/manifest_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,9 @@ def display_image
let(:file_presenter) { DisplayImagePresenter.new }

it 'returns a sequence' do
allow(IIIFManifest::ManifestBuilder::CanvasBuilder).to receive(:new).and_call_original
allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter])

result

expect(IIIFManifest::ManifestBuilder::CanvasBuilder).to have_received(:new)
.exactly(1).times.with(file_presenter, anything, anything)
end
it 'builds a structure if it can' do
allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter])
Expand All @@ -115,7 +111,6 @@ def display_image
let(:file_presenter) { DisplayImagePresenter.new }

it 'does not have a rendering on the sequence' do
allow(IIIFManifest::ManifestBuilder::CanvasBuilder).to receive(:new).and_call_original
allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter])
expect(result['sequences'][0]['rendering']).to eq []
end
Expand Down Expand Up @@ -155,7 +150,6 @@ def sequence_rendering
end

it 'has a rendering on the sequence' do
allow(IIIFManifest::ManifestBuilder::CanvasBuilder).to receive(:new).and_call_original
allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter])

expect(result['sequences'][0]['rendering']).to eq [{
Expand All @@ -168,7 +162,6 @@ def sequence_rendering
let(:file_presenter) { DisplayImagePresenter.new }

it 'does not have a metadata element' do
allow(IIIFManifest::ManifestBuilder::CanvasBuilder).to receive(:new).and_call_original
allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter])
expect(result['metadata']).to eq nil
end
Expand Down Expand Up @@ -197,7 +190,6 @@ def sequence_rendering
let(:file_presenter) { DisplayImagePresenter.new }

it 'does not have a service element' do
allow(IIIFManifest::ManifestBuilder::CanvasBuilder).to receive(:new).and_call_original
allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter])
expect(result['service']).to eq nil
end
Expand Down
8 changes: 0 additions & 8 deletions spec/lib/iiif_manifest/v3/manifest_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,10 @@ def display_image
let(:file_presenter) { DisplayImagePresenter.new }

it 'returns items' do
allow(IIIFManifest::V3::ManifestBuilder::CanvasBuilder).to receive(:new).and_call_original
allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter])

result

expect(IIIFManifest::V3::ManifestBuilder::CanvasBuilder).to have_received(:new)
.exactly(1).times.with(file_presenter, anything, anything)
expect(result['items'].length).to eq 1
expect(result['items'].first['type']).to eq 'Canvas'
expect(result['items'].first['id']).to eq 'http://test.host/books/book-77/manifest/canvas/test-22'
Expand Down Expand Up @@ -153,7 +150,6 @@ def display_image
let(:file_presenter) { DisplayImagePresenter.new }

it 'does not have a rendering on the sequence' do
allow(IIIFManifest::V3::ManifestBuilder::CanvasBuilder).to receive(:new).and_call_original
allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter])
expect(result['rendering']).to eq []
end
Expand Down Expand Up @@ -195,7 +191,6 @@ def sequence_rendering
end

it 'has a rendering on the canvas' do
allow(IIIFManifest::V3::ManifestBuilder::CanvasBuilder).to receive(:new).and_call_original
allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter])

expect(result['rendering']).to eq [{
Expand All @@ -210,7 +205,6 @@ def sequence_rendering
let(:file_presenter) { DisplayImagePresenter.new }

it 'does not have a metadata element' do
allow(IIIFManifest::V3::ManifestBuilder::CanvasBuilder).to receive(:new).and_call_original
allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter])
expect(result['metadata']).to eq nil
end
Expand Down Expand Up @@ -251,7 +245,6 @@ def sequence_rendering
let(:file_presenter) { DisplayImagePresenter.new }

it 'does not have a service element' do
allow(IIIFManifest::V3::ManifestBuilder::CanvasBuilder).to receive(:new).and_call_original
allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter])
expect(result['service']).to eq nil
end
Expand Down Expand Up @@ -416,7 +409,6 @@ def display_content
end
end

allow(IIIFManifest::V3::ManifestBuilder::CanvasBuilder).to receive(:new).and_call_original
allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter])
end

Expand Down