iiif_print 1.1.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/Gemfile.lock +2 -2
  4. data/README.md +4 -0
  5. data/app/actors/iiif_print/actors/file_set_actor_decorator.rb +1 -1
  6. data/app/indexers/concerns/iiif_print/child_work_indexer.rb +27 -0
  7. data/app/indexers/concerns/iiif_print/file_set_indexer.rb +37 -22
  8. data/{lib → app/jobs}/iiif_print/jobs/application_job.rb +2 -1
  9. data/{lib → app/jobs}/iiif_print/jobs/child_works_from_pdf_job.rb +14 -9
  10. data/{lib → app/jobs}/iiif_print/jobs/create_relationships_job.rb +10 -20
  11. data/app/listeners/iiif_print/listener.rb +31 -0
  12. data/app/models/concerns/iiif_print/set_child_flag.rb +1 -1
  13. data/app/models/concerns/iiif_print/solr/document.rb +5 -3
  14. data/app/presenters/iiif_print/file_set_presenter_decorator.rb +11 -0
  15. data/app/presenters/iiif_print/iiif_manifest_presenter_factory_behavior.rb +1 -1
  16. data/app/presenters/iiif_print/work_show_presenter_decorator.rb +5 -2
  17. data/app/services/iiif_print/manifest_builder_service_behavior.rb +4 -2
  18. data/app/services/iiif_print/pluggable_derivative_service.rb +5 -1
  19. data/app/services/iiif_print/simple_schema_loader_decorator.rb +11 -0
  20. data/app/transactions/hyrax/transactions/iiif_print_container_decorator.rb +34 -0
  21. data/app/transactions/hyrax/transactions/steps/conditionally_destroy_children_from_split.rb +32 -0
  22. data/app/transactions/hyrax/transactions/steps/delete_all_file_sets_decorator.rb +35 -0
  23. data/app/views/hyrax/file_sets/_show_actions.html.erb +1 -1
  24. data/config/initializers/simple_schema_loader.rb +1 -0
  25. data/config/metadata/child_works_from_pdf_splitting.yaml +17 -0
  26. data/db/migrate/20181214181358_create_iiif_print_derivative_attachments.rb +8 -6
  27. data/db/migrate/20190107165909_create_iiif_print_ingest_file_relations.rb +7 -5
  28. data/db/migrate/20230109000000_create_iiif_print_pending_relationships.rb +8 -6
  29. data/db/migrate/20231110163052_add_model_details_to_iiif_print_pending_relationships.rb +3 -3
  30. data/iiif_print.gemspec +1 -1
  31. data/lib/iiif_print/base_derivative_service.rb +13 -2
  32. data/lib/iiif_print/blacklight_iiif_search/annotation_decorator.rb +2 -2
  33. data/lib/iiif_print/catalog_search_builder.rb +2 -2
  34. data/lib/iiif_print/configuration.rb +65 -5
  35. data/lib/iiif_print/data/fileset_helper.rb +2 -2
  36. data/lib/iiif_print/data/work_derivatives.rb +1 -1
  37. data/lib/iiif_print/engine.rb +46 -2
  38. data/lib/iiif_print/homepage_search_builder.rb +2 -2
  39. data/lib/iiif_print/jp2_derivative_service.rb +4 -1
  40. data/lib/iiif_print/lineage_service.rb +19 -6
  41. data/lib/iiif_print/pdf_derivative_service.rb +3 -1
  42. data/lib/iiif_print/persistence_layer/active_fedora_adapter.rb +189 -0
  43. data/lib/iiif_print/persistence_layer/valkyrie_adapter.rb +183 -0
  44. data/lib/iiif_print/persistence_layer.rb +118 -0
  45. data/lib/iiif_print/split_pdfs/base_splitter.rb +11 -0
  46. data/lib/iiif_print/split_pdfs/child_work_creation_from_pdf_service.rb +19 -9
  47. data/lib/iiif_print/split_pdfs/destroy_pdf_child_works_service.rb +5 -16
  48. data/lib/iiif_print/text_extraction_derivative_service.rb +4 -2
  49. data/lib/iiif_print/text_formats_from_alto_service.rb +3 -1
  50. data/lib/iiif_print/tiff_derivative_service.rb +3 -1
  51. data/lib/iiif_print/version.rb +1 -1
  52. data/lib/iiif_print.rb +79 -44
  53. metadata +19 -192
  54. data/app/indexers/concerns/iiif_print/child_indexer.rb +0 -40
  55. data/app/views/hyrax/file_sets/_actions.html.erb +0 -46
  56. data/bin/rails +0 -13
  57. data/spec/.keep.txt +0 -1
  58. data/spec/factories/ability.rb +0 -6
  59. data/spec/factories/newspaper_issue.rb +0 -7
  60. data/spec/factories/newspaper_page.rb +0 -7
  61. data/spec/factories/newspaper_page_solr_document.rb +0 -20
  62. data/spec/factories/newspaper_title.rb +0 -8
  63. data/spec/factories/uploaded_pdf_file.rb +0 -9
  64. data/spec/factories/uploaded_txt_file.rb +0 -9
  65. data/spec/factories/user.rb +0 -13
  66. data/spec/fixtures/authorities/licenses.yml +0 -4
  67. data/spec/fixtures/authorities/rights_statements.yml +0 -4
  68. data/spec/fixtures/files/4.1.07.jp2 +0 -0
  69. data/spec/fixtures/files/4.1.07.tiff +0 -0
  70. data/spec/fixtures/files/README.md +0 -7
  71. data/spec/fixtures/files/alto-2-0.xsd +0 -714
  72. data/spec/fixtures/files/broken-truncated.pdf +0 -0
  73. data/spec/fixtures/files/credits.md +0 -16
  74. data/spec/fixtures/files/lowres-gray-via-ndnp-sample.tiff +0 -0
  75. data/spec/fixtures/files/minimal-1-page.pdf +0 -0
  76. data/spec/fixtures/files/minimal-2-page.pdf +0 -0
  77. data/spec/fixtures/files/minimal-alto.xml +0 -31
  78. data/spec/fixtures/files/ndnp-alto-sample.xml +0 -24
  79. data/spec/fixtures/files/ndnp-sample1-json.json +0 -1
  80. data/spec/fixtures/files/ndnp-sample1-txt.txt +0 -1
  81. data/spec/fixtures/files/ndnp-sample1.pdf +0 -0
  82. data/spec/fixtures/files/ocr_alto.xml +0 -202
  83. data/spec/fixtures/files/ocr_alto_scaled_4pts_per_px.xml +0 -202
  84. data/spec/fixtures/files/ocr_color.tiff +0 -0
  85. data/spec/fixtures/files/ocr_gray.jp2 +0 -0
  86. data/spec/fixtures/files/ocr_gray.tiff +0 -0
  87. data/spec/fixtures/files/ocr_mono.tiff +0 -0
  88. data/spec/fixtures/files/ocr_mono_text_hocr.html +0 -78
  89. data/spec/fixtures/files/page1.tiff +0 -0
  90. data/spec/fixtures/files/sample-4page-issue.pdf +0 -0
  91. data/spec/fixtures/files/sample-color-newsletter.pdf +0 -0
  92. data/spec/fixtures/files/thumbnail.jpg +0 -0
  93. data/spec/helpers/hyrax/iiif_helper_spec.rb +0 -65
  94. data/spec/helpers/iiif_print_helper_spec.rb +0 -43
  95. data/spec/iiif_print/base_derivative_service_spec.rb +0 -28
  96. data/spec/iiif_print/blacklight_iiif_search/annotation_decorator_spec.rb +0 -59
  97. data/spec/iiif_print/catalog_search_builder_spec.rb +0 -60
  98. data/spec/iiif_print/configuration_spec.rb +0 -193
  99. data/spec/iiif_print/data/work_derivatives_spec.rb +0 -245
  100. data/spec/iiif_print/data/work_file_spec.rb +0 -99
  101. data/spec/iiif_print/data/work_files_spec.rb +0 -237
  102. data/spec/iiif_print/image_tool_spec.rb +0 -109
  103. data/spec/iiif_print/jobs/child_works_from_pdf_job_spec.rb +0 -35
  104. data/spec/iiif_print/jobs/create_relationships_job_spec.rb +0 -118
  105. data/spec/iiif_print/jp2_image_metadata_spec.rb +0 -37
  106. data/spec/iiif_print/lineage_service_spec.rb +0 -13
  107. data/spec/iiif_print/metadata_spec.rb +0 -249
  108. data/spec/iiif_print/split_pdfs/base_splitter_spec.rb +0 -27
  109. data/spec/iiif_print/split_pdfs/derivative_rodeo_splitter_spec.rb +0 -80
  110. data/spec/iiif_print/split_pdfs/destroy_pdf_child_works_service_spec.rb +0 -92
  111. data/spec/iiif_print/split_pdfs/pages_to_jpgs_splitter_spec.rb +0 -22
  112. data/spec/iiif_print/split_pdfs/pages_to_pngs_splitter_spec.rb +0 -18
  113. data/spec/iiif_print/split_pdfs/pages_to_tiffs_splitter_spec.rb +0 -19
  114. data/spec/iiif_print/text_extraction/alto_reader_spec.rb +0 -49
  115. data/spec/iiif_print/text_extraction/hocr_reader_spec.rb +0 -45
  116. data/spec/iiif_print/text_extraction/page_ocr_spec.rb +0 -84
  117. data/spec/iiif_print/text_extraction/render_alto_spec.rb +0 -54
  118. data/spec/iiif_print/text_extraction/word_coords_builder_spec.rb +0 -44
  119. data/spec/iiif_print_spec.rb +0 -171
  120. data/spec/misc_shared.rb +0 -111
  121. data/spec/models/iiif_print/derivative_attachment_spec.rb +0 -37
  122. data/spec/models/iiif_print/iiif_search_decorator_spec.rb +0 -27
  123. data/spec/models/iiif_print/ingest_file_relation_spec.rb +0 -56
  124. data/spec/models/solr_document_spec.rb +0 -14
  125. data/spec/presenters/iiif_print/iiif_manifest_presenter_behavior_spec.rb +0 -70
  126. data/spec/presenters/iiif_print/iiif_manifest_presenter_factory_behavior_spec.rb +0 -49
  127. data/spec/samvera/derivatives/configuration_spec.rb +0 -41
  128. data/spec/samvera/derivatives/hyrax_spec.rb +0 -62
  129. data/spec/samvera/derivatives_spec.rb +0 -54
  130. data/spec/services/iiif_print/derivative_rodeo_service_spec.rb +0 -103
  131. data/spec/services/iiif_print/jp2_derivative_service_spec.rb +0 -59
  132. data/spec/services/iiif_print/manifest_builder_service_behavior_spec.rb +0 -20
  133. data/spec/services/iiif_print/pdf_derivative_service_spec.rb +0 -66
  134. data/spec/services/iiif_print/pluggable_derivative_service_spec.rb +0 -175
  135. data/spec/services/iiif_print/text_extraction_derivative_service_spec.rb +0 -82
  136. data/spec/services/iiif_print/text_formats_from_alto_service_spec.rb +0 -127
  137. data/spec/services/iiif_print/tiff_derivative_service_spec.rb +0 -65
  138. data/spec/spec_helper.rb +0 -181
  139. data/spec/support/controller_level_helpers.rb +0 -28
  140. data/spec/support/iiif_print_models.rb +0 -127
  141. data/spec/test_app_templates/blacklight.yml +0 -9
  142. data/spec/test_app_templates/fedora.yml +0 -15
  143. data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -40
  144. data/spec/test_app_templates/redis.yml +0 -9
  145. data/spec/test_app_templates/solr/conf/schema.xml +0 -362
  146. data/spec/test_app_templates/solr/conf/solrconfig.xml +0 -322
  147. data/spec/test_app_templates/solr.yml +0 -7
  148. /data/{lib → app/jobs}/iiif_print/jobs/request_split_pdf_job.rb +0 -0
