Class: Cocina::Models::Mapping::FromMods::Authority

Inherits:
Object
  • Object
show all
Defined in:
lib/cocina/models/mapping/from_mods/authority.rb

Overview

Helper class: normalizes Authorities

Constant Summary collapse

NORMALIZE_AUTHORITY_URIS =
[
  'http://id.loc.gov/authorities/names',
  'http://id.loc.gov/authorities/subjects',
  'http://id.loc.gov/vocabulary/relators',
  'http://id.loc.gov/vocabulary/countries',
  'http://id.loc.gov/authorities/genreForms',
  'http://id.loc.gov/vocabulary/descriptionConventions'
].freeze

Class Method Summary collapse

Class Method Details

.normalize_code(code, notifier) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/cocina/models/mapping/from_mods/authority.rb', line 24

def self.normalize_code(code, notifier)
  if code == 'lcnaf'
    notifier.warn('lcnaf authority code')
    return 'naf'
  end

  if code == 'tgm'
    notifier.warn('tgm authority code (should be lctgm)')
    return 'lctgm'
  end

  if code == '#N/A'
    notifier.warn('"#N/A" authority code')
    return nil
  end

  if code == 'marcountry'
    notifier.warn('marcountry authority code (should be marccountry)')
    return 'marccountry'
  end

  code.presence
end

.normalize_uri(uri) ⇒ Object



18
19
20
21
22
# File 'lib/cocina/models/mapping/from_mods/authority.rb', line 18

def self.normalize_uri(uri)
  return "#{uri}/" if NORMALIZE_AUTHORITY_URIS.include?(uri)

  uri.presence
end