iiif_print 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +18 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +16 -0
  4. data/.github/workflows/build-lint-test-action.yaml +4 -5
  5. data/.gitignore +5 -4
  6. data/.rubocop.yml +1 -0
  7. data/.solargraph.yml +19 -0
  8. data/Gemfile.lock +1025 -0
  9. data/README.md +98 -9
  10. data/Rakefile +6 -0
  11. data/app/actors/iiif_print/actors/cleanup_file_sets_actor_decorator.rb +24 -0
  12. data/app/actors/iiif_print/actors/file_set_actor_decorator.rb +30 -28
  13. data/app/controllers/iiif_print/split_pdfs_controller.rb +38 -0
  14. data/app/helpers/iiif_print/iiif_helper_decorator.rb +32 -0
  15. data/app/helpers/iiif_print/iiif_print_helper_behavior.rb +23 -0
  16. data/app/helpers/iiif_print_helper.rb +0 -20
  17. data/app/indexers/concerns/iiif_print/child_indexer.rb +9 -3
  18. data/app/indexers/concerns/iiif_print/file_set_indexer.rb +17 -4
  19. data/app/models/concerns/iiif_print/set_child_flag.rb +9 -0
  20. data/app/models/concerns/iiif_print/solr/document.rb +14 -0
  21. data/app/models/iiif_print/iiif_search_decorator.rb +35 -0
  22. data/app/models/iiif_print/iiif_search_response_decorator.rb +25 -2
  23. data/app/models/iiif_print/pending_relationship.rb +3 -0
  24. data/app/presenters/iiif_print/iiif_manifest_presenter_behavior.rb +120 -0
  25. data/app/presenters/iiif_print/iiif_manifest_presenter_factory_behavior.rb +1 -1
  26. data/app/presenters/iiif_print/work_show_presenter_decorator.rb +19 -10
  27. data/app/search_builders/concerns/iiif_print/allinson_flex_fields.rb +15 -0
  28. data/app/search_builders/concerns/iiif_print/highlight_search_params.rb +2 -1
  29. data/app/services/iiif_print/derivative_rodeo_service.rb +382 -0
  30. data/app/services/iiif_print/manifest_builder_service_behavior.rb +88 -31
  31. data/app/services/iiif_print/pluggable_derivative_service.rb +3 -9
  32. data/app/views/catalog/_index_header_list_default.html.erb +13 -0
  33. data/app/views/hyrax/base/_representative_media.html.erb +4 -3
  34. data/app/views/hyrax/base/iiif_viewers/_universal_viewer.html.erb +1 -1
  35. data/app/views/hyrax/file_sets/_actions.html.erb +2 -1
  36. data/app/views/hyrax/file_sets/_show_actions.html.erb +24 -0
  37. data/config/locales/iiif_print.en.yml +4 -0
  38. data/config/routes.rb +3 -0
  39. data/db/migrate/20231110163052_add_model_details_to_iiif_print_pending_relationships.rb +7 -0
  40. data/docker-compose.yml +2 -2
  41. data/iiif_print.gemspec +10 -9
  42. data/lib/generators/iiif_print/install_generator.rb +21 -1
  43. data/lib/generators/iiif_print/templates/config/initializers/iiif_print.rb +11 -4
  44. data/lib/generators/iiif_print/templates/helpers/iiif_print_helper.rb +5 -0
  45. data/lib/iiif_print/base_derivative_service.rb +2 -1
  46. data/lib/iiif_print/blacklight_iiif_search/annotation_decorator.rb +57 -5
  47. data/lib/iiif_print/catalog_search_builder.rb +5 -1
  48. data/lib/iiif_print/configuration.rb +145 -8
  49. data/lib/iiif_print/data/fileset_helper.rb +1 -1
  50. data/lib/iiif_print/data/work_derivatives.rb +3 -3
  51. data/lib/iiif_print/engine.rb +7 -13
  52. data/lib/iiif_print/errors.rb +18 -0
  53. data/lib/iiif_print/homepage_search_builder.rb +17 -0
  54. data/lib/iiif_print/image_tool.rb +12 -8
  55. data/lib/iiif_print/jobs/child_works_from_pdf_job.rb +74 -33
  56. data/lib/iiif_print/jobs/create_relationships_job.rb +80 -31
  57. data/lib/iiif_print/jobs/request_split_pdf_job.rb +31 -0
  58. data/lib/iiif_print/lineage_service.rb +29 -8
  59. data/lib/iiif_print/metadata.rb +67 -48
  60. data/lib/iiif_print/split_pdfs/base_splitter.rb +142 -0
  61. data/lib/iiif_print/split_pdfs/child_work_creation_from_pdf_service.rb +68 -32
  62. data/lib/iiif_print/split_pdfs/derivative_rodeo_splitter.rb +166 -0
  63. data/lib/iiif_print/split_pdfs/destroy_pdf_child_works_service.rb +33 -0
  64. data/lib/iiif_print/split_pdfs/pages_to_jpgs_splitter.rb +19 -0
  65. data/lib/iiif_print/split_pdfs/pages_to_pngs_splitter.rb +26 -0
  66. data/lib/iiif_print/split_pdfs/pages_to_tiffs_splitter.rb +41 -0
  67. data/lib/iiif_print/split_pdfs/pdf_image_extraction_service.rb +64 -59
  68. data/lib/iiif_print/text_extraction/hocr_reader.rb +7 -3
  69. data/lib/iiif_print/text_extraction/page_ocr.rb +5 -4
  70. data/lib/iiif_print/version.rb +1 -1
  71. data/lib/iiif_print.rb +167 -12
  72. data/lib/samvera/derivatives/configuration.rb +83 -0
  73. data/lib/samvera/derivatives/hyrax.rb +129 -0
  74. data/lib/samvera/derivatives.rb +238 -0
  75. data/spec/factories/newspaper_page_solr_document.rb +9 -1
  76. data/spec/fixtures/authorities/licenses.yml +4 -0
  77. data/spec/fixtures/authorities/rights_statements.yml +4 -0
  78. data/spec/iiif_print/base_derivative_service_spec.rb +20 -3
  79. data/spec/iiif_print/blacklight_iiif_search/annotation_decorator_spec.rb +11 -3
  80. data/spec/iiif_print/catalog_search_builder_spec.rb +1 -1
  81. data/spec/iiif_print/configuration_spec.rb +141 -15
  82. data/spec/iiif_print/jobs/child_works_from_pdf_job_spec.rb +7 -2
  83. data/spec/iiif_print/jobs/create_relationships_job_spec.rb +110 -9
  84. data/spec/iiif_print/lineage_service_spec.rb +1 -1
  85. data/spec/iiif_print/metadata_spec.rb +157 -23
  86. data/spec/iiif_print/split_pdfs/base_splitter_spec.rb +27 -0
  87. data/spec/iiif_print/split_pdfs/derivative_rodeo_splitter_spec.rb +80 -0
  88. data/spec/iiif_print/split_pdfs/destroy_pdf_child_works_service_spec.rb +92 -0
  89. data/spec/iiif_print/split_pdfs/pages_to_jpgs_splitter_spec.rb +22 -0
  90. data/spec/iiif_print/split_pdfs/pages_to_pngs_splitter_spec.rb +18 -0
  91. data/spec/iiif_print/split_pdfs/pages_to_tiffs_splitter_spec.rb +19 -0
  92. data/spec/iiif_print/text_extraction/hocr_reader_spec.rb +2 -2
  93. data/spec/iiif_print_spec.rb +125 -5
  94. data/spec/models/iiif_print/iiif_search_decorator_spec.rb +27 -0
  95. data/spec/presenters/iiif_print/iiif_manifest_presenter_behavior_spec.rb +51 -0
  96. data/spec/samvera/derivatives/configuration_spec.rb +41 -0
  97. data/spec/samvera/derivatives/hyrax_spec.rb +62 -0
  98. data/spec/samvera/derivatives_spec.rb +54 -0
  99. data/spec/services/iiif_print/derivative_rodeo_service_spec.rb +103 -0
  100. data/spec/services/iiif_print/manifest_builder_service_behavior_spec.rb +20 -0
  101. data/spec/services/iiif_print/pluggable_derivative_service_spec.rb +8 -11
  102. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  103. data/tasks/copy_authorities_to_test_app.rake +11 -0
  104. data/tasks/iiif_print_dev.rake +4 -4
  105. metadata +123 -35
  106. data/app/helpers/hyrax/iiif_helper.rb +0 -22
  107. data/lib/iiif_print/split_pdfs/pages_into_images_service.rb +0 -130
  108. data/spec/iiif_print/split_pdfs/pages_into_images_service_spec.rb +0 -6
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe IiifPrint::IiifSearchDecorator do
4
+ let(:iiif_config) { { object_relation_field: 'is_page_of_ssim' } }
5
+ let(:parent_document) { double(SolrDocument, id: 'abc123') }
6
+ let(:iiif_search) { BlacklightIiifSearch::IiifSearch.new(params, iiif_config, parent_document) }
7
+
8
+ describe '#solr_params' do
9
+ subject { iiif_search.solr_params }
10
+
11
+ context 'when q is nil' do
12
+ let(:params) { { q: nil } }
13
+
14
+ it 'returns nil:nil' do
15
+ expect(subject).to eq({ q: 'nil:nil' })
16
+ end
17
+ end
18
+
19
+ context 'when q is not nil' do
20
+ let(:params) { { q: 'catscan' } }
21
+
22
+ it 'returns a query with the search term and filters for child or parent id' do
23
+ expect(subject).to eq({ q: "catscan AND (is_page_of_ssim:\"abc123\" OR id:\"abc123\")", rows: 50, page: nil })
24
+ end
25
+ end
26
+ end
27
+ end
@@ -16,4 +16,55 @@ RSpec.describe IiifPrint::IiifManifestPresenterBehavior do
16
16
  expect(presenter.search_service).to include("#{solr_document.id}/iiif_search")
