Skip to content

Commit

Permalink
viewingHint -> behavior, @id -> id, @type -> type
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcolvar committed Mar 24, 2018
1 parent b43a8db commit 5803b5d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
7 changes: 6 additions & 1 deletion lib/iiif_manifest/v3/manifest_builder/iiif_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module IIIFManifest::V3
class ManifestBuilder
class IIIFService < IIIFManifest::ManifestBuilder::IIIFService
end

class IIIFManifest < IIIFService
def label
inner_hash['label']
Expand All @@ -17,6 +17,11 @@ def summary=(summary)
inner_hash['summary'] = summary
end

def behavior=(behavior)
return unless behavior.present?
inner_hash['behavior'] = behavior
end

def viewing_direction=(viewing_direction)
return unless viewing_direction.present?
inner_hash['viewingDirection'] = viewing_direction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def apply(manifest)
manifest['id'] = record.manifest_url.to_s
manifest.label = record.to_s
manifest.summary = record.description
manifest.viewing_hint = viewing_hint if viewing_hint.present?
manifest.behavior = viewing_hint if viewing_hint.present?
manifest.viewing_direction = viewing_direction if viewing_direction.present?
manifest.metadata = record.manifest_metadata if valid_metadata?
manifest.service = services if search_service.present?
Expand Down
28 changes: 14 additions & 14 deletions spec/lib/iiif_manifest/v3/manifest_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def display_image
expect(result.label).to eq book_presenter.to_s
end
it 'has an ID' do
expect(result['@id']).to eq 'http://test.host/books/book-77/manifest'
expect(result['id']).to eq 'http://test.host/books/book-77/manifest'
end

context 'when there are no files' do
Expand Down Expand Up @@ -102,7 +102,7 @@ def display_image
expect(structure['viewingHint']).to eq 'top'
expect(structure['canvases']).to be_blank
expect(structure['ranges'].length).to eq 1
expect(structure['ranges'][0]).not_to eq structure['@id']
expect(structure['ranges'][0]).not_to eq structure['id']

sub_range = result['structures'].last
expect(sub_range['ranges']).to be_blank
Expand Down Expand Up @@ -205,10 +205,10 @@ def sequence_rendering
context 'when there is a search_service method' do
let(:search_service) { 'http://test.host/books/book-77/search' }

it 'has a service element with the correct profile, @id and without an embedded service element' do
it 'has a service element with the correct profile, id and without an embedded service element' do
allow(book_presenter).to receive(:search_service).and_return(search_service)
expect(result['service'][0]['profile']).to eq 'http://iiif.io/api/search/0/search'
expect(result['service'][0]['@id']).to eq 'http://test.host/books/book-77/search'
expect(result['service'][0]['profile']).to eq 'http://iiif.io/api/search/1/search'
expect(result['service'][0]['id']).to eq 'http://test.host/books/book-77/search'
expect(result['service'][0]['service']).to eq nil
end
end
Expand All @@ -226,11 +226,11 @@ def sequence_rendering
let(:search_service) { 'http://test.host/books/book-77/search' }
let(:autocomplete_service) { 'http://test.host/books/book-77/autocomplete' }

it 'has a service element within the first service containing @id and profile for the autocomplete service' do
it 'has a service element within the first service containing id and profile for the autocomplete service' do
allow(book_presenter).to receive(:search_service).and_return(search_service)
allow(book_presenter).to receive(:autocomplete_service).and_return(autocomplete_service)
expect(result['service'][0]['service']['@id']).to eq 'http://test.host/books/book-77/autocomplete'
expect(result['service'][0]['service']['profile']).to eq 'http://iiif.io/api/search/0/autocomplete'
expect(result['service'][0]['service']['id']).to eq 'http://test.host/books/book-77/autocomplete'
expect(result['service'][0]['service']['profile']).to eq 'http://iiif.io/api/search/1/autocomplete'
end
end

Expand Down Expand Up @@ -259,19 +259,19 @@ def sequence_rendering
allow(book_presenter).to receive(:work_presenters).and_return([child_work_presenter])
end
it 'returns a IIIF Collection' do
expect(result['@type']).to eq 'sc:Collection'
expect(result['type']).to eq 'Collection'
end
it "doesn't build sequences" do
expect(result['sequences']).to eq nil
end
it 'has a multi-part viewing hint' do
expect(json_result['viewingHint']).to eq 'multi-part'
expect(json_result['behavior']).to eq 'multi-part'
end
it 'builds child manifests' do
expect(result['manifests'].length).to eq 1
first_child = result['manifests'].first
expect(first_child['@id']).to eq 'http://test.host/books/test2/manifest'
expect(first_child['@type']).to eq 'sc:Manifest'
expect(first_child['id']).to eq 'http://test.host/books/test2/manifest'
expect(first_child['type']).to eq 'Manifest'
expect(first_child['label']).to eq child_work_presenter.to_s
end
end
Expand All @@ -287,7 +287,7 @@ def sequence_rendering
allow(child_work_presenter).to receive(:file_set_presenters).and_return([file_presenter2])
end
it 'returns a IIIF Manifest' do
expect(result['@type']).to eq 'sc:Manifest'
expect(result['type']).to eq 'Manifest'
end
it "doesn't build manifests" do
expect(result['manifests']).to eq nil
Expand All @@ -307,7 +307,7 @@ def sequence_rendering
allow(child_work_presenter).to receive(:file_set_presenters).and_return([file_presenter])
end
it 'returns a IIIF Manifest' do
expect(result['@type']).to eq 'sc:Manifest'
expect(result['type']).to eq 'Manifest'
end
it "doesn't build manifests" do
expect(result['manifests']).to eq nil
Expand Down

0 comments on commit 5803b5d

Please sign in to comment.