Class: Hyrax::Ingest::BatchRunner
- Inherits:
-
Object
- Object
- Hyrax::Ingest::BatchRunner
- Includes:
- HasDepositor, HasLogger, HasReport, Interloper
- Defined in:
- lib/hyrax/ingest/batch_runner.rb
Instance Attribute Summary collapse
-
#sip_paths ⇒ Object
readonly
Returns the value of attribute sip_paths.
Instance Method Summary collapse
-
#ingested_ids ⇒ Array
Returns an array containing the IDs of new or updated records.
-
#ingested_ids_by_type ⇒ Hash
Returns an hash containing the IDs of new or updated records, keyed by the model class by which they were saved.
-
#initialize(config_file_path:, sip_paths: [], shared_sip_path: nil, iterations: nil, depositor: nil) ⇒ BatchRunner
constructor
A new instance of BatchRunner.
- #run! ⇒ Object
Methods included from HasDepositor
Methods included from HasLogger
Methods included from HasReport
Constructor Details
#initialize(config_file_path:, sip_paths: [], shared_sip_path: nil, iterations: nil, depositor: nil) ⇒ BatchRunner
Returns a new instance of BatchRunner.
30 31 32 33 34 35 36 |
# File 'lib/hyrax/ingest/batch_runner.rb', line 30 def initialize(config_file_path:, sip_paths: [], shared_sip_path: nil, iterations: nil, depositor: nil) @sip_paths = sip_paths @shared_sip_path = shared_sip_path @config_file_path = config_file_path @iterations = iterations self.depositor = depositor end |
Instance Attribute Details
#sip_paths ⇒ Object (readonly)
Returns the value of attribute sip_paths.
28 29 30 |
# File 'lib/hyrax/ingest/batch_runner.rb', line 28 def sip_paths @sip_paths end |
Instance Method Details
#ingested_ids ⇒ Array
Returns an array containing the IDs of new or updated records. Currently only returns the IDs for ActiveFedora records (or subclasses) that are specified at the top level (i.e. not nested) of the ingest configuration.
57 58 59 |
# File 'lib/hyrax/ingest/batch_runner.rb', line 57 def ingested_ids ingested_ids_by_type.flatten end |
#ingested_ids_by_type ⇒ Hash
Returns an hash containing the IDs of new or updated records, keyed by the model class by which they were saved. Example:
{ FileSet => ['123', '456'], Work => ['789'] }
Currently only returns the IDs for ActiveFedora records (or subclasses) that are specified at the top level (i.e. not nested) of the ingest configuration.
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/hyrax/ingest/batch_runner.rb', line 69 def ingested_ids_by_type {}.tap do |h| runners.each do |runner| runner.ingested_ids_by_type.each do |type, ids| h[type] ||= [] h[type] += ids h[type].uniq! end end end end |
#run! ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/hyrax/ingest/batch_runner.rb', line 38 def run! runners.each { |runner| runner.run! } rescue StandardError => error # TODO: move to callback, but :rescue hook doesn't exist yet in # Interloper gem. report.stat[:datetime_completed] = DateTime.now report.failed_with error raise error ensure # TODO: move to callback, but :ensure hook doesn't exist yet in # Interloper gem. report.write_to_file end |