Sha256: 9177a40fc2114a34d1d5bc27f45bbd0aeb00fde7847bcd642ddd695cc5d835ac

Contents?: true

Size: 851 Bytes

Versions: 8

Compression:

Stored size: 851 Bytes

Contents

# frozen_string_literal: true

module TrajectPlus
  module Macros
    # Macros for extracting values from CSV rows
    module Csv
      # Retrieve the value of the column with the given header or index.
      # @param header_or_index [String] the field header or index to accumulate
      def column(header_or_index, options = {})
        lambda do |row, accumulator, _context|
          return if row[header_or_index].to_s.empty?
          result = Array(row[header_or_index].to_s)
          unless options.empty?
            Deprecation.warn(self, "passing options to column is deprecated and will be removed in the next major release. Use the Traject 3 pipeline instead")
          end
          result = TrajectPlus::Extraction.apply_extraction_options(result, options)
          accumulator.concat(result)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
traject_plus-2.0.1 lib/traject_plus/macros/csv.rb
traject_plus-1.3.0 lib/traject_plus/macros/csv.rb
traject_plus-2.0.0 lib/traject_plus/macros/csv.rb
traject_plus-1.2.2 lib/traject_plus/macros/csv.rb
traject_plus-1.2.1 lib/traject_plus/macros/csv.rb
traject_plus-1.2.0 lib/traject_plus/macros/csv.rb
traject_plus-1.1.1 lib/traject_plus/macros/csv.rb
traject_plus-1.1.0 lib/traject_plus/macros/csv.rb