Skip to content

Commit

Permalink
rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
labradford committed Apr 26, 2023
1 parent f1442d3 commit be6f969
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Hyrax
module IiifAv
# main reasons for this decorator is to override variable names from hyrax-iiif_av
Expand Down Expand Up @@ -39,22 +41,26 @@ def video_display_content(_url, label = '')
width = Array(solr_document.width).first.try(:to_i) || 320
height = Array(solr_document.height).first.try(:to_i) || 240
duration = conformed_duration_in_seconds
# rubocop:disable Metrics/LineLength
IIIFManifest::V3::DisplayContent.new(Hyrax::IiifAv::Engine.routes.url_helpers.iiif_av_content_url(solr_document.id, label: label, host: request.base_url),
label: label,
width: width,
height: height,
duration: duration,
type: 'Video',
format: solr_document.mime_type)
# rubocop:enable Metrics/LineLength
end

def audio_display_content(_url, label = '')
duration = conformed_duration_in_seconds
# rubocop:disable Metrics/LineLength
IIIFManifest::V3::DisplayContent.new(Hyrax::IiifAv::Engine.routes.url_helpers.iiif_av_content_url(solr_document.id, label: label, host: request.base_url),
label: label,
duration: duration,
type: 'Sound',
format: solr_document.mime_type)
# rubocop:enable Metrics/LineLength
end

def conformed_duration_in_seconds
Expand All @@ -74,4 +80,4 @@ def conformed_duration_in_seconds
end
end

Hyrax::IiifAv::DisplaysContent.prepend(Hyrax::IiifAv::DisplaysContentDecorator)
Hyrax::IiifAv::DisplaysContent.prepend(Hyrax::IiifAv::DisplaysContentDecorator)
19 changes: 9 additions & 10 deletions app/presenters/hyku/work_show_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class WorkShowPresenter < Hyrax::WorkShowPresenter
include Hyrax::IiifAv::DisplaysIiifAv
Hyrax::MemberPresenterFactory.file_presenter_class = Hyrax::IiifAv::IiifFileSetPresenter


delegate :title_or_label, :extent, to: :solr_document

# OVERRIDE Hyrax v2.9.0 here to make featured collections work
Expand Down Expand Up @@ -69,17 +68,17 @@ def iiif_viewer?

private

def iiif_media?(presenter: representative_presenter)
presenter.image? || presenter.video? || presenter.audio?
end
def iiif_media?(presenter: representative_presenter)
presenter.image? || presenter.video? || presenter.audio?
end

def members_include_viewable?
file_set_presenters.any? do |presenter|
iiif_media?(presenter: presenter) && current_ability.can?(:read, presenter.id)
def members_include_viewable?
file_set_presenters.any? do |presenter|
iiif_media?(presenter: presenter) && current_ability.can?(:read, presenter.id)
end
end
end

def extract_from_identifier(rgx)

def extract_from_identifier(rgx)
if solr_document['identifier_tesim'].present?
ref = solr_document['identifier_tesim'].map do |str|
str.scan(rgx)
Expand Down
2 changes: 2 additions & 0 deletions app/services/hyrax/manifest_builder_service_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Hyrax
module ManifestBuilderServiceDecorator
private
Expand Down
2 changes: 1 addition & 1 deletion spec/presenters/hyku/work_show_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
it { is_expected.to be true }
end
end

context "when the work has valid doi and isbns" do
# the values are set in generic_works factory
describe "#doi" do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe Hyrax::IiifManifestPresenter::DisplayImagePresenter do
let(:presenter) { described_class.new(work) }

Expand Down
4 changes: 3 additions & 1 deletion spec/presenters/hyrax/iiif_manifest_presenter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

RSpec.describe Hyrax::IiifManifestPresenter do
subject(:presenter) { described_class.new(work) }

let(:work) { double(GenericWork) }

# verify that the decorator is being loaded
it { is_expected.to respond_to(:iiif_version) }
end
end

0 comments on commit be6f969

Please sign in to comment.