class NewspaperWorks::Ingest::NewspaperIssueIngest
Public Class Methods
configure()
click to toggle source
# File lib/newspaper_works/ingest/newspaper_issue_ingest.rb, line 7 def configure return if @configured == true # PDF ingest may save page images to /tmp (via Dir.tmpdir), which # needs whitelisting for use by NewspaperWorks::Data::WorkFiles.commit! # via Hyrax CreateWithRemoteFilesActor: whitelist = Hyrax.config.whitelisted_ingest_dirs whitelist.push(Dir.tmpdir) unless whitelist.include?(Dir.tmpdir) @configured = true end
Public Instance Methods
create_child_pages()
click to toggle source
Creates child pages with attached TIFF masters, can be called by
`import`, or independently if `load` is called first. The latter is appropriate if framework is already handling the NewspaperIssue file attachment (e.g. Hyrax upload via browser).
# File lib/newspaper_works/ingest/newspaper_issue_ingest.rb, line 29 def create_child_pages self.class.configure pages = NewspaperWorks::Ingest::PdfPages.new(path).to_a pages.each_with_index do |tiffpath, idx| page = new_child_page_with_file(tiffpath, idx) @work.ordered_members << page end @work.save!(validate: false) unless pages.empty? end
import()
click to toggle source
Calls superclass method
NewspaperWorks::Ingest::BaseIngest#import
# File lib/newspaper_works/ingest/newspaper_issue_ingest.rb, line 18 def import # first, handle the PDF itself on the issue... super # ...then create child works from split pages create_child_pages end
new_child_page_with_file(tiffpath, idx)
click to toggle source
# File lib/newspaper_works/ingest/newspaper_issue_ingest.rb, line 39 def new_child_page_with_file(tiffpath, idx) page_number = idx + 1 page = NewspaperPage.new page.title = ["#{@work.title.first}: Page #{page_number}"] # technically, a sequence number distinct from displayed page number page.page_number = page_number.to_s # Set depositor and admin-set id: page.depositor = @work.depositor page.admin_set_id = @work.admin_set_id # copying permissions also by effect copies visibility: page.permissions_attributes = @work.permissions.map(&:to_hash) NewspaperPageIngest.new(page).ingest(tiffpath) page.save! page end