Sha256: c4a6083bd87bdff0f40eb38d137770756b95186d4252f87868df286872085d2d

Contents?: true

Size: 792 Bytes

Versions: 16

Compression:

Stored size: 792 Bytes

Contents

# This file allows us to choose the CSV library we want to use.

require 'csv'
# Using relevant core CSV library.
CSVLibrary = CSV

class << CSVLibrary
  # Is the library we're using FasterCSV?
  def fastercsv?
    not self.const_defined?(:Reader)
  end

  def write_csv_to_string(data)
    self.generate do |csv|
      data.each { |line| csv << line }
    end
  end

  def write_csv_to_file(data, filepath, mode = 'w')
    self.open(filepath, mode) do |csv|
      data.each { |line| csv << line }
    end
  end

  def read_csv_from_file(filepath)
    self.read(filepath)
  end
end

# Forward port CSV::Cell, as it is sometimes
# serialised in YAML. :-(
class CSV::Cell < String
  def initialize(data = '', is_null = false)
    super(is_null ? '' : data)
  end

  def data
    to_s
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ndr_import-4.1.4 lib/ndr_import/csv_library.rb
ndr_import-4.1.3 lib/ndr_import/csv_library.rb
ndr_import-4.1.2 lib/ndr_import/csv_library.rb
ndr_import-4.1.1 lib/ndr_import/csv_library.rb
ndr_import-4.1.0 lib/ndr_import/csv_library.rb
ndr_import-4.0.1 lib/ndr_import/csv_library.rb
ndr_import-4.0.0 lib/ndr_import/csv_library.rb
ndr_import-3.1.6 lib/ndr_import/csv_library.rb
ndr_import-3.1.5 lib/ndr_import/csv_library.rb
ndr_import-3.1.4 lib/ndr_import/csv_library.rb
ndr_import-3.1.3 lib/ndr_import/csv_library.rb
ndr_import-3.1.2 lib/ndr_import/csv_library.rb
ndr_import-3.1.1 lib/ndr_import/csv_library.rb
ndr_import-3.1.0 lib/ndr_import/csv_library.rb
ndr_import-3.0.1 lib/ndr_import/csv_library.rb
ndr_import-3.0.0 lib/ndr_import/csv_library.rb