Sha256: 6988b0e474808db7e4c420030492e9d2124b5fa5ac3e77128ce07a22de452b86

Contents?: true

Size: 838 Bytes

Versions: 4

Compression:

Stored size: 838 Bytes

Contents

require 'csv'
require 'berkeley_library/tind/mapping/util'

module BerkeleyLibrary
  module TIND
    module Mapping
      module CsvMapper
        @rows = []
        class << self
          attr_accessor :rows
        end

        CsvMapper.rows = Util.csv_rows(Config.one_to_one_map_file)

        def from_tags
          CsvMapper.rows.map { |row| row[:tag_origin] }.compact
        end

        def rules
          CsvMapper.rows.to_h { |row| ["tag_#{row[:tag_origin]}".to_sym, SingleRule.new(row)] }
        end

        # tags allow to keep the first datafield from original marc record
        def one_occurrence_tags
          tags = []
          CsvMapper.rows.each do |row|
            tags << row[:tag_origin] if row[:keep_one_if_multiple_available]
          end
          tags.compact
        end

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
berkeley_library-tind-0.7.2 lib/berkeley_library/tind/mapping/csv_mapper.rb
berkeley_library-tind-0.7.1 lib/berkeley_library/tind/mapping/csv_mapper.rb
berkeley_library-tind-0.7.0 lib/berkeley_library/tind/mapping/csv_mapper.rb
berkeley_library-tind-0.6.0 lib/berkeley_library/tind/mapping/csv_mapper.rb