Module: Kiba::Extend::Marc

Extended by:
Dry::Configurable
Defined in:
lib/kiba/extend/marc.rb

Overview

Configuration and shared methods for MARC data

Since:

  • 3.3.0

Class Method Summary collapse

Class Method Details

.field_tag_targetSymbol

Returns field in which the write the field tag value from which data was extracted when converting MARC data to Hash row.

Returns:

  • (Symbol)

    field in which the write the field tag value from which data was extracted when converting MARC data to Hash row

Since:

  • 3.3.0



14
# File 'lib/kiba/extend/marc.rb', line 14

setting :field_tag_target, default: :sourcefield, reader: true

.id_field_selectorProc?

Returns Code to perform any further selection from the Array of fields having the configured id_tag, after any given id_subfield and id_subfield_selector constraints have been met in the field selection.

The Proc should take one argument, which is an Array of MARC::ControlField or MARC::DataField objects.

The Proc should return an Array of MARC::ControlField or MARC::DataField objects.

Returns:

  • (Proc, nil)

    Code to perform any further selection from the Array of fields having the configured id_tag, after any given id_subfield and id_subfield_selector constraints have been met in the field selection.

    The Proc should take one argument, which is an Array of MARC::ControlField or MARC::DataField objects.

    The Proc should return an Array of MARC::ControlField or MARC::DataField objects.

Since:

  • 3.3.0



27
28
29
# File 'lib/kiba/extend/marc.rb', line 27

setting :id_field_selector,
default: ->(fields) { [fields.first] },
reader: true

.id_subfieldString

Returns subfield of :id_tag field from which to extract id.

Returns:

  • (String)

    subfield of :id_tag field from which to extract id

Since:

  • 3.3.0



32
# File 'lib/kiba/extend/marc.rb', line 32

setting :id_subfield, default: nil, reader: true

.id_subfield_selectorProc?

