summaryrefslogtreecommitdiff
path: root/lib/csv.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-04-07 16:44:49 -0700
committerJeremy Evans <code@jeremyevans.net>2019-08-30 12:39:31 -0700
commitd08e1004e0ee1286e4513de2a170391a4d0a0116 (patch)
tree5c7dd8244c2bf4c0f9b06725f3585c7ffc710ef3 /lib/csv.rb
parent3f67fcd3d5ca5e2907790eb5bb16d03f5884ece8 (diff)
Fix keyword argument separation issues in lib
Mostly requires adding ** in either calls or method definitions.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2395
Diffstat (limited to 'lib/csv.rb')
-rw-r--r--lib/csv.rb36
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/csv.rb b/lib/csv.rb
index 4893b94e88..61702137d0 100644
--- a/lib/csv.rb
+++ b/lib/csv.rb
@@ -432,7 +432,7 @@ class CSV
# fetch or create the instance for this signature
@@instances ||= Hash.new
- instance = (@@instances[sig] ||= new(data, options))
+ instance = (@@instances[sig] ||= new(data, **options))
if block_given?
yield instance # run block, if given, returning result
@@ -480,8 +480,8 @@ class CSV
end
end
# build input and output wrappers
- input = new(input || ARGF, in_options)
- output = new(output || $stdout, out_options)
+ input = new(input || ARGF, **in_options)
+ output = new(output || $stdout, **out_options)
# read, yield, write
input.each do |row|
@@ -505,8 +505,8 @@ class CSV
# but transcode it to UTF-8 before CSV parses it.
#
def self.foreach(path, mode="r", **options, &block)
- return to_enum(__method__, path, mode, options) unless block_given?
- open(path, mode, options) do |csv|
+ return to_enum(__method__, path, mode, **options) unless block_given?
+ open(path, mode, **options) do |csv|
csv.each(&block)
end
end
@@ -539,7 +539,7 @@ class CSV
str = +""
str.force_encoding(encoding) if encoding
end
- csv = new(str, options) # wrap
+ csv = new(str, **options) # wrap
yield csv # yield for appending
csv.string # return final String
end
@@ -565,7 +565,7 @@ class CSV
elsif field = row.find {|f| f.is_a?(String)}
str.force_encoding(field.encoding)
end
- (new(str, options) << row).string
+ (new(str, **options) << row).string
end
#
@@ -645,7 +645,7 @@ class CSV
retry
end
begin
- csv = new(f, options)
+ csv = new(f, **options)
rescue Exception
f.close
raise
@@ -675,8 +675,8 @@ class CSV
# You pass your +str+ to read from, and an optional +options+ containing
# anything CSV::new() understands.
#
- def self.parse(*args, &block)
- csv = new(*args)
+ def self.parse(*args, **options, &block)
+ csv = new(*args, **options)
return csv.each(&block) if block_given?
@@ -696,7 +696,7 @@ class CSV
# The +options+ parameter can be anything CSV::new() understands.
#
def self.parse_line(line, **options)
- new(line, options).shift
+ new(line, **options).shift
end
#
@@ -710,13 +710,13 @@ class CSV
# <tt>encoding: "UTF-32BE:UTF-8"</tt> would read UTF-32BE data from the file
# but transcode it to UTF-8 before CSV parses it.
#
- def self.read(path, *options)
- open(path, *options) { |csv| csv.read }
+ def self.read(*args, **options)
+ open(*args, **options) { |csv| csv.read }
end
# Alias for CSV::read().
- def self.readlines(*args)
- read(*args)
+ def self.readlines(*args, **options)
+ read(*args, **options)
end
#
@@ -727,9 +727,9 @@ class CSV
# header_converters: :symbol }.merge(options) )
#
def self.table(path, **options)
- read( path, { headers: true,
- converters: :numeric,
- header_converters: :symbol }.merge(options) )
+ read( path, **{ headers: true,
+ converters: :numeric,
+ header_converters: :symbol }.merge(options) )
end
#