Sha256: 5f15cd1df76e781694895a81c2501b5456f9d0a34b2b5120970206ee0da85fed

Contents?: true

Size: 593 Bytes

Versions: 12

Compression:

Stored size: 593 Bytes

Contents

require 'arc-furnace/csv_to_hash_with_duplicate_headers'
require 'arc-furnace/enumerator_source'
require 'csv'

module ArcFurnace
  class CSVSource < EnumeratorSource
    include CSVToHashWithDuplicateHeaders
    attr_reader :value, :file

    def initialize(filename: , encoding: 'UTF-8')
      @file = File.open(filename, encoding: encoding)
      super()
    end

    def finalize
      file.close
    end

    def build_enumerator
      Enumerator.new do |yielder|
        CSV.new(file, headers: true).each { |row| yielder << csv_to_hash_with_duplicates(row) }
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
arc-furnace-0.1.25 lib/arc-furnace/csv_source.rb
arc-furnace-0.1.24 lib/arc-furnace/csv_source.rb
arc-furnace-0.1.23 lib/arc-furnace/csv_source.rb
arc-furnace-0.1.22 lib/arc-furnace/csv_source.rb
arc-furnace-0.1.21 lib/arc-furnace/csv_source.rb
arc-furnace-0.1.20 lib/arc-furnace/csv_source.rb
arc-furnace-0.1.19 lib/arc-furnace/csv_source.rb
arc-furnace-0.1.18 lib/arc-furnace/csv_source.rb
arc-furnace-0.1.16 lib/arc-furnace/csv_source.rb
arc-furnace-0.1.15 lib/arc-furnace/csv_source.rb
arc-furnace-0.1.14 lib/arc-furnace/csv_source.rb
arc-furnace-0.1.13 lib/arc-furnace/csv_source.rb