17
17
  end
18
18
  end
19
+
20
+ context 'with IIIF external support' do
21
+ let(:presenter) { Hyrax::IiifManifestPresenter::DisplayImagePresenter.new(solr_document) }
22
+ let(:id) { 'abc123' }
23
+ let(:url) { 'external_iiif_url' }
24
+ let(:iiif_info_url_builder) { ->(file_id, base_url) { "#{base_url}/#{file_id}" } }
25
+
26
+ before { allow(solr_document).to receive(:image?).and_return(true) }
27
+
28
+ context 'when external iiif is enabled' do
29
+ before do
30
+ allow(ENV).to receive(:[])
31
+ allow(ENV).to receive(:[]).with('EXTERNAL_IIIF_URL').and_return(url)
32
+ allow(presenter).to receive(:latest_file_id).and_return(id)
33
+ end
34
+
35
+ describe '#display_image' do
36
+ it 'renders a external url' do
37
+ expect(presenter.display_image.iiif_endpoint.url).to eq "#{url}/#{id}"
38
+ expect(presenter.display_image.iiif_endpoint.profile).to eq "http://iiif.io/api/image/2/level2.json"
39
+ end
40
+ end
41
+
42
+ describe '#display_content' do
43
+ it 'renders a external url' do
44
+ expect(presenter.display_content.iiif_endpoint.url).to eq "#{url}/#{id}"
45
+ expect(presenter.display_content.iiif_endpoint.profile).to eq "http://iiif.io/api/image/2/level2.json"
46
+ end
47
+ end
48
+ end
49
+
50
+ context 'when external iiif is not enabled' do
51
+ before do
52
+ allow(presenter).to receive(:latest_file_id).and_return(id)
53
+ allow(Hyrax.config).to receive(:iiif_image_server?).and_return(true)
54
+ allow(Hyrax.config).to receive(:iiif_info_url_builder).and_return(iiif_info_url_builder)
55
+ end
56
+
57
+ describe '#display_image' do
58
+ it 'does not render a external url' do
59
+ expect(presenter.display_image.iiif_endpoint.url).to eq "localhost/#{id}"
60
+ end
61
+ end
62
+
63
+ describe '#display_content' do
64
+ it 'does not render a external url' do
65
+ expect(presenter.display_content.iiif_endpoint.url).to eq "localhost/#{id}"
66
+ end
67
+ end
68
+ end
69
+ end
19
70
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'samvera/derivatives/configuration'
5
+
6
+ RSpec.describe Samvera::Derivatives::Configuration do
7
+ let(:file_set) { double(:file_set) }
8
+ let(:config) { described_class.new }
9
+
10
+ describe '#registry_for' do
11
+ it 'has a applicable_for that is falsey' do
12
+ register = config.registry_for(type: :thumbnail)
13
+ expect(register.applicable_for?(file_set: file_set)).to be_falsey
14
+ end
15
+ end
16
+
17
+ describe '#register' do
18
+ it 'amends the existing registry' do
19
+ locator = double
20
+ type = :thumbnail
21
+ expect do
22
+ config.register(type: type, locators: [locator], applicators: [])
23
+ end.to change { config.registry_for(type: type).locators }.from([]).to([locator])
24
+ end
25
+
26
+ context 'validation' do
27
+ it 'defaults to a truthy validator' do
28
+ registry = config.register(type: :thumbnail, locators: [], applicators: [])
29
+ expect(registry.applicable_for?(file_set: file_set)).to be_truthy
30
+ end
31
+
32
+ it 'allows for block configuration' do
33
+ registry = config.register(type: :thumbnail, locators: [], applicators: []) do |_file_set|
34
+ false
35
+ end
36
+
37
+ expect(registry.applicable_for?(file_set: file_set)).to be_falsey
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+ require 'samvera/derivatives'
4
+ require 'samvera/derivatives/hyrax'
5
+
6
+ RSpec.describe Samvera::Derivatives::Hyrax::ServiceShim do
7
+ let(:config) { Samvera::Derivatives::Configuration.new }
8
+ let(:file_set) { FileSet.new }
9
+ let(:other_locator) { double('Locator', locate: nil) }
10
+ let(:other_applicator) { double('Applicator', apply!: nil) }
11
+ before do
12
+ config.register(
13
+ type: :thumbnail,
14
+ locators: [other_locator, Samvera::Derivatives::Hyrax::FileLocatorStrategy],
15
+ applicators: [other_applicator, Samvera::Derivatives::Hyrax::FileApplicatorStrategy]
16
+ ) { |_file_set| true }
17
+ config.register(
18
+ type: :jpg,
19
+ locators: [other_locator, Samvera::Derivatives::Hyrax::FileLocatorStrategy],
20
+ applicators: [other_applicator, Samvera::Derivatives::Hyrax::FileApplicatorStrategy]
21
+ ) { |_file_set| true }
22
+ end
23
+
24
+ let(:shim) { described_class.new(file_set, candidate_derivative_types: [:thumnail, :jpg], config: config) }
25
+
26
+ subject { shim }
27
+
28
+ it { is_expected.to be_valid }
29
+
30
+ describe '#create_derivatives' do
31
+ let(:file_path) { __FILE__ }
32
+ subject { shim.create_derivatives(file_path) }
33
+
34
+ context 'when other locator and applicator are not applicable' do
35
+ it 'locates and applies the derivatives using the underlying service' do
36
+ expect_any_instance_of(Samvera::Derivatives::Hyrax::FileApplicatorStrategy).to receive(:apply!).and_call_original
37
+ expect_any_instance_of(Samvera::Derivatives::Hyrax::FileSetDerivativesServiceWrapper).to receive(:apply!).and_call_original
38
+ expect_any_instance_of(::Hyrax::FileSetDerivativesService).to receive(:valid?).and_return(true)
39
+ expect_any_instance_of(::Hyrax::FileSetDerivativesService).to receive(:create_derivatives).with(file_path)
40
+ expect(other_applicator).to receive(:apply!)
41
+
42
+ subject
43
+ end
44
+ end
45
+
46
+ context 'when the other locator finds the derivative' do
47
+ let(:other_locator) { double(locate: file_path) }
48
+
49
+ it 'uses that located derivative and applies it' do
50
+ # Yes, we will attempt to apply the derivative...
51
+ expect_any_instance_of(Samvera::Derivatives::Hyrax::FileApplicatorStrategy).to receive(:apply!).and_call_original
52
+ # ...however, we won't be leveraging the wrapper's derivative work; meaning no default behavior.
53
+ expect_any_instance_of(Samvera::Derivatives::Hyrax::FileSetDerivativesServiceWrapper).not_to receive(:apply!)
54
+ expect_any_instance_of(::Hyrax::FileSetDerivativesService).not_to receive(:valid?)
55
+ expect_any_instance_of(::Hyrax::FileSetDerivativesService).not_to receive(:create_derivatives)
56
+ expect(other_applicator).to receive(:apply!)
57
+
58
+ subject
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+ require 'samvera/derivatives'
4
+
5
+ RSpec.describe Samvera::Derivatives do
6
+ describe '.config' do
7
+ subject { described_class.config }
8
+
9
+ it { is_expected.to be_a(described_class::Configuration) }
10
+ end
11
+
12
+ describe '.locate_and_apply_derivative_for' do
13
+ let(:file_set) { double(FileSet) }
14
+ let(:file_path) { __FILE__ }
15
+ let(:applicability) { true }
16
+ let(:type) { :thumbnail }
17
+ let(:locator) { described_class::FileLocator::Strategy }
18
+ let(:applicator) { described_class::FileApplicator::Strategy }
19
+
20
+ let(:derivative) do
21
+ described_class::Configuration::RegisteredType.new(
22
+ type: type,
23
+ applicators: [applicator],
24
+ locators: [locator],
25
+ applicability: ->(_) { applicability }
26
+ )
27
+ end
28
+
29
+ subject do
30
+ described_class.locate_and_apply_derivative_for(
31
+ file_set: file_set,
32
+ derivative: derivative,
33
+ file_path: file_path
34
+ )
35
+ end
36
+
37
+ context 'when not applicable' do
38
+ let(:applicability) { false }
39
+
40
+ it { is_expected.to be_falsey }
41
+ end
42
+
43
+ context 'when applicable' do
44
+ let(:from_location) { :from_location }
45
+
46
+ it 'locates then applies the derivative' do
47
+ expect(locator).to receive(:locate).and_return(from_location)
48
+ expect(applicator).to receive(:apply!).with(file_set: file_set, derivative_type: type, from_location: from_location)
49
+
50
+ subject
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe IiifPrint::DerivativeRodeoService do
6
+ let(:work) { double("Work", { :id => 'work-5678', described_class.parent_work_identifier_property_name => 'hello-1234-id' }) }
7
+ let(:file_set) { FileSet.new.tap { |fs| fs.save!(validate: false) } }
8
+ let(:generator) { DerivativeRodeo::Generators::CopyGenerator }
9
+ let(:output_extension) { "rb" }
10
+
11
+ before do
12
+ allow(file_set).to receive(:parent).and_return(work)
13
+
14
+ # TODO: This is a hack that leverages the internals oof Hydra::Works; not excited about it but
15
+ # this part is only one piece of the over all integration.
16
+ allow(file_set).to receive(:original_file).and_return(double(original_filename: __FILE__))
17
+ end
18
+
19
+ let(:instance) { described_class.new(file_set) }
20
+
21
+ subject(:klass) { described_class }
22
+
23
+ describe '.preprocessed_location_adapter_name' do
24
+ subject { described_class.preprocessed_location_adapter_name }
25
+ it { is_expected.to eq 's3' }
26
+ end
27
+
28
+ describe '.parent_work_identifier_property_name' do
29
+ subject { described_class.parent_work_identifier_property_name }
30
+ it { is_expected.to be_a String }
31
+ end
32
+
33
+ describe '.named_derivatives_and_generators_by_type' do
34
+ subject { described_class.named_derivatives_and_generators_by_type }
35
+ it { is_expected.to be_a Hash }
36
+ end
37
+
38
+ describe '.derivative_rodeo_uri' do
39
+ subject { described_class.derivative_rodeo_uri(file_set: file_set, filename: __FILE__) }
40
+
41
+ context 'when the file_set does not have a parent' do
42
+ xit 'is expected to raise an error' do
43
+ expect { subject }.to raise_error(IiifPrint::DataError)
44
+ end
45
+ end
46
+
47
+ context 'when the file_set has a parent' do
48
+ it { is_expected.to start_with("#{described_class.preprocessed_location_adapter_name}://") }
49
+ it { is_expected.to end_with(File.basename(__FILE__)) }
50
+ end
51
+
52
+ context 'for a thumbnail based on a PDF' do
53
+ let(:extension) { DerivativeRodeo::Generators::ThumbnailGenerator.output_extension }
54
+ let(:filename) { "/tmp/d20230714-1897-1wgmauo/#{work.aark_id}.ARCHIVAL.pdf" }
55
+ it 'has the correct filename' do
56
+ expect(described_class.derivative_rodeo_uri(file_set: file_set, filename: filename, extension: extension,
57
+ adapter_name: 'file')).to eq("file://#{work.aark_id}/#{work.aark_id}.ARCHIVAL.#{extension}")
58
+ end
59
+ end
60
+
61
+ context 'for the original file' do
62
+ let(:extension) { nil }
63
+ let(:filename) { "/tmp/d20230714-1897-1wgmauo/#{work.aark_id}.ARCHIVAL.pdf" }
64
+ it 'has the correct filename' do
65
+ expect(described_class.derivative_rodeo_uri(file_set: file_set, filename: filename, extension: extension, adapter_name: 'file')).to eq("file://#{work.aark_id}/#{work.aark_id}.ARCHIVAL.pdf")
66
+ end
67
+ end
68
+ end
69
+
70
+ # TODO: Need Faux Bucket for Derivative Rodeo
71
+ xdescribe '#valid?' do
72
+ subject { instance.valid? }
73
+
74
+ before do
75
+ allow(file_set).to receive(:mime_type).and_return(mime_type)
76
+ allow(file_set).to receive(:parent).and_return(work)
77
+ end
78
+
79
+ context 'when the mime_type of the file is not supported' do
80
+ let(:mime_type) { "text/plain" }
81
+ it { is_expected.to be_falsey }
82
+ end
83
+
84
+ context 'when derivative rodeo has not pre-processed the file set' do
85
+ before { instance.preprocessed_location_adapter_name = "file" }
86
+
87
+ let(:mime_type) { "application/pdf" }
88
+ it { is_expected.to be_falsey }
89
+ end
90
+
91
+ context 'when the mime type is supported and the derivative rodeo has pre-processed the file set' do
92
+ before do
93
+ # TODO: write to the rodeo; consider using AWS's spec support; I want to be able to "fake" S3
94
+ # with a "fake" bucket.
95
+ #
96
+ # Dependent on https://github.com/scientist-softserv/derivative_rodeo/pull/37
97
+ end
98
+
99
+ let(:mime_type) { "application/pdf" }
100
+ it { is_expected.to be_truthy }
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe IiifPrint::ManifestBuilderServiceBehavior do
5
+ context '#initialize' do
6
+ it 'uses defaults to set the version' do
7
+ builder_service = Hyrax::ManifestBuilderService.new
8
+ expect(builder_service.manifest_factory).to eq(::IIIFManifest::ManifestFactory)
9
+ expect(builder_service.version).to eq(IiifPrint.config.default_iiif_manifest_version)
10
+ end
11
+
12
+ it 'allows version overrides' do
13
+ # This in part verifies the expected interaction of the version as a parameter being picked up
14
+ # by another parameter.
15
+ builder_service = Hyrax::ManifestBuilderService.new(version: 3)
16
+ expect(builder_service.manifest_factory).to eq(::IIIFManifest::V3::ManifestFactory)
17
+ expect(builder_service.version).to eq(3)
18
+ end
19
+ end
20
+ end
@@ -111,10 +111,7 @@ RSpec.describe IiifPrint::PluggableDerivativeService do
111
111
  def expected_plugins
