diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-18 03:55:29 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-18 03:55:29 +0000 |
commit | 5f92358977cd2b58f0f2202528b29f026c9da94f (patch) | |
tree | 777d8719b38c4f5556650e9e30bb7171ae56ad79 | |
parent | 2537ed5734d0882d7312d6cee4393e74c584922b (diff) | |
download | ruby-5f92358977cd2b58f0f2202528b29f026c9da94f.tar.gz |
csv.rb: tail commas
* lib/csv.rb (CSV::Converters, CSV::DEFAULT_OPTIONS): supply tail
commas for further elements.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | lib/csv.rb | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/lib/csv.rb b/lib/csv.rb index 6e005cf20d..6456da8103 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -949,30 +949,32 @@ class CSV # To add a combo field, the value should be an Array of names. Combo fields # can be nested with other combo fields. # - Converters = { integer: lambda { |f| - Integer(f.encode(ConverterEncoding)) rescue f - }, - float: lambda { |f| - Float(f.encode(ConverterEncoding)) rescue f - }, - numeric: [:integer, :float], - date: lambda { |f| - begin - e = f.encode(ConverterEncoding) - e =~ DateMatcher ? Date.parse(e) : f - rescue # encoding conversion or date parse errors - f - end - }, - date_time: lambda { |f| - begin - e = f.encode(ConverterEncoding) - e =~ DateTimeMatcher ? DateTime.parse(e) : f - rescue # encoding conversion or date parse errors - f - end - }, - all: [:date_time, :numeric] } + Converters = { + integer: lambda { |f| + Integer(f.encode(ConverterEncoding)) rescue f + }, + float: lambda { |f| + Float(f.encode(ConverterEncoding)) rescue f + }, + numeric: [:integer, :float], + date: lambda { |f| + begin + e = f.encode(ConverterEncoding) + e =~ DateMatcher ? Date.parse(e) : f + rescue # encoding conversion or date parse errors + f + end + }, + date_time: lambda { |f| + begin + e = f.encode(ConverterEncoding) + e =~ DateTimeMatcher ? DateTime.parse(e) : f + rescue # encoding conversion or date parse errors + f + end + }, + all: [:date_time, :numeric], + } # # This Hash holds the built-in header converters of CSV that can be accessed @@ -1018,18 +1020,20 @@ class CSV # <b><tt>:force_quotes</tt></b>:: +false+ # <b><tt>:skip_lines</tt></b>:: +nil+ # - DEFAULT_OPTIONS = { col_sep: ",", - row_sep: :auto, - quote_char: '"', - field_size_limit: nil, - converters: nil, - unconverted_fields: nil, - headers: false, - return_headers: false, - header_converters: nil, - skip_blanks: false, - force_quotes: false, - skip_lines: nil }.freeze + DEFAULT_OPTIONS = { + col_sep: ",", + row_sep: :auto, + quote_char: '"', + field_size_limit: nil, + converters: nil, + unconverted_fields: nil, + headers: false, + return_headers: false, + header_converters: nil, + skip_blanks: false, + force_quotes: false, + skip_lines: nil, + }.freeze # # This method will return a CSV instance, just like CSV::new(), but the |