ruby-changes:58219
From: Sutou <ko1@a...>
Date: Sat, 12 Oct 2019 14:03:39 +0900 (JST)
Subject: [ruby-changes:58219] 92df7d98b6 (master): Import CSV 3.1.2 (#2547)
https://git.ruby-lang.org/ruby.git/commit/?id=92df7d98b6 From 92df7d98b62f48cf21cdec522f2e7b34380fd718 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei <kou@c...> Date: Sat, 12 Oct 2019 14:03:21 +0900 Subject: Import CSV 3.1.2 (#2547) diff --git a/NEWS b/NEWS index 9a1c027..d265233 100644 --- a/NEWS +++ b/NEWS @@ -343,7 +343,7 @@ CGI:: https://github.com/ruby/ruby/blob/trunk/NEWS#L343 CSV:: - * Upgrade to 3.0.9. + * Upgrade to 3.1.2. See https://github.com/ruby/csv/blob/master/NEWS.md. Date:: diff --git a/lib/csv.rb b/lib/csv.rb index 60dbbcc..8aa6586 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -10,18 +10,18 @@ https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L10 # # Welcome to the new and improved CSV. # -# This version of the CSV library began its life as FasterCSV. FasterCSV was -# intended as a replacement to Ruby's then standard CSV library. It was +# This version of the CSV library began its life as FasterCSV. FasterCSV was +# intended as a replacement to Ruby's then standard CSV library. It was # designed to address concerns users of that library had and it had three # primary goals: # # 1. Be significantly faster than CSV while remaining a pure Ruby library. -# 2. Use a smaller and easier to maintain code base. (FasterCSV eventually -# grew larger, was also but considerably richer in features. The parsing +# 2. Use a smaller and easier to maintain code base. (FasterCSV eventually +# grew larger, was also but considerably richer in features. The parsing # core remains quite small.) # 3. Improve on the CSV interface. # -# Obviously, the last one is subjective. I did try to defer to the original +# Obviously, the last one is subjective. I did try to defer to the original # interface whenever I didn't have a compelling reason to change it though, so # hopefully this won't be too radically different. # @@ -29,20 +29,20 @@ https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L29 # the original library as of Ruby 1.9. If you are migrating code from 1.8 or # earlier, you may have to change your code to comply with the new interface. # -# == What's Different From the Old CSV? +# == What's the Different From the Old CSV? # # I'm sure I'll miss something, but I'll try to mention most of the major # differences I am aware of, to help others quickly get up to speed: # # === CSV Parsing # -# * This parser is m17n aware. See CSV for full details. +# * This parser is m17n aware. See CSV for full details. # * This library has a stricter parser and will throw MalformedCSVErrors on # problematic data. -# * This library has a less liberal idea of a line ending than CSV. What you -# set as the <tt>:row_sep</tt> is law. It can auto-detect your line endings +# * This library has a less liberal idea of a line ending than CSV. What you +# set as the <tt>:row_sep</tt> is law. It can auto-detect your line endings # though. -# * The old library returned empty lines as <tt>[nil]</tt>. This library calls +# * The old library returned empty lines as <tt>[nil]</tt>. This library calls # them <tt>[]</tt>. # * This library has a much faster parser. # @@ -56,9 +56,9 @@ https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L56 # * CSV now has a new() method used to wrap objects like String and IO for # reading and writing. # * CSV::generate() is different from the old method. -# * CSV no longer supports partial reads. It works line-by-line. +# * CSV no longer supports partial reads. It works line-by-line. # * CSV no longer allows the instance methods to override the separators for -# performance reasons. They must be set in the constructor. +# performance reasons. They must be set in the constructor. # # If you use this library and find yourself missing any functionality I have # trimmed, please {let me know}[mailto:james@g...]. @@ -70,16 +70,16 @@ https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L70 # == What is CSV, really? # # CSV maintains a pretty strict definition of CSV taken directly from -# {the RFC}[http://www.ietf.org/rfc/rfc4180.txt]. I relax the rules in only one -# place and that is to make using this library easier. CSV will parse all valid +# {the RFC}[http://www.ietf.org/rfc/rfc4180.txt]. I relax the rules in only one +# place and that is to make using this library easier. CSV will parse all valid # CSV. # -# What you don't want to do is feed CSV invalid data. Because of the way the +# What you don't want to do is to feed CSV invalid data. Because of the way the # CSV format works, it's common for a parser to need to read until the end of -# the file to be sure a field is invalid. This eats a lot of time and memory. +# the file to be sure a field is invalid. This consumes a lot of time and memory. # # Luckily, when working with invalid CSV, Ruby's built-in methods will almost -# always be superior in every way. For example, parsing non-quoted fields is as +# always be superior in every way. For example, parsing non-quoted fields is as # easy as: # # data.split(",") @@ -104,7 +104,7 @@ require_relative "csv/writer" https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L104 using CSV::MatchP if CSV.const_defined?(:MatchP) # -# This class provides a complete interface to CSV files and data. It offers +# This class provides a complete interface to CSV files and data. It offers # tools to enable you to read and write to and from Strings or IO objects, as # needed. # @@ -184,7 +184,7 @@ using CSV::MatchP if CSV.const_defined?(:MatchP) https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L184 # === CSV with headers # # CSV allows to specify column names of CSV file, whether they are in data, or -# provided separately. If headers specified, reading methods return an instance +# provided separately. If headers are specified, reading methods return an instance # of CSV::Table, consisting of CSV::Row. # # # Headers are part of data @@ -223,42 +223,42 @@ using CSV::MatchP if CSV.const_defined?(:MatchP) https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L223 # == CSV and Character Encodings (M17n or Multilingualization) # # This new CSV parser is m17n savvy. The parser works in the Encoding of the IO -# or String object being read from or written to. Your data is never transcoded +# or String object being read from or written to. Your data is never transcoded # (unless you ask Ruby to transcode it for you) and will literally be parsed in -# the Encoding it is in. Thus CSV will return Arrays or Rows of Strings in the -# Encoding of your data. This is accomplished by transcoding the parser itself +# the Encoding it is in. Thus CSV will return Arrays or Rows of Strings in the +# Encoding of your data. This is accomplished by transcoding the parser itself # into your Encoding. # # Some transcoding must take place, of course, to accomplish this multiencoding -# support. For example, <tt>:col_sep</tt>, <tt>:row_sep</tt>, and +# support. For example, <tt>:col_sep</tt>, <tt>:row_sep</tt>, and # <tt>:quote_char</tt> must be transcoded to match your data. Hopefully this # makes the entire process feel transparent, since CSV's defaults should just -# magically work for your data. However, you can set these values manually in +# magically work for your data. However, you can set these values manually in # the target Encoding to avoid the translation. # # It's also important to note that while all of CSV's core parser is now -# Encoding agnostic, some features are not. For example, the built-in +# Encoding agnostic, some features are not. For example, the built-in # converters will try to transcode data to UTF-8 before making conversions. # Again, you can provide custom converters that are aware of your Encodings to -# avoid this translation. It's just too hard for me to support native +# avoid this translation. It's just too hard for me to support native # conversions in all of Ruby's Encodings. # -# Anyway, the practical side of this is simple: make sure IO and String objects +# Anyway, the practical side of this is simple: make sure IO and String objects # passed into CSV have the proper Encoding set and everything should just work. # CSV methods that allow you to open IO objects (CSV::foreach(), CSV::open(), # CSV::read(), and CSV::readlines()) do allow you to specify the Encoding. # # One minor exception comes when generating CSV into a String with an Encoding -# that is not ASCII compatible. There's no existing data for CSV to use to +# that is not ASCII compatible. There's no existing data for CSV to use to # prepare itself and thus you will probably need to manually specify the desired -# Encoding for most of those cases. It will try to guess using the fields in a +# Encoding for most of those cases. It will try to guess using the fields in a # row of output though, when using CSV::generate_line() or Array#to_csv(). # # I try to point out any other Encoding issues in the documentation of methods # as they come up. # # This has been tested to the best of my ability with all non-"dummy" Encodings -# Ruby ships with. However, it is brave new code and may have some bugs. +# Ruby ships with. However, it is brave new code and may have some bugs. # Please feel free to {report}[mailto:james@g...] any issues you # find with it. # @@ -354,7 +354,7 @@ class CSV https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L354 # # This Hash holds the built-in header converters of CSV that can be accessed - # by name. You can select HeaderConverters with CSV.header_convert() or + # by name. You can select HeaderConverters with CSV.header_convert() or # through the +options+ Hash passed to CSV::new(). # # <b><tt>:downcase</tt></b>:: Calls downcase() on the header String. @@ -364,13 +364,13 @@ class CSV https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L364 # and finally to_sym() is called. # # All built-in header converters transcode header data to UTF-8 before (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/