112
112
  [
113
113
  Hyrax::FileSetDerivativesService,
114
- IiifPrint::JP2DerivativeService,
115
- IiifPrint::PDFDerivativeService,
116
- IiifPrint::TextExtractionDerivativeService,
117
- IiifPrint::TIFFDerivativeService
114
+ IiifPrint::TextExtractionDerivativeService
118
115
  ]
119
116
  end
120
117
 
@@ -123,7 +120,7 @@ RSpec.describe IiifPrint::PluggableDerivativeService do
123
120
  plugins = described_class.new(persisted_file_set).plugins
124
121
  fs = persisted_file_set
125
122
  services = plugins.map { |plugin| plugin.new(fs) }.select(&:valid?)
126
- expect(services.length).to eq 5
123
+ expect(services.length).to eq 2
127
124
  used_plugins = services.map(&:class)
128
125
  expected_plugins.each do |plugin|
129
126
  expect(used_plugins).to include plugin
@@ -136,8 +133,6 @@ RSpec.describe IiifPrint::PluggableDerivativeService do
136
133
  made = derivatives_for(persisted_file_set)
137
134
  made.each { |path| expect(File.exist?(path)) }
138
135
  extensions = made.map { |path| path.split('.')[-1] }
139
- expect(extensions).to include 'pdf'
140
- expect(extensions).to include 'jp2'
141
136
  expect(extensions).not_to include 'tiff'
