Skip to content

Commit

Permalink
Add viewingDirection as optional data value on manifest, fixes #12
Browse files Browse the repository at this point in the history
  • Loading branch information
hackartisan committed Nov 28, 2017
1 parent 4c0bf30 commit 7d33b24
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/iiif_manifest/manifest_builder/record_property_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def apply(manifest)
manifest.label = record.to_s
manifest.description = record.description
manifest.viewing_hint = viewing_hint if viewing_hint.present?
manifest.viewing_direction = viewing_direction if viewing_direction.present?
manifest.metadata = record.manifest_metadata if valid_metadata?
manifest
end
Expand All @@ -21,6 +22,10 @@ def viewing_hint
(record.respond_to?(:viewing_hint) && record.send(:viewing_hint))
end

def viewing_direction
(record.respond_to?(:viewing_direction) && record.send(:viewing_direction))
end

# Validate manifest_metadata against the IIIF spec format for metadata
#
# @return [Boolean]
Expand Down
13 changes: 13 additions & 0 deletions spec/lib/iiif_manifest/manifest_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,5 +236,18 @@ def sequence_rendering
expect(result['sequences'].first['canvases'].length).to eq 2
end
end

context 'where there is no viewing_direction method' do
it 'does not have a viewingDirection element' do
expect(result['viewingDirection']).to eq nil
end
end

context 'where there is a viewing_direction method' do
it 'has a viewingDirection' do
allow_any_instance_of(Book).to receive(:viewing_direction).and_return('right-to-left')
expect(result.viewingDirection).to eq 'right-to-left'
end
end
end
end

0 comments on commit 7d33b24

Please sign in to comment.