Class: Traject::Indexer::MarcIndexer

Inherits:
Traject::Indexer show all
Includes:
Macros::Marc21
Defined in:
lib/traject/indexer/marc_indexer.rb

Overview

An indexer sub-class that includes "extract_marc" and other macros from Traject::Macros::Marc21, and also adds some marc-specific default settings.

Constant Summary

Constants included from Macros::Marc21

Macros::Marc21::EXTRACT_ALL_MARC_VALID_OPTIONS, Macros::Marc21::EXTRACT_MARC_VALID_OPTIONS, Macros::Marc21::SERIALZED_MARC_VALID_OPTIONS

Constants inherited from Traject::Indexer

ArityError, CompletedStateError, NamingError

Instance Attribute Summary

Attributes inherited from Traject::Indexer

#logger, #reader_class, #writer, #writer_class

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Macros::Marc21

apply_extraction_options, #extract_all_marc_values, extract_marc, extract_marc_from, first!, #serialized_marc, #trim_punctuation, trim_punctuation

Methods inherited from Traject::Indexer

#after_processing, apply_class_configure_block, #complete, #completed?, #configure, configure, #create_logger, #each_record, #initialize, legacy_marc_mode!, #load_config_file, #log_skip, #logger_format, #map_record, #map_to_context!, #process, #process_record, #process_with, #reader!, #run_after_processing_steps, #settings, #to_field, #writer!

Methods included from QualifiedConstGet

#qualified_const_get

Methods included from Macros::Transformation

#append, #default, #first_only, #gsub, #prepend, #split, #strip, #transform, #translation_map, #unique

Methods included from Macros::Basic

#literal

Constructor Details

This class inherits a constructor from Traject::Indexer

Class Method Details

.default_settingsObject



8
9
10
11
12
13
14
15
16
# File 'lib/traject/indexer/marc_indexer.rb', line 8

def self.default_settings
  @default_settings ||= begin
    marc_settings = {
      "reader_class_name"       => "Traject::MarcReader",
      "marc_source.type"        => "binary",
    }
    super.merge(marc_settings)
  end
end

Instance Method Details

#source_record_id_procObject

Overridden from base Indexer, to get MARC 001 for log messages.



19
20
21
22
23
24
25
26
27
# File 'lib/traject/indexer/marc_indexer.rb', line 19

def source_record_id_proc
  @source_record_id_proc ||= lambda do |source_marc_record|
    if ( source_marc_record &&
         source_marc_record.kind_of?(MARC::Record) &&
         source_marc_record['001'] )
      source_marc_record['001'].value
    end
  end
end