142
137
  # Thumbnail, created by Hyrax:
143
138
  expect(extensions).to include 'jpeg'
@@ -154,19 +149,21 @@ RSpec.describe IiifPrint::PluggableDerivativeService do
154
149
  )
155
150
  end
156
151
 
157
- def jp2_plugin?(plugins)
158
- r = plugins.select { |p| p.is_a? IiifPrint::JP2DerivativeService }
152
+ def text_plugin?(plugins)
153
+ r = plugins.select { |p| p.is_a? IiifPrint::TextExtractionDerivativeServiceService }
159
154
  !r.empty?
160
155
  end
161
156
 
162
- it "will not attempt creating over pre-made derivative" do
157
+ # TODO: This is not working with the default configuration and is part of a larger refactor
158
+ # regarding specs.
159
+ xit "will not attempt creating over pre-made derivative" do
163
160
  service = described_class.new(persisted_file_set)
164
161
  # this should be respected, evaluate by obtaining filtered
165
162
  # services list, which must omit JP2DerivativeService
166
163
  plugins = service.services(:create_derivatives)
167
164
  # initially has jp2 plugin
168
165
  expect(jp2_plugin?(plugins)).to be true
169
- # blacklist jp2 by effect of log entry of pre-made attachment
166
+ # deny jp2 by effect of log entry of pre-made attachment
170
167
  log_attachment(service.file_set)
