Sha256: 2417e375f700037b1344226cb8c92d74a67cf81ad8a6ca4bf51b954d1fb00b8d

Contents?: true

Size: 787 Bytes

Versions: 11

Compression:

Stored size: 787 Bytes

Contents

# frozen_string_literal: true

module Bulkrax
  class CsvFileSetEntry < CsvEntry
    def factory_class
      ::FileSet
    end

    def add_path_to_file
      parsed_metadata['file'].each_with_index do |filename, i|
        path_to_file = ::File.join(parser.path_to_files, filename)

        parsed_metadata['file'][i] = path_to_file
      end
      raise ::StandardError, "one or more file paths are invalid: #{parsed_metadata['file'].join(', ')}" unless parsed_metadata['file'].map { |file_path| ::File.file?(file_path) }.all?

      parsed_metadata['file']
    end

    def validate_presence_of_parent!
      return if parsed_metadata[related_parents_parsed_mapping]&.map(&:present?)&.any?

      raise StandardError, 'File set must be related to at least one work'
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bulkrax-3.0.0.beta5 app/models/bulkrax/csv_file_set_entry.rb
bulkrax-3.0.0.beta4 app/models/bulkrax/csv_file_set_entry.rb
bulkrax-3.0.0.beta3 app/models/bulkrax/csv_file_set_entry.rb
bulkrax-3.0.0.beta2 app/models/bulkrax/csv_file_set_entry.rb
bulkrax-3.0.0.beta1 app/models/bulkrax/csv_file_set_entry.rb
bulkrax-2.3.0 app/models/bulkrax/csv_file_set_entry.rb
bulkrax-2.2.4 app/models/bulkrax/csv_file_set_entry.rb
bulkrax-2.2.3 app/models/bulkrax/csv_file_set_entry.rb
bulkrax-2.2.2 app/models/bulkrax/csv_file_set_entry.rb
bulkrax-2.2.1 app/models/bulkrax/csv_file_set_entry.rb
bulkrax-2.2.0 app/models/bulkrax/csv_file_set_entry.rb