Sha256: 8ceb1bb73b022b310f8c37e93df3387b987704cbe6a7700020f3b66bddae48b8

Contents?: true

Size: 730 Bytes

Versions: 1

Compression:

Stored size: 730 Bytes

Contents

class CsvEncodingError < StandardError ; end

module Eeml
  class CsvParserV2

    def self.make_environment_from_csv(csv_content)
      csv = LightCsv.parse(strip_content(csv_content))
      environment = Environment.new(:csv_version => 'v2')

      csv = strip_content(csv)

      csv.each do |datastream|
        raise(CsvEncodingError, "CSV is invalid. Double check you are properly encoding line breaks.") if datastream.length == 3 && datastream[1].include?('\n')
        raise(CsvEncodingError, "CSV is invalid. Incorrect number of fields.") if datastream.length != 2
        environment.datastreams << DataStream.new(:value => datastream.last, :identifier => datastream.first)
      end
      environment
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eeml-0.0.29 lib/eeml/csv_parser_v2.rb