summaryrefslogtreecommitdiff
path: root/lib/csv.rb
diff options
context:
space:
mode:
authorSutou Kouhei <[email protected]>2021-09-12 07:34:15 +0900
committerSutou Kouhei <[email protected]>2021-10-24 05:57:33 +0900
commit8ba98f83b0fa8634c68e2d86e71718cc8097bfcf (patch)
tree8093406ef146891d9254f179aeac3378b997f279 /lib/csv.rb
parent7f3dd601c895354c041988251a0be05a8a423664 (diff)
[ruby/csv] Use "\n" for the default row separator on Ruby 3.0 or later
https://github.com/ruby/csv/commit/1f9cbc170e
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5010
Diffstat (limited to 'lib/csv.rb')
-rw-r--r--lib/csv.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/csv.rb b/lib/csv.rb
index 3881ba24c2..91aeb19a3c 100644
--- a/lib/csv.rb
+++ b/lib/csv.rb
@@ -90,11 +90,11 @@
# with any questions.
require "forwardable"
-require "English"
require "date"
require "stringio"
require_relative "csv/fields_converter"
+require_relative "csv/input_record_separator"
require_relative "csv/match_p"
require_relative "csv/parser"
require_relative "csv/row"
@@ -1051,7 +1051,7 @@ class CSV
# out_string # => "FOO,0000\nBAR,1111\nBAZ,2222\n"
def filter(input=nil, output=nil, **options)
# parse options for input, output, or both
- in_options, out_options = Hash.new, {row_sep: $INPUT_RECORD_SEPARATOR}
+ in_options, out_options = Hash.new, {row_sep: InputRecordSeparator.value}
options.each do |key, value|
case key.to_s
when /\Ain(?:put)?_(.+)\Z/
@@ -1292,8 +1292,8 @@ class CSV
# Argument +ary+ must be an \Array.
#
# Special options:
- # * Option <tt>:row_sep</tt> defaults to <tt>$INPUT_RECORD_SEPARATOR</tt>
- # (<tt>$/</tt>).:
+ # * Option <tt>:row_sep</tt> defaults to <tt>"\n"> on Ruby 3.0 or later
+ # and <tt>$INPUT_RECORD_SEPARATOR</tt> (<tt>$/</tt>) otherwise.:
# $INPUT_RECORD_SEPARATOR # => "\n"
# * This method accepts an additional option, <tt>:encoding</tt>, which sets the base
# Encoding for the output. This method will try to guess your Encoding from
@@ -1315,7 +1315,7 @@ class CSV
# CSV.generate_line(:foo)
#
def generate_line(row, **options)
- options = {row_sep: $INPUT_RECORD_SEPARATOR}.merge(options)
+ options = {row_sep: InputRecordSeparator.value}.merge(options)
str = +""
if options[:encoding]
str.force_encoding(options[:encoding])