Module: BerkeleyLibrary::AV::Metadata::Fields

Includes:
Constants
Defined in:
lib/berkeley_library/av/metadata/fields.rb

Constant Summary collapse

TITLE =
Field.new(order: 1, label: 'Title', spec: "#{TAG_TITLE_FIELD}$a")
DESCRIPTION =
Field.new(order: 2, label: 'Description', spec: '520$a')
CREATOR_PERSONAL =
Field.new(order: 2, label: 'Creator', spec: '700')
CREATOR_CORPORATE =
Field.new(order: 2, label: 'Creator', spec: '710')
TRACKS =
Field.new(order: 99, label: 'Tracks', spec: TAG_TRACK_FIELD, subfield_order: %w[g t a])
Field.new(order: 998, label: 'Linked Resources', spec: "#{TAG_LINK_FIELD}{^1=\\4}{^2=\\1}")
TRANSCRIPTS =

rubocop:disable Layout/LineLength

Field.new(order: 999, label: 'Transcripts', spec: "#{TAG_TRANSCRIPT_FIELD}{$y~\\Transcript}{^1=\\4}{^2=\\2}", subfield_order: %w[u y])
STANDARD_FIELDS =

rubocop:enable Layout/LineLength

[
  TITLE,
  DESCRIPTION,
  CREATOR_PERSONAL,
  CREATOR_CORPORATE,
  TRACKS,
  TRANSCRIPTS,
  CATALOG_LINK
].freeze
TIND_CONFIG =
File.join(__dir__, 'tind_html_metadata_da.json')
REQ_ATTRS =
%w[visible params labels order].freeze
TAG_ATTRS =
%w[tag fields tag_1 tag_2].freeze
TAG_RE =
/(?<tag>[0-9]{3})(?<ind1>[a-z0-9_%])(?<ind2>[a-z0-9_%])(?<subfield>[a-z0-9])?/

Constants included from Constants

Constants::ALMA_RECORD_RE, Constants::MILLENNIUM_RECORD_RE, Constants::OCLC_RECORD_RE, Constants::SUBFIELD_CODES_TRACKS, Constants::SUBFIELD_CODE_ALMA_BIB_NUMBER, Constants::SUBFIELD_CODE_DURATION, Constants::SUBFIELD_CODE_LINKTEXT, Constants::SUBFIELD_CODE_PATH, Constants::SUBFIELD_CODE_TIND_BIB_NUMBER, Constants::SUBFIELD_CODE_TITLE, Constants::SUBFIELD_CODE_URI, Constants::TAG_ALMA_MIGRATION_INFO, Constants::TAG_LINK_FIELD, Constants::TAG_TIND_CATALOG_ID, Constants::TAG_TIND_ID, Constants::TAG_TITLE_FIELD, Constants::TAG_TRACK_FIELD, Constants::TAG_TRANSCRIPT_FIELD, Constants::UNKNOWN_TITLE

Class Method Summary collapse

Class Method Details

.default_fieldsObject



38
39
40
41
42
43
# File 'lib/berkeley_library/av/metadata/fields.rb', line 38

def default_fields
  @default_fields ||= begin
    default_fields = STANDARD_FIELDS + from_tind_config(TIND_CONFIG)
    (default_fields)
  end
end

.default_values_from(marc_record) ⇒ Object



50
51
52
53
54
55
# File 'lib/berkeley_library/av/metadata/fields.rb', line 50

def default_values_from(marc_record)
  default_fields.each_with_object({}) do |f, vv|
    field_value = f.value_from(marc_record)
    vv[f] = field_value if field_value
  end
end

.from_tind_config(json_config) ⇒ Object



45
46
47
48
# File 'lib/berkeley_library/av/metadata/fields.rb', line 45

def from_tind_config(json_config)
  json_config_hash = ensure_hash(json_config)
  json_config_hash['config'].filter_map { |jf| to_field(jf) }
end