Sha256: ee0bdc6ea48ee3db57046d44dddfc56ee54810c20ae7172c64892445672f4c5f

Contents?: true

Size: 1.38 KB

Versions: 40

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

module Cocina
  module Models
    module Mapping
      module FromMods
        # Helper class: normalizes Authorities
        class Authority
          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

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

            uri.presence
          end

          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
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
cocina-models-0.89.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.88.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.87.1 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.87.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.86.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.85.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.84.5 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.84.4 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.84.3 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.84.2 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.84.1 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.84.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.83.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.82.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.81.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.80.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.79.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.78.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.77.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.76.0 lib/cocina/models/mapping/from_mods/authority.rb