class BBMB::Util::CsvImporter
Public Instance Methods
import(io, persistence=BBMB.persistence)
click to toggle source
# File lib/bbmb/util/csv_importer.rb, line 12 def import(io, persistence=BBMB.persistence) count = 0 if io.respond_to?(:path) get_encoding = `file --brief "#{io.path}"` io.set_encoding('ISO-8859-1', 'UTF-8') if /^ISO-8859/.match(get_encoding) end io.each { |line| next if line.size < 5 record = line.split("\t") if(object = import_record(record)) persistence.save(object) end count += 1 } postprocess(persistence) count end
postprocess(persistence=BBMB.persistence)
click to toggle source
# File lib/bbmb/util/csv_importer.rb, line 30 def postprocess(persistence=BBMB.persistence) end
string(str)
click to toggle source
# File lib/bbmb/util/csv_importer.rb, line 32 def string(str) str = str.to_s.strip str.gsub(/\s+/, ' ') unless str.empty? end