module SimpleCsv
Constants
- VERSION
Public Class Methods
converters_initialized?()
click to toggle source
# File lib/simple_csv.rb, line 54 def self.converters_initialized? @converters_initialized end
csv_manually_set_headers!()
click to toggle source
# File lib/simple_csv.rb, line 27 def self.csv_manually_set_headers! raise HeadersNotSet, ['CSV does not contain headers', 'please add headers in them manually or in the file'].join(', ') end
csv_not_enough_headers!()
click to toggle source
# File lib/simple_csv.rb, line 23 def self.csv_not_enough_headers! raise NotEnoughHeaders, 'Not enough headers defined!' end
generate(path, **options, &block)
click to toggle source
# File lib/simple_csv.rb, line 38 def self.generate(path, **options, &block) initialize_converters unless converters_initialized? Writer.new path, options, &block end
initialize_converters()
click to toggle source
# File lib/simple_csv.rb, line 48 def self.initialize_converters CSV::Converters[:blank_to_nil] = ->(f) { f && f.empty? ? nil : f } CSV::Converters[:null_to_nil] = ->(f) { f && f == 'NULL' ? nil : f } @converters_initialized = true end
read(path, **options, &block)
click to toggle source
# File lib/simple_csv.rb, line 33 def self.read(path, **options, &block) initialize_converters unless converters_initialized? Reader.new path, options, &block end
row_not_complete!(mtd, value)
click to toggle source
# File lib/simple_csv.rb, line 18 def self.row_not_complete!(mtd, value) raise RowNotComplete, "Row not complete! #{mtd} called twice with value #{value}" end
transform(path, **options, &block)
click to toggle source
# File lib/simple_csv.rb, line 43 def self.transform(path, **options, &block) initialize_converters unless converters_initialized? Transformer.new path, options, &block end