@@ -1,82 +0,0 @@
1
- require 'nokogiri'
2
- require 'spec_helper'
3
- require 'misc_shared'
4
-
5
- RSpec.describe IiifPrint::TextExtractionDerivativeService do
6
- include_context "shared setup"
7
-
8
- let(:valid_file_set) do
9
- file_set = FileSet.new
10
- file_set.save!(validate: false)
11
- file_set
12
- end
13
-
14
- let(:work) do
15
- work = NewspaperPage.create(title: ["Hello"])
16
- work.members << valid_file_set
17
- work.save!
18
- end
19
-
20
- let(:minimal_alto) do
21
- File.join(fixture_path, 'minimal-alto.xml')
22
- end
23
-
24
- let(:altoxsd) do
25
- xsdpath = File.join(fixture_path, 'alto-2-0.xsd')
26
- Nokogiri::XML::Schema(File.read(xsdpath))
27
- end
28
-
29
- describe "Creates ALTO derivative" do
30
- def source_image(name)
31
- File.join(fixture_path, name)
32
- end
33
-
34
- def expected_path(file_set, ext)
35
- Hyrax::DerivativePath.derivative_path_for_reference(file_set, ext)
36
- end
37
-
38
- def validate_alto(filename)
39
- altoxsd.validate(filename)
40
- end
41
-
42
- def derivative_exists(ext)
43
- path = expected_path(valid_file_set, ext)
44
- expect(File.exist?(path)).to be true
45
- expect(File.size(path)).to be > 0
46
- end
47
-
48
- xit "creates, stores valid ALTO and plain-text derivatives" do
49
- # these are in same test to avoid duplicate OCR operation
50
- service = described_class.new(valid_file_set)
51
- service.create_derivatives(source_image('ocr_mono.tiff'))
52
- # ALTO derivative file exists at expected path and validates:
53
- altoxsd.validate(expected_path(valid_file_set, 'xml'))
54
- # Plain text exists as non-empty file:
55
- derivative_exists('txt')
56
- derivative_exists('json')
57
- json_path = expected_path(valid_file_set, 'json')
58
- loaded_result = JSON.parse(File.read(json_path))
59
- expect(loaded_result['coords'].length).to be > 1
60
- end
61
-
62
- xit "usually uses OCR, when no existing text" do
63
- service = described_class.new(valid_file_set)
64
- # here, service will delegate create_derivatives to OCR impl method:
65
- expect(service).to receive(:create_derivatives_from_ocr)
66
- service.create_derivatives(source_image('ocr_mono.tiff'))
67
- end
68
-
69
- xit "defers to existing ALTO sources, when present" do
70
- # Attach some ALTO to a work
71
- derivatives = IiifPrint::Data::WorkDerivatives.of(
72
- work,
73
- valid_file_set
74
- )
75
- derivatives.attach(minimal_alto, 'xml')
76
- # In this case, service will not call the OCR implementation method:
77
- service = described_class.new(valid_file_set)
78
- expect(service).not_to receive(:create_derivatives_from_ocr)
79
- service.create_derivatives(source_image('ocr_mono.tiff'))
80
- end
81
- end
82
- end
@@ -1,127 +0,0 @@
1
- require 'nokogiri'
2
- require 'spec_helper'
3
- require 'misc_shared'
4
-
5
- RSpec.describe IiifPrint::TextFormatsFromALTOService do
6
- include_context "shared setup"
7
-
8
- let(:valid_file_set) do
9
- file_set = FileSet.new
10
- file_set.save!(validate: false)
11
- file_set
12
- end
13
-
14
- let(:work) do
15
- work = NewspaperPage.create(title: ["Hello"])
16
- work.members << valid_file_set
17
- work.save!
18
- work
19
- end
20
-
21
- let(:minimal_alto) do
22
- File.join(fixture_path, 'minimal-alto.xml')
23
- end
24
-
25
- def log_incoming_attachment(fsid)
26
- IiifPrint::DerivativeAttachment.create!(
27
- fileset_id: fsid,
28
- path: minimal_alto,
29
- destination_name: 'xml'
30
- )
31
- end
32
-
33
- def derivatives_of(work, fileset)
34
- IiifPrint::Data::WorkDerivatives.of(work, fileset)
35
- end
36
-
37
- describe "Saves other formats from ALTO" do
38
- xit "saves JSON, text from existing ALTO derivative" do
39
- derivatives = derivatives_of(work, valid_file_set)
40
- expect(derivatives.keys.size).to eq 0
41
- derivatives.attach(minimal_alto, 'xml')
42
- expect(derivatives.keys.size).to eq 1
43
- service = described_class.new(valid_file_set)
44
- service.create_derivatives('/some/random/primary/path/does_not/matter')
45
- derivatives.load_paths
46
- expect(derivatives.keys.size).to eq 3
47
- expect(derivatives.keys).to include 'json', 'txt'
48
- end
49
-
50
- xit "saves JSON, text from incoming ALTO derivative" do
51
- derivatives = derivatives_of(work, valid_file_set)
52
- expect(derivatives.keys.size).to eq 0
53
- log_incoming_attachment(valid_file_set.id)
54
- service = described_class.new(valid_file_set)
55
- service.create_derivatives('/some/random/primary/path/does_not/matter')
56
- # reload keys to check derivatives:
57
- derivatives.load_paths
58
- expect(derivatives.keys).to include 'json', 'txt'
59
- end
60
- end
61
-
62
- describe "scaling matters" do
63
- # we need an ingested, characterized file:
64
- do_now_jobs = [
65
- IngestLocalFileJob,
66
- IngestJob,
67
- InheritPermissionsJob,
68
- CharacterizeJob
69
- ]
70
- # we omit CreateDerivativesJob from above, as obviously duplicative and
71
- # therefore potential cause of problems here.
72
-
73
- # remove any previous test run (development) artifacts in file
74
- # attachment logging tables
75
- before(:all) do
76
- IiifPrint::DerivativeAttachment.all.delete_all
77
- IiifPrint::IngestFileRelation.all.delete_all
78
- end
79
-
80
- let(:work) do
81
- work = NewspaperPage.create(title: ["Hello"])
82
- work
83
- end
84
-
85
- let(:tiff_path) { File.join(fixture_path, 'ocr_gray.tiff') }
86
- let(:ocr_alto_path) do
87
- File.join(fixture_path, 'ocr_alto_scaled_4pts_per_px.xml')
88
- end
89
-
90
- def attach_primary_file(work)
91
- IiifPrint::Data::WorkFiles.assign!(to: work, path: tiff_path)
92
- work.reload
93
- pcdm_file = IiifPrint::Data::WorkFiles.of(work).values[0].unwrapped
94
- expect(pcdm_file).not_to be_nil
95
- # we have image dimensions (px) to work with:
96
- expect(pcdm_file.width[0].to_i).to be_an Integer
97
- expect(pcdm_file.height[0].to_i).to be_an Integer
98
- end
99
-
100
- def derivatives_of(work)
101
- IiifPrint::Data::WorkFiles.of(work).derivatives
102
- end
103
-
104
- def attach_alto(work)
105
- derivatives = derivatives_of(work)
106
- derivatives.attach(ocr_alto_path, 'xml')
107
- # has a path to now-stored derivative:
108
- expect(derivatives.path('xml')).not_to be_nil
109
- end
110
-
111
- xit "scales ALTO points to original image", perform_enqueued: do_now_jobs do
112
- attach_primary_file(work)
113
- attach_alto(work)
114
- work.reload
115
- file_set = work.ordered_members.to_a.find { |m| m.is_a? FileSet }
116
- service = described_class.new(file_set)
117
- service.create_derivatives('/a/path/here/needed/but/will/not/matter')
118
- coords = JSON.parse(derivatives_of(work).data('json'))
119
- word = coords['coords'].select { |k, _v| k == 'Bethesda' }
120
- # test against known scaled coordinate of OCR data:
121
- # This roughly matches unscaled ALTO data for token 'Bethesda'
122
- # in spec/fixtures/files/ocr_alto.xml, with the disclaimer that
123
- # round-trip rounding error of 1px is noted for VPOS.
124
- expect(word['Bethesda']).to eq [[16, 665, 78, 16]]
125
- end
126
- end
127
- end
@@ -1,65 +0,0 @@
1
- require 'spec_helper'
2
- RSpec.describe IiifPrint::TIFFDerivativeService do
3
- let(:valid_file_set) do
4
- file_set = FileSet.new
5
- file_set.save!(validate: false)
6
- file_set
7
- end
8
-
9
- let(:fixture_path) do
10
- File.join(
11
- IiifPrint::GEM_PATH, 'spec', 'fixtures', 'files'
12
- )
13
- end
14
-
15
- describe "Creates TIFF derivatives" do
16
- def source_image(name)
17
- File.join(fixture_path, name)
18
- end
19
-
20
- def expected_path(file_set)
21
- Hyrax::DerivativePath.derivative_path_for_reference(file_set, 'tiff')
22
- end
23
-
24
- def get_res(path)
25
- tool = IiifPrint::ImageTool.new(path)
26
- "#{tool.metadata[:width]}x#{tool.metadata[:height]}"
27
- end
28
-
29
- def check_dpi_match(orig, dest)
30
- # check ppi, but skip pdf to avoid ghostscript warnings to stderr
31
- expect(get_res(orig)).to eq get_res(dest) unless orig.end_with?('pdf')
32
- end
33
-
34
- def makes_tiff(filename)
35
- path = source_image(filename)
36
- expected = expected_path(valid_file_set)
37
- expect(File.exist?(expected)).to be false
38
- svc = described_class.new(valid_file_set)
39
- svc.create_derivatives(path)
40
- expect(File.exist?(expected)).to be true
41
- mime = IiifPrint::ImageTool.new(expected).metadata[:content_type]
42
- expect(mime).to eq 'image/tiff'
43
- check_dpi_match(path, expected)
44
- svc.cleanup_derivatives
45
- end
46
-
47
- # for cases where primary file is TIFF already
48
- def avoids_duplicative_creation(filename)
49
- expected = expected_path(valid_file_set)
50
- expect(File.exist?(expected)).to be false
51
- svc = described_class.new(valid_file_set)
52
- svc.create_derivatives(source_image(filename))
53
- expect(File.exist?(expected)).not_to be true
54
- end
55
-
56
- it "Does not make TIFF derivatives when primary is TIFF" do
57
- avoids_duplicative_creation('ocr_mono.tiff')
58
- avoids_duplicative_creation('ocr_gray.tiff')
59
- end
60
-
61
- it "creates TIFF from PDF source, robust to multi-page" do
62
- makes_tiff('sample-color-newsletter.pdf')
63
- end
64
- end
65
- end
data/spec/spec_helper.rb DELETED
@@ -1,181 +0,0 @@
1
- require 'json'
2
-
3
- # testing environent:
4
- ENV['RAILS_ENV'] ||= 'test'
5
-
6
- require 'coveralls'
7
- Coveralls.wear!
8
-
9
- require 'shoulda/matchers'
10
- Shoulda::Matchers.configure do |config|
11
- config.integrate do |with|
12
- with.test_framework :rspec
13
- end
14
- end
15
-
16
- # engine_cart:
17
- require 'bundler/setup'
18
- require 'engine_cart'
19
- EngineCart.load_application!
20
-
21
- require 'rspec/rails'
22
- require 'support/iiif_print_models'
23
- require 'support/controller_level_helpers'
24
- require 'rspec/active_model/mocks'
25
-
26
- ActiveJob::Base.queue_adapter = :test
27
-
28
- RSpec.configure do |config|
29
- # enable FactoryBot:
30
- require 'factory_bot'
31
- config.include FactoryBot::Syntax::Methods
32
- # auto-detect and load all factories in spec/factories:
33
- FactoryBot.find_definitions
34
-
35
- config.infer_spec_type_from_file_location!
36
-
37
- # Transactional
38
- config.use_transactional_fixtures = false
39
- config.include Devise::Test::ControllerHelpers, type: :controller
40
-
41
- # ensure Hyrax has active sipity workflow for default admin set:
42
- config.before(:suite) do
43
- require 'active_fedora/cleaner'
44
- require 'database_cleaner'
45
-
46
- # By default, Hyrax uses a database minter class. That's the preferred pathway (because you are
47
- # tracking minting state in the database). However, for testing purposes we don't need to / nor
48
- # want to install the minter migrations. Hence we're favoring this approach.
49
- minter_class = ::Noid::Rails::Minter::File
50
- ::Noid::Rails.config.minter_class = minter_class
51
- Hyrax.config.noid_minter_class = minter_class
52
-
53
- ActiveFedora::Cleaner.clean!
54
- DatabaseCleaner.clean_with(:truncation)
55
-
56
- begin
57
- # TODO: switch the below methods to use the appropriate services
58
- # rather than the deprecated methods currently being used.
59
- # ensure permission template actually exists in RDBMS:
60
- id = 'admin_set/default'
61
- no_template = Hyrax::PermissionTemplate.find_by(source_id: id).nil?
62
- Hyrax::PermissionTemplate.create!(source_id: id) if no_template
63
- # ensure workflows exist, presumes permission template does first:
64
- Hyrax::Workflow::WorkflowImporter.load_workflows
65
- # Default admin set needs to exist in Fedora, with relation to its
66
- # PermissionTemplate object:
67
- begin
68
- admin_set = AdminSet.find(AdminSet.find_or_create_default_admin_set_id)
69
- admin_set.save!
70
- rescue ActiveRecord::RecordNotUnique
71
- admin_set = AdminSet.find(AdminSet::DEFAULT_ID)
72
- end
73
- permission_template = admin_set.permission_template
74
- workflow = permission_template.available_workflows.where(
75
- name: 'default'
76
- ).first
77
- Sipity::Workflow.activate!(
78
- permission_template: permission_template,
79
- workflow_id: workflow.id
80
- )
81
- rescue Faraday::ConnectionFailed
82
- STDERR.puts "Attempting to run test suite without Fedora and/or Solr..."
83
- end
84
- end
85
-
86
- # :perform_enqueued config setting below copied from Hyrax spec_helper.rb
87
- config.before(:example, :perform_enqueued) do |example|
88
- ActiveJob::Base.queue_adapter.filter = example.metadata[:perform_enqueued].try(:to_a)
89
- ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true
90
- ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = true
91
- end
92
- config.after(:example, :perform_enqueued) do
93
- ActiveJob::Base.queue_adapter.filter = nil
94
- ActiveJob::Base.queue_adapter.enqueued_jobs = []
95
- ActiveJob::Base.queue_adapter.performed_jobs = []
96
- ActiveJob::Base.queue_adapter.perform_enqueued_jobs = false
97
- ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = false
98
- end
99
- config.after(:suite) do # or :each or :all
100
- FileUtils.rm_rf(Dir[Rails.root.join('tmp', 'derivatives', '*')])
101
- end
102
-
103
- # rspec-expectations config goes here. You can use an alternate
104
- # assertion/expectation library such as wrong or the stdlib/minitest
105
- # assertions if you prefer.
106
- config.expect_with :rspec do |expectations|
107
- # This option will default to `true` in RSpec 4. It makes the `description`
108
- # and `failure_message` of custom matchers include text for helper methods
109
- # defined using `chain`, e.g.:
110
- # be_bigger_than(2).and_smaller_than(4).description
111
- # # => "be bigger than 2 and smaller than 4"
112
- # ...rather than:
113
- # # => "be bigger than 2"
114
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
115
- end
116
-
117
- # rspec-mocks config goes here. You can use an alternate test double
118
- # library (such as bogus or mocha) by changing the `mock_with` option here.
119
- config.mock_with :rspec do |mocks|
120
- # Prevents you from mocking or stubbing a method that does not exist on
121
- # a real object. This is generally recommended, and will default to
122
- # `true` in RSpec 4.
123
- mocks.verify_partial_doubles = true
124
- end
125
-
126
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
127
- # have no way to turn it off -- the option exists only for backwards
128
- # compatibility in RSpec 3). It causes shared context metadata to be
129
- # inherited by the metadata hash of host groups and examples, rather than
130
- # triggering implicit auto-inclusion in groups with matching metadata.
131
- config.shared_context_metadata_behavior = :apply_to_host_groups
132
-
133
- # The settings below are suggested to provide a good initial experience
134
- # with RSpec, but feel free to customize to your heart's content.
135
-
136
- # This allows you to limit a spec run to individual examples or groups
137
- # you care about by tagging them with `:focus` metadata. When nothing
138
- # is tagged with `:focus`, all examples get run. RSpec also provides
139
- # aliases for `it`, `describe`, and `context` that include `:focus`
140
- # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
141
- # config.filter_run_when_matching :focus
142
-
143
- # Allows RSpec to persist some state between runs in order to support
144
- # the `--only-failures` and `--next-failure` CLI options. We recommend
145
- # you configure your source control system to ignore this file.
146
- # config.example_status_persistence_file_path = "spec/examples.txt"
147
-
148
- # Limits the available syntax to the non-monkey patched syntax that is
149
- # recommended. For more details, see:
150
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
151
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
152
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
153
- # config.disable_monkey_patching!
154
-
155
- # Many RSpec users commonly either run the entire suite or an individual
156
- # file, and it's useful to allow more verbose output when running an
157
- # individual spec file.
158
- # if config.files_to_run.one?
159
- # Use the documentation formatter for detailed output,
160
- # unless a formatter has already been configured
161
- # (e.g. via a command-line flag).
162
- # config.default_formatter = "doc"
163
- # end
164
-
165
- # Print the 10 slowest examples and example groups at the
166
- # end of the spec run, to help surface which specs are running
167
- # particularly slow.
168
- config.profile_examples = 10
169
-
170
- # Run specs in random order to surface order dependencies. If you find an
171
- # order dependency and want to debug it, you can fix the order by providing
172
- # the seed, which is printed after each run.
173
- # --seed 1234
174
- config.order = :random
175
-
176
- # Seed global randomization in this process using the `--seed` CLI option.
177
- # Setting this allows you to use `--seed` to deterministically reproduce
178
- # test failures related to randomization by passing the same `--seed` value
179
- # as the one that triggered the failure.
180
- Kernel.srand config.seed
181
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
- # copied from Hyrax
3
-
4
- module ControllerLevelHelpers
5
- # This provides some common mock methods for view tests.
6
- # These are normally provided by the controller.
7
- module ControllerViewHelpers
8
- def search_state
9
- @search_state ||= CatalogController.search_state_class.new(params, blacklight_config, controller)
10
- end
11
-
12
- # This allows you to set the configuration
13
- # @example: view.blacklight_config = Blacklight::Configuration.new
14
- attr_writer :blacklight_config
15
-
16
- def blacklight_config
17
- @blacklight_config ||= CatalogController.blacklight_config
18
- end
19
-
20
- def blacklight_configuration_context
21
- @blacklight_configuration_context ||= Blacklight::Configuration::Context.new(controller)
22
- end
23
- end
24
-
25
- def initialize_controller_helpers(helper)
26
- helper.extend ControllerViewHelpers
27
- end
28
- end
@@ -1,127 +0,0 @@
1
- # frozen_string_literal: true
2
- ###################################################################################################
3
- #
4
- # The purpose of this file is to define the models we'll use in our spec application. Some of these
5
- # models are echoes of what downstream apps will define (e.g. FileSet). Other are for internal
6
- # modeling purposes only.
7
- #
8
- ####################################################################################################
9
- class FakeDerivativeService
10
- class_attribute :target_extension, default: 'txt'
11
- def initialize(target_extension: nil)
12
- self.target_extension = target_extension if target_extension
13
- @create_called = 0
14
- @cleanup_called = 0
15
- end
16
- attr_reader :create_called, :cleanup_called
17
-
18
- # Why the #new method?
19
- #
20
- # Because the plugin interface assumes we're passing a
21
- # plugin that responds to `new`. In prod code, that plugin is a class.
22
- # However, in test, to facilitate observing what methods are called we pass
23
- # the plugin as an instance of this class (e.g. `plugin =
24
- # FakeDerivativeService.new`). Later, in the process, the code calls
25
- # `plugin.new(file_set)`; it is then expected to return something that
26
- # responds to `create_derivatives` and `cleanup_derivatives`.
27
- #
28
- # @see IiifPrint::PluggableDerivativeService#initialize
29
- # @see IiifPrint::PluggableDerivativeService#services
30
- #
31
- # @note FakeDerivativeService.new returns an instance of
32
- # FakeDerivativeService. Likewise, FakeDerivativeService#new will now
33
- # return an instance of FakeDerivativeService
34
- def new(fileset)
35
- @fileset = fileset
36
- self
37
- end
38
-
39
- def valid?
40
- true
41
- end
42
-
43
- def create_derivatives(filename)
44
- @create_called += 1
45
- filename
46
- end
47
-
48
- def cleanup_derivatives
49
- @cleanup_called += 1
50
- end
51
- end
52
-
53
- ##
54
- # iiif_print requires a file set model that is compatible with Hyrax assumptions. We do not want to
55
- # add this to app/models because those are loaded in the downstream application; which can create
56
- class FileSet < ActiveFedora::Base
57
- include ::Hyrax::FileSetBehavior
58
- end
59
-
60
- class MyWork < ActiveFedora::Base
61
- include ::Hyrax::WorkBehavior
62
- end
63
-
64
- class MyWorkNeedsDerivative < ActiveFedora::Base
65
- attr_accessor :title
66
- def members
67
- []
68
- end
69
- end
70
-
71
- class MyWorkDoesNotNeedDerivative < ActiveFedora::Base
72
- attr_accessor :title
73
- def members
74
- []
75
- end
76
- end
77
-
78
- class MyIiifConfiguredWorkWithAllDerivativeServices < ActiveFedora::Base
79
- include IiifPrint.model_configuration
80
-
81
- attr_accessor :title
82
- def members
83
- []
84
- end
85
- end
86
-
87
- class MyIiifConfiguredWork < ActiveFedora::Base
88
- include IiifPrint.model_configuration(
89
- derivative_service_plugins: [FakeDerivativeService]
90
- )
91
- attr_accessor :title
92
- def members
93
- []
94
- end
95
- end
96
-
97
- # Newspaper Issue
98
- class NewspaperIssue < ActiveFedora::Base
99
- # WorkBehavior mixes in minimal ::Hyrax::CoreMetadata fields of
100
- # depositor, title, date_uploaded, and date_modified.
101
- # https://samvera.github.io/customize-metadata-model.html#core-metadata
102
- include ::Hyrax::WorkBehavior
103
- # BasicMetadata must be included last
104
- include ::Hyrax::BasicMetadata
105
- end
106
-
107
- # TODO: merge this in with whatever is needed from misc_shared.rb
108
- class WorkWithIiifPrintConfig < ActiveFedora::Base
109
- include ::Hyrax::WorkBehavior
110
- include IiifPrint::SetChildFlag
111
- include IiifPrint.model_configuration(pdf_split_child_model: WorkWithIiifPrintConfig)
112
- include ::Hyrax::BasicMetadata
113
-
114
- validates :title, presence: { message: 'Your work must have a title.' }
115
-
116
- # self.indexer = GenericWorkIndexer
117
- end
118
-
119
- class WorkWithOutConfig < ActiveFedora::Base
120
- include ::Hyrax::WorkBehavior
121
- include IiifPrint::SetChildFlag
122
- include ::Hyrax::BasicMetadata
123
-
124
- validates :title, presence: { message: 'Your work must have a title.' }
125
-
126
- # self.indexer = GenericWorkIndexer
127
- end
@@ -1,9 +0,0 @@
1
- development:
2
- adapter: solr
3
- url: <%= ENV['SOLR_URL'] %>/hyrax
4
- test: &test
5
- adapter: solr
6
- url: <%= ENV['SOLR_URL'] %>/hyrax_test
7
- production:
8
- adapter: solr
9
- url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/blacklight-core" %>
@@ -1,15 +0,0 @@
1
- development:
2
- user: fedoraAdmin
3
- password: fedoraAdmin
4
- url: <%= ENV['FCREPO_URL'] %>/rest
5
- base_path: /dev
6
- test:
7
- user: fedoraAdmin
8
- password: fedoraAdmin
9
- url: <%= ENV['FCREPO_URL'] %>/rest
10
- base_path: /test
11
- production:
12
- user: fedoraAdmin
13
- password: fedoraAdmin
14
- url: http://127.0.0.1:8983/fedora/rest
15
- base_path: /prod
@@ -1,40 +0,0 @@
1
- # Test App Generator
2
- require 'rails/generators'
3
- require 'byebug'
4
- class TestAppGenerator < Rails::Generators::Base
5
- source_root File.expand_path('../../../spec/test_app_templates', __dir__)
6
-
7
- def install_redis
8
- gem 'redis', '4.8.1'
9
- Bundler.with_unbundled_env do
10
- run "bundle install"
11
- end
12
- end
13
-
14
- def install_hyrax
15
- generate 'hyrax:install', '-f'
16
- end
17
-
18
- # TODO not sure why this doesnt work
19
- # just copy them manually for the moment
20
- def install_config_files
21
- copy_file 'blacklight.yml', 'config/blacklight.yml'
22
- copy_file 'fedora.yml', 'config/fedora.yml'
23
- copy_file 'redis.yml', 'config/redis.yml'
24
- copy_file 'solr.yml', 'config/solr.yml'
25
- copy_file 'solr/conf/schema.xml', 'solr/conf/schema.xml'
26
- copy_file 'solr/conf/solrconfig.xml', 'solr/conf/solrconfig.xml'
27
- end
28
-
29
- def install_engine
30
- generate 'iiif_print:install'
31
- end
32
-
33
- def db_migrations
34
- rake 'db:migrate'
35
- end
36
-
37
- def configure_browse_everything
38
- generate 'browse_everything:config'
39
- end
40
- end
@@ -1,9 +0,0 @@
1
- development:
2
- host: <%= ENV['REDIS_HOST'] || 'localhost' %>
3
- port: 6379
4
- test:
5
- host: <%= ENV['REDIS_HOST'] || 'localhost' %>
6
- port: 6379
7
- production:
8
- host: <%= ENV['REDIS_HOST'] || 'localhost' %>
9
- port: 6379