Sha256: ac4e5ba69c11182c2260f8b9c6668fc3195aedb80b18d676f5ce5d693bca2c4e

Contents?: true

Size: 768 Bytes

Versions: 10

Compression:

Stored size: 768 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)

      datastreams = csv.collect 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
        DataStream.new(:value => datastream.last, :identifier => datastream.first)
      end
      environment.add_datastreams(datastreams)

      environment
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
eeml-0.0.41 lib/eeml/csv_parser_v2.rb
eeml-0.0.40 lib/eeml/csv_parser_v2.rb
eeml-0.0.39 lib/eeml/csv_parser_v2.rb
eeml-0.0.38 lib/eeml/csv_parser_v2.rb
eeml-0.0.37 lib/eeml/csv_parser_v2.rb
eeml-0.0.36 lib/eeml/csv_parser_v2.rb
eeml-0.0.35 lib/eeml/csv_parser_v2.rb
eeml-0.0.34 lib/eeml/csv_parser_v2.rb
eeml-0.0.33 lib/eeml/csv_parser_v2.rb
eeml-0.0.32 lib/eeml/csv_parser_v2.rb