lib/bulkrax.rb in bulkrax-4.3.1 vs lib/bulkrax.rb in bulkrax-4.4.0

- old
+ new

@@ -1,38 +1,42 @@ # frozen_string_literal: true +require "bulkrax/version" require "bulkrax/engine" require 'active_support/all' module Bulkrax class << self - mattr_accessor :parsers, - :default_work_type, + mattr_accessor :api_definition, :default_field_mapping, + :default_work_type, + :export_path, + :field_mappings, :fill_in_blank_source_identifiers, :generated_metadata_mapping, + :import_path, + :multi_value_element_join_on, + :multi_value_element_split_on, + :object_factory, + :parsers, + :qa_controlled_properties, :related_children_field_mapping, :related_parents_field_mapping, - :reserved_properties, - :qa_controlled_properties, - :field_mappings, - :import_path, - :export_path, :removed_image_path, - :server_name, - :api_definition + :reserved_properties, + :server_name self.parsers = [ { name: "OAI - Dublin Core", class_name: "Bulkrax::OaiDcParser", partial: "oai_fields" }, { name: "OAI - Qualified Dublin Core", class_name: "Bulkrax::OaiQualifiedDcParser", partial: "oai_fields" }, { name: "CSV - Comma Separated Values", class_name: "Bulkrax::CsvParser", partial: "csv_fields" }, { name: "Bagit", class_name: "Bulkrax::BagitParser", partial: "bagit_fields" }, { name: "XML", class_name: "Bulkrax::XmlParser", partial: "xml_fields" } ] - self.import_path = 'tmp/imports' - self.export_path = 'tmp/exports' + self.import_path = Bulkrax.import_path || 'tmp/imports' + self.export_path = Bulkrax.export_path || 'tmp/exports' self.removed_image_path = Bulkrax::Engine.root.join('spec', 'fixtures', 'removed.png').to_s self.server_name = 'bulkrax@example.com' # Hash of Generic field_mappings for use in the view # There must be one field_mappings hash per view parial @@ -133,9 +137,32 @@ ERB.new( File.read(Rails.root.join('config', 'bulkrax_api.yml')) ).result ) ) + end + + DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON = ' | ' + # Specify the delimiter for joining an attribute's multi-value array into a string. + # + # @note the specific delimeter should likely be present in the multi_value_element_split_on + # expression. + def self.multi_value_element_join_on + @multi_value_element_join_on ||= DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON + end + + DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON = /\s*[:;|]\s*/.freeze + # @return [RegexClass] the regular express to use to "split" an attribute's values. If set to + # `true` use the DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON. + # + # @note The "true" value is to preserve backwards compatibility. + # @see DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON + def self.multi_value_element_split_on + if @multi_value_element_join_on.is_a?(TrueClass) + DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON + else + @multi_value_element_split_on ||= DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON + end end # this function maps the vars from your app into your engine def self.setup yield self