Skip to content

Commit

Permalink
Merge branch 'main' into issues-54-rename-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
bess authored Apr 7, 2022
2 parents 35022db + 1ad6109 commit 3311b65
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 22 deletions.
19 changes: 2 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Code: [![CircleCI](https://circleci.com/gh/samvera/iiif_manifest.svg?style=svg)]

Docs: [![Contribution Guidelines](http://img.shields.io/badge/CONTRIBUTING-Guidelines-blue.svg)](./CONTRIBUTING.md) [![Apache 2.0 License](http://img.shields.io/badge/APACHE2-license-blue.svg)](./LICENSE)

Jump in: [![Slack Status](http://slack.samvera.org/badge.svg)](http://slack.samvera.org/)
Join the conversation on slack: [![Slack Status](https://raw.githubusercontent.com/samvera/maintenance/main/assets/slack_icon.png)](http://slack.samvera.org/)

# What is IIIFManifest

Expand Down Expand Up @@ -171,21 +171,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To

Bug reports and pull requests are welcome on GitHub at <https://github.com/samvera-labs/iiif_manifest>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## Releasing

1. `bundle install`
2. Increase the version number in `lib/iiif_manifest/version.rb`
3. Increase the same version number in `.github_changelog_generator`
4. Update `CHANGELOG.md` by running this command:

```
github_changelog_generator --user samvera --project iiif_manifest --token YOUR_GITHUB_TOKEN_HERE
```

5. Commit these changes to the master branch

6. Run `rake release`

## Help

The Samvera community is here to help. Please see our [support guide](./SUPPORT.md).
Expand All @@ -194,4 +179,4 @@ The Samvera community is here to help. Please see our [support guide](./SUPPORT.

This software has been developed by and is brought to you by the Samvera community. Learn more at the [Samvera website](http://samvera.org/).

![Samvera Logo](https://wiki.duraspace.org/download/thumbnails/87459292/samvera-fall-font2-200w.png?version=1&modificationDate=1498550535816&api=v2)
![Samvera Logo](https://raw.githubusercontent.com/samvera/maintenance/main/assets/samvera_tree.png)
2 changes: 1 addition & 1 deletion lib/iiif_manifest/manifest_builder/iiif_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def initialize
@inner_hash = initial_attributes
end

delegate :[]=, :[], :as_json, :to_json, :has_key?, to: :inner_hash
delegate :[]=, :[], :as_json, :to_json, :has_key?, :key?, to: :inner_hash

def initial_attributes
{}
Expand Down
6 changes: 3 additions & 3 deletions lib/iiif_manifest/v3/manifest_builder/content_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def initialize(display_content, iiif_annotation_factory:, body_builder_factory:)

def apply(canvas)
annotation['target'] = canvas['id']
canvas['width'] = annotation.body['width']
canvas['height'] = annotation.body['height']
canvas['duration'] = annotation.body['duration']
canvas['width'] = annotation.body['width'] if annotation.body['width'].present?
canvas['height'] = annotation.body['height'] if annotation.body['height'].present?
canvas['duration'] = annotation.body['duration'] if annotation.body['duration'].present?
# Assume first item in canvas is an annotation page
canvas.items.first.items += [annotation]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/iiif_manifest/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module IIIFManifest
VERSION = '1.1.0'.freeze
VERSION = '1.1.1'.freeze
end
70 changes: 70 additions & 0 deletions spec/lib/iiif_manifest/v3/manifest_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def ranges
end
end

class AudioBook < Book
end

class ManifestRange
attr_reader :label, :ranges, :file_set_presenters
def initialize(label:, ranges: [], file_set_presenters: [])
Expand All @@ -67,10 +70,28 @@ def display_image
IIIFManifest::DisplayImage.new(id, width: 100, height: 100, format: 'image/jpeg')
end
end

class AudioFilePresenter
attr_reader :id, :label
def initialize(id: 'test-22', label: 'Disc 1')
@id = id
@label = label
end

def to_s
label
end

def display_content
IIIFManifest::V3::DisplayContent.new(id, type: 'Sound', duration: 360_000, format: 'audio/mp4')
end
end
end

after do
Object.send(:remove_const, :DisplayImagePresenter)
Object.send(:remove_const, :AudioFilePresenter)
Object.send(:remove_const, :AudioBook)
Object.send(:remove_const, :Book)
end

Expand Down Expand Up @@ -144,6 +165,36 @@ def display_image
expect(sub_range['items'][0]['type']).to eq 'Canvas'
expect(sub_range['items'][0]['id']).to eq 'http://test.host/books/book-77/manifest/canvas/test-22'
end

context 'with audio file' do
let(:presenter_class) { AudioBook }
let(:file_presenter) { AudioFilePresenter.new }

it 'returns items' do
allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter])

result

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'
expect(result['items'].first.key?('height')).to eq false
expect(result['items'].first.key?('width')).to eq false
expect(result['items'].first['duration']).to eq 360_000
expect(result['items'].first['items'].first['type']).to eq 'AnnotationPage'
expect(result['items'].first['items'].first['id']).not_to be_empty
expect(result['items'].first['items'].first['items'].length).to eq 1
expect(result['items'].first['items'].first['items'].first['type']).to eq 'Annotation'
expect(result['items'].first['items'].first['items'].first['motivation']).to eq 'painting'
expect(result['items'].first['items'].first['items'].first['target']).to eq result['items'].first['id']
expect(result['items'].first['items'].first['items'].first['body']['type']).to eq 'Sound'
expect(result['items'].first['items'].first['items'].first['body']['id']).not_to be_empty
expect(result['items'].first['items'].first['items'].first['body'].key?('height')).to eq false
expect(result['items'].first['items'].first['items'].first['body'].key?('width')).to eq false
expect(result['items'].first['items'].first['items'].first['body']['duration']).to eq 360_000
expect(result['items'].first['items'].first['items'].first['body']['format']).to eq 'audio/mp4'
end
end
end

context 'when there is no sequence_rendering method' do
Expand Down Expand Up @@ -454,6 +505,25 @@ def display_content
expect(content_annotation_body['duration']).to eq 100
expect(content_annotation_body['label']).to eq('@none' => ['High'])
end

context 'with audio file' do
let(:content) do
IIIFManifest::V3::DisplayContent.new(SecureRandom.uuid, duration: 100,
type: 'Sound',
format: 'audio/mp4',
label: 'High')
end

it 'returns items' do
expect(content_annotation_body['type']).to eq 'Sound'
expect(content_annotation_body['id']).not_to be_empty
expect(content_annotation_body.key?('height')).to eq false
expect(content_annotation_body.key?('width')).to eq false
expect(content_annotation_body['format']).to eq 'audio/mp4'
expect(content_annotation_body['duration']).to eq 100
expect(content_annotation_body['label']).to eq('@none' => ['High'])
end
end
end

context 'with multiple files' do
Expand Down

0 comments on commit 3311b65

Please sign in to comment.