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.99.1 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.99.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.98.1 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.98.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.96.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.95.1 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.95.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.94.2 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.94.1 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.94.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.93.1 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.93.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.92.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.91.4 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.91.3 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.91.2 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.91.1 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.91.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.90.0 lib/cocina/models/mapping/from_mods/authority.rb
cocina-models-0.89.1 lib/cocina/models/mapping/from_mods/authority.rb