171
168
  # omits, after logging intent of previous attachment:
172
169
  plugins = service.services(:create_derivatives)
@@ -5,7 +5,7 @@ class TestAppGenerator < Rails::Generators::Base
5
5
  source_root File.expand_path('../../../spec/test_app_templates', __dir__)
6
6
 
7
7
  def install_redis
8
- gem 'redis', '4.8.0'
8
+ gem 'redis', '4.8.1'
9
9
  Bundler.with_unbundled_env do
10
10
  run "bundle install"
11
11
  end
@@ -0,0 +1,11 @@
1
+ namespace :engine_cart do
2
+ desc "Copy custom rights_statement and license questioning authority YAML files into the test app"
3
+ task copy_authorities: :generate do
4
+ test_app_path = ENV['ENGINE_CART_DESTINATION'] || File.expand_path(".internal_test_app", File.dirname(__FILE__))
5
+ src_dir = File.expand_path("../spec/fixtures/authorities", __dir__)
6
+ dest_dir = File.join(test_app_path, "config/authorities")
7
+
8
+ FileUtils.mkdir_p(dest_dir)
9
+ FileUtils.cp_r("#{src_dir}/.", dest_dir)
10
+ end
11
+ end
@@ -20,14 +20,14 @@ task :spec_with_app_load do
20
20
  end
21
21
 
22
22
  if ENV.fetch('IN_DOCKER', false)
23
- desc 'Generate the engine_cart and spin up test servers and run specs'
24
- task ci: %w[rubocop engine_cart:generate] do
23
+ desc 'Generate the engine_cart, copy authorities and spin up test servers and run specs'
24
+ task ci: %w[rubocop engine_cart:generate engine_cart:copy_authorities] do
25
25
  puts 'running continuous integration'
26
26
  Rake::Task['spec'].invoke
27
27
  end
28
28
  else
29
- desc 'Generate the engine_cart and spin up test servers and run specs'
30
- task ci: %w[rubocop engine_cart:generate] do
29
+ desc 'Generate the engine_cart, copy authorities and spin up test servers and run specs'
30
+ task ci: %w[rubocop engine_cart:generate engine_cart:copy_authorities] do
31
31
  puts 'running continuous integration'
32
32
  Rake::Task['spec_with_app_load'].invoke
33
33
  end