Sha256: 700745739d8c7a2532d2c57423d411c5bfec163477af74542bda1e5a9de9e1d6

Contents?: true

Size: 858 Bytes

Versions: 3

Compression:

Stored size: 858 Bytes

Contents

require "cascade/columns_matching"
require "cascade/registry"

module Cascade
  class DataParser
    def initialize(options = {})
      @data_provider  = options.fetch(:data_provider) { Registry.data_provider }
      @row_processor  = options.fetch(:row_processor) { Registry.row_processor }
      @error_handler  = options.fetch(:error_handler) { Registry.error_handler }
      @data_saver     = options.fetch(:data_saver)    { Registry.data_saver }
    end

    # Starts parsing processing with opening file and iterating through each
    # line with parsing and then saves result of each line parsing with
    # DataSaver
    #
    def call
      @data_provider.each_with_index do |row, row_number|
        @error_handler.with_errors_handling(row) do
          @data_saver.call @row_processor.call(row), row_number
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cascade-rb-0.2.3 lib/cascade/data_parser.rb
cascade-rb-0.2.2 lib/cascade/data_parser.rb
cascade-rb-0.2.1 lib/cascade/data_parser.rb