The Proc should take one argument, which is a String (usually derived by calling MARC::Subfield.value.

The Proc should return TrueClass or FalseClass

Returns:

  • (Proc, nil)

    Code specifying criteria a subfield value must meet in order to be selected as a MARC ID value. Eg. must begin with (OCoLC)

Since:

  • 3.3.0



41
# File 'lib/kiba/extend/marc.rb', line 41

setting :id_subfield_selector, default: nil, reader: true

.id_tagString

Returns the MARC field tag from which id value is extracted.

Returns:

  • (String)

    the MARC field tag from which id value is extracted

Since:

  • 3.3.0



16
# File 'lib/kiba/extend/marc.rb', line 16

setting :id_tag, default: "001", reader: true

.id_target_fieldSymbol

Returns field in which to write the MARC id value when converting MARC data to CSV row.

Returns:

  • (Symbol)

    field in which to write the MARC id value when converting MARC data to CSV row

Since:

  • 3.3.0



53
# File 'lib/kiba/extend/marc.rb', line 53

setting :id_target_field, default: :marcid, reader: true

.id_value_formatterProc

The Proc should take one argument, which is an Array of Strings.

The Proc should return a String.

Returns:

  • (Proc)

    Code specifying how to transform values extracted from id_tag/id_subfield into a final ID string.

Since:

  • 3.3.0



48
49
50
# File 'lib/kiba/extend/marc.rb', line 48

setting :id_value_formatter,
default: ->(values) { values.first },
reader: true

.linked_fields(record, tag) ⇒ Array<MARC::DataField>

Returns 880 fields linked to fields with given tag.

Parameters:

  • record (MARC::Record)
  • tag (String)

    of normal MARC field, e.g. ‘245’

Returns:

  • (Array<MARC::DataField>)

    880 fields linked to fields with given tag

Since:

  • 3.3.0



143
144
145
146
147
# File 'lib/kiba/extend/marc.rb', line 143

def linked_fields(record, tag)
  record.find_all do |field|
    field.tag == "880" && field["6"].start_with?(tag)
  end
end

.meeting_data_tagsArray<String>

Returns MARC field tags for fields that contain the structured meeting name data pattern documented at https://www.loc.gov/marc/bibliographic/bdx11.html.

Returns:

  • (Array<String>)

    MARC field tags for fields that contain the structured meeting name data pattern documented at https://www.loc.gov/marc/bibliographic/bdx11.html

Since:

  • 3.3.0



57
58
59
# File 'lib/kiba/extend/marc.rb', line 57

setting :meeting_data_tags,
default: %w[111 611 711 811],
reader: true

.meeting_name_part_subfieldsArray<String>

Returns subfields to be extracted as part of name values from meeting_data_tags.

Returns:

  • (Array<String>)

    subfields to be extracted as part of name values from meeting_data_tags

Since:

  • 3.3.0



62
63
64
# File 'lib/kiba/extend/marc.rb', line 62

setting :meeting_name_part_subfields,
default: %w[a q b c e d g n u],
reader: true

.meeting_role_code_subfieldsArray<String>

Returns subfields to be extracted as meeting role codes from meeting_data_tags.

Returns:

  • (Array<String>)

    subfields to be extracted as meeting role codes from meeting_data_tags

Since:

  • 3.3.0



67
68
69
# File 'lib/kiba/extend/marc.rb', line 67

setting :meeting_role_code_subfields,
default: %w[4],
reader: true

.meeting_role_term_subfieldsArray<String>

Returns subfields to be extracted as meeting role terms from meeting_data_tags.

Returns:

  • (Array<String>)

    subfields to be extracted as meeting role terms from meeting_data_tags

Since:

  • 3.3.0



72
73
74
# File 'lib/kiba/extend/marc.rb', line 72

setting :meeting_role_term_subfields,
default: %w[j],
reader: true

.name_targetSymbol

Returns field in which to write the name value when converting MARC data to CSV row when extracting names.

Returns:

  • (Symbol)

    field in which to write the name value when converting MARC data to CSV row when extracting names

Since:

  • 3.3.0



77
# File 'lib/kiba/extend/marc.rb', line 77

setting :name_target, default: :name, reader: true

.name_type_targetSymbol

Returns field in which to write the name type value when converting MARC data to CSV row when extracting names.

Returns:

  • (Symbol)

    field in which to write the name type value when converting MARC data to CSV row when extracting names

Since:

  • 3.3.0



80
# File 'lib/kiba/extend/marc.rb', line 80

setting :name_type_target, default: :nametype, reader: true

.org_data_tagsArray<String>

Returns MARC field tags for fields that contain the structured org name data pattern documented at https://www.loc.gov/marc/bibliographic/bdx10.html.

Returns:

  • (Array<String>)

    MARC field tags for fields that contain the structured org name data pattern documented at https://www.loc.gov/marc/bibliographic/bdx10.html

Since:

  • 3.3.0



84
85
86
# File 'lib/kiba/extend/marc.rb', line 84

setting :org_data_tags,
default: %w[110 610 710 810],
reader: true

.org_name_part_subfieldsArray<String>

Returns subfields to be extracted as part of name values from org_data_tags.

Returns:

  • (Array<String>)

    subfields to be extracted as part of name values from org_data_tags

Since:

  • 3.3.0



89
90
91
# File 'lib/kiba/extend/marc.rb', line 89

setting :org_name_part_subfields,
default: %w[a b c d g n u],
reader: true

.org_role_code_subfieldsArray<String>

Returns subfields to be extracted as org role codes from org_data_tags.

Returns:

  • (Array<String>)

    subfields to be extracted as org role codes from org_data_tags

Since:

  • 3.3.0



94
95
96
# File 'lib/kiba/extend/marc.rb', line 94

setting :org_role_code_subfields,
default: %w[4],
reader: true

.org_role_term_subfieldsArray<String>

Returns subfields to be extracted as org role terms from org_data_tags.

Returns:

  • (Array<String>)

    subfields to be extracted as org role terms from org_data_tags

Since:

  • 3.3.0



99
100
101
# File 'lib/kiba/extend/marc.rb', line 99

setting :org_role_term_subfields,
default: %w[e],
reader: true

.person_data_tagsArray<String>

Returns MARC field tags for fields that contain the structured person name data pattern documented at https://www.loc.gov/marc/bibliographic/bdx00.html.

Returns:

  • (Array<String>)

    MARC field tags for fields that contain the structured person name data pattern documented at https://www.loc.gov/marc/bibliographic/bdx00.html

Since:

  • 3.3.0



105
106
107
# File 'lib/kiba/extend/marc.rb', line 105

setting :person_data_tags,
default: %w[100 600 700 800],
reader: true

.person_name_part_subfieldsArray<String>

Returns subfields to be extracted as part of name values from person_data_tags.

Returns:

  • (Array<String>)

    subfields to be extracted as part of name values from person_data_tags

Since:

  • 3.3.0



110
111
112
# File 'lib/kiba/extend/marc.rb', line 110

setting :person_name_part_subfields,
default: %w[a b c d j q u],
reader: true

.person_role_code_subfieldsArray<String>

Returns subfields to be extracted as person role codes from person_data_tags.

Returns:

  • (Array<String>)

    subfields to be extracted as person role codes from person_data_tags

Since:

  • 3.3.0



115
116
117
# File 'lib/kiba/extend/marc.rb', line 115

setting :person_role_code_subfields,
default: %w[4],
reader: true

.person_role_term_subfieldsArray<String>

Returns subfields to be extracted as person role terms from person_data_tags.

Returns:

  • (Array<String>)

    subfields to be extracted as person role terms from person_data_tags

Since:

  • 3.3.0



120
121
122
# File 'lib/kiba/extend/marc.rb', line 120

setting :person_role_term_subfields,
default: %w[e],
reader: true

.prefer_vernacularBoolean

Returns If true, returns linked 880 field values instead of main field (transliterated values). If false, returns main field value, followed by 880 field value.

Returns:

  • (Boolean)

    If true, returns linked 880 field values instead of main field (transliterated values). If false, returns main field value, followed by 880 field value

Since:

  • 3.3.0



126
# File 'lib/kiba/extend/marc.rb', line 126

setting :prefer_vernacular, default: true, reader: true

.role_code_targetSymbol

Returns field in which to write the role code value when converting MARC data to CSV row for name extraction.

Returns:

  • (Symbol)

    field in which to write the role code value when converting MARC data to CSV row for name extraction

Since:

  • 3.3.0



129
# File 'lib/kiba/extend/marc.rb', line 129

setting :role_code_target, default: :role_code, reader: true

.role_term_targetSymbol

Returns field in which to write the role term value when converting MARC data to CSV row for name extraction.

Returns:

  • (Symbol)

    field in which to write the role term value when converting MARC data to CSV row for name extraction

Since:

  • 3.3.0



132
# File 'lib/kiba/extend/marc.rb', line 132

setting :role_term_target, default: :role_term, reader: true

.title_part_subfieldsArray<String>

Returns subfields to be extracted as part of title from 245 fields.

Returns:

  • (Array<String>)

    subfields to be extracted as part of title from 245 fields

Since:

  • 3.3.0



135
136
137
# File 'lib/kiba/extend/marc.rb', line 135

setting :title_part_subfields,
default: %w[a b f g k n p s],
reader: true