Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix multivalue split and join on configs #1003

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions lib/bulkrax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class Configuration
:field_mappings,
:generated_metadata_mapping,
:import_path,
:multi_value_element_join_on,
:multi_value_element_split_on,
:object_factory,
:parsers,
:qa_controlled_properties,
Expand Down Expand Up @@ -175,6 +173,33 @@ def use_locking
ENV.key?("REDIS_HOST")
end
alias use_locking? use_locking

DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON = ' | '
# Specify the delimiter for joining an attribute's multi-value array into a string.
#
# @note the specific delimiter should likely be present in the multi_value_element_split_on
# expression.
def multi_value_element_join_on
@multi_value_element_join_on ||= DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON
end

attr_writer :multi_value_element_split_on

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 multi_value_element_split_on
if @multi_value_element_split_on.is_a?(TrueClass)
DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON
else
@multi_value_element_split_on ||= DEFAULT_MULTI_VALUE_ELEMENT_SPLIT_ON
end
end

attr_writer :multi_value_element_join_on
end

def config
Expand Down Expand Up @@ -361,29 +386,6 @@ def api_definition
)
end

DEFAULT_MULTI_VALUE_ELEMENT_JOIN_ON = ' | '
# Specify the delimiter for joining an attribute's multi-value array into a string.
#
# @note the specific delimiter should likely be present in the multi_value_element_split_on
# expression.
def 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 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

# Responsible for stripping hidden characters from the given string.
#
# @param value [#to_s]
Expand Down
Loading