Project

General

Profile

Defect #7039 » faster_csv.rb.patch

Patch that doesn't work - Sven Müller, 2011-09-09 15:42

View differences:

lib/faster_csv.rb (working copy)
}
#
# The options used when no overrides are given by calling code. They are:
#
# <b><tt>:col_sep</tt></b>:: <tt>","</tt>
# <b><tt>:col_sep</tt></b>:: <tt>";"</tt>
# <b><tt>:row_sep</tt></b>:: <tt>:auto</tt>
# <b><tt>:quote_char</tt></b>:: <tt>'"'</tt>
# <b><tt>:converters</tt></b>:: +nil+
# <b><tt>:unconverted_fields</tt></b>:: +nil+
# <b><tt>:headers</tt></b>:: +false+
# <b><tt>:return_headers</tt></b>:: +false+
# <b><tt>:header_converters</tt></b>:: +nil+
# <b><tt>:skip_blanks</tt></b>:: +false+
# <b><tt>:force_quotes</tt></b>:: +false+
#
DEFAULT_OPTIONS = { :col_sep => ",",
DEFAULT_OPTIONS = { :col_sep => ";",
:row_sep => :auto,
:quote_char => '"',
:converters => nil,
:unconverted_fields => nil,
:headers => false,
......
Object.const_set(:CSV, Class.new).class_eval do
def self.foreach(path, rs = :auto, &block) # :nodoc:
FasterCSV.foreach(path, :row_sep => rs, &block)
end
def self.generate_line(row, fs = ",", rs = "") # :nodoc:
def self.generate_line(row, fs = ";", rs = "") # :nodoc:
FasterCSV.generate_line(row, :col_sep => fs, :row_sep => rs)
end
def self.open(path, mode, fs = ",", rs = :auto, &block) # :nodoc:
def self.open(path, mode, fs = ";", rs = :auto, &block) # :nodoc:
if block and mode.include? "r"
FasterCSV.open(path, mode, :col_sep => fs, :row_sep => rs) do |csv|
csv.each(&block)
end
else
FasterCSV.open(path, mode, :col_sep => fs, :row_sep => rs, &block)
end
end
def self.parse(str_or_readable, fs = ",", rs = :auto, &block) # :nodoc:
def self.parse(str_or_readable, fs = ";", rs = :auto, &block) # :nodoc:
FasterCSV.parse(str_or_readable, :col_sep => fs, :row_sep => rs, &block)
end
def self.parse_line(src, fs = ",", rs = :auto) # :nodoc:
def self.parse_line(src, fs = ";", rs = :auto) # :nodoc:
FasterCSV.parse_line(src, :col_sep => fs, :row_sep => rs)
end
def self.readlines(path, rs = :auto) # :nodoc:
FasterCSV.readlines(path, :row_sep => rs)
(7-7/7)