[前][次][番号順一覧][スレッド一覧]

ruby-changes:41109

From: nobu <ko1@a...>
Date: Fri, 18 Dec 2015 12:55:34 +0900 (JST)
Subject: [ruby-changes:41109] nobu:r53184 (trunk): csv.rb: tail commas

nobu	2015-12-18 12:55:29 +0900 (Fri, 18 Dec 2015)

  New Revision: 53184

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53184

  Log:
    csv.rb: tail commas
    
    * lib/csv.rb (CSV::Converters, CSV::DEFAULT_OPTIONS): supply tail
      commas for further elements.

  Modified files:
    trunk/lib/csv.rb
Index: lib/csv.rb
===================================================================
--- lib/csv.rb	(revision 53183)
+++ lib/csv.rb	(revision 53184)
@@ -949,30 +949,32 @@ class CSV https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L949
   # 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 https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L1020
   # <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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]