Class: Kiba::Extend::Transforms::Cspace::NormalizeForID
- Inherits:
-
Object
- Object
- Kiba::Extend::Transforms::Cspace::NormalizeForID
- Includes:
- MultivalPlusDelimDeprecatable
- Defined in:
- lib/kiba/extend/transforms/cspace/normalize_for_id.rb
Overview
This class makes use of Utils::StringNormalizer with
mode: :cspaceid
. See that class for more details and fuller
tests of string normalization
Normalizes a string value—typically a value that will become a
CSpace authority termdisplayname
value—using the same (or as
close as possible to the same) algorithm as the CSpace application
uses to generate the shortid
field in authority records.
This is useful for identifying values that are not exact string
matches, but that CSpace may see/treat as duplicates under the hood
where it uses the shortid
(which is embedded in refName URNs).
In preparing data for CSpace migrations, this can prevent creation
of terms that cause problems during ingest, or that will later
cause warnings/errors if you try to load Objects or Procedures
containing those terms.
Instance Method Summary collapse
-
#initialize(source:, target:, multival: omitted = true, delim: nil) ⇒ NormalizeForID
constructor
A new instance of NormalizeForID.
-
#process(row) ⇒ Object
Methods included from MultivalPlusDelimDeprecatable
Constructor Details
#initialize(source:, target:, multival: omitted = true, delim: nil) ⇒ NormalizeForID
Returns a new instance of NormalizeForID.
76 77 78 79 80 81 82 83 84 |
# File 'lib/kiba/extend/transforms/cspace/normalize_for_id.rb', line 76 def initialize(source:, target:, multival: omitted = true, delim: nil) @source = source @target = target @multival = set_multival(multival, omitted, self) @delim = delim @normalizer = Kiba::Extend::Utils::StringNormalizer.new( mode: :cspaceid ) end |
Instance Method Details
#process(row) ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/kiba/extend/transforms/cspace/normalize_for_id.rb', line 87 def process(row) row[target] = nil val = row.fetch(source, nil) return row if val.blank? row[target] = values(val).map { |val| normalize(val) }.join(delim) row end |