mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix keyword argument separation issues in lib
Mostly requires adding ** in either calls or method definitions.
This commit is contained in:
parent
3f67fcd3d5
commit
d08e1004e0
Notes:
git
2019-08-31 04:40:18 +09:00
13 changed files with 38 additions and 38 deletions
36
lib/csv.rb
36
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
|
||||
|
||||
#
|
||||
|
|
|
@ -4,6 +4,6 @@ class Array # :nodoc:
|
|||
# ["CSV", "data"].to_csv
|
||||
# #=> "CSV,data\n"
|
||||
def to_csv(**options)
|
||||
CSV.generate_line(self, options)
|
||||
CSV.generate_line(self, **options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,6 +4,6 @@ class String # :nodoc:
|
|||
# "CSV,data".parse_csv
|
||||
# #=> ["CSV", "data"]
|
||||
def parse_csv(**options)
|
||||
CSV.parse_line(self, options)
|
||||
CSV.parse_line(self, **options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -345,7 +345,7 @@ class CSV
|
|||
# csv_row.fields.to_csv( options )
|
||||
#
|
||||
def to_csv(**options)
|
||||
fields.to_csv(options)
|
||||
fields.to_csv(**options)
|
||||
end
|
||||
alias_method :to_s, :to_csv
|
||||
|
||||
|
|
|
@ -367,9 +367,9 @@ class CSV
|
|||
# pass <tt>:write_headers => false</tt>.
|
||||
#
|
||||
def to_csv(write_headers: true, **options)
|
||||
array = write_headers ? [headers.to_csv(options)] : []
|
||||
array = write_headers ? [headers.to_csv(**options)] : []
|
||||
@table.each do |row|
|
||||
array.push(row.fields.to_csv(options)) unless row.header_row?
|
||||
array.push(row.fields.to_csv(**options)) unless row.header_row?
|
||||
end
|
||||
|
||||
array.join("")
|
||||
|
|
|
@ -1456,7 +1456,7 @@ module Net
|
|||
|
||||
if defined?(OpenSSL::SSL::SSLSocket)
|
||||
class BufferedSSLSocket < BufferedSocket
|
||||
def initialize(*args)
|
||||
def initialize(*args, **options)
|
||||
super
|
||||
@is_shutdown = false
|
||||
end
|
||||
|
|
|
@ -322,7 +322,7 @@ module Net # :nodoc:
|
|||
|
||||
|
||||
class InternetMessageIO < BufferedIO #:nodoc: internal use only
|
||||
def initialize(*)
|
||||
def initialize(*, **)
|
||||
super
|
||||
@wbuf = nil
|
||||
end
|
||||
|
|
|
@ -269,7 +269,7 @@ class RDoc::Generator::Darkfish
|
|||
|
||||
@options.static_path.each do |path|
|
||||
unless File.directory? path then
|
||||
FileUtils.install path, @outputdir, fu_options.merge(:mode => 0644)
|
||||
FileUtils.install path, @outputdir, **fu_options.merge(:mode => 0644)
|
||||
next
|
||||
end
|
||||
|
||||
|
@ -278,9 +278,9 @@ class RDoc::Generator::Darkfish
|
|||
dest_file = @outputdir + entry
|
||||
|
||||
if File.directory? entry then
|
||||
FileUtils.mkdir_p entry, fu_options
|
||||
FileUtils.mkdir_p entry, **fu_options
|
||||
else
|
||||
FileUtils.install entry, dest_file, fu_options.merge(:mode => 0644)
|
||||
FileUtils.install entry, dest_file, **fu_options.merge(:mode => 0644)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -585,16 +585,16 @@ class RDoc::Generator::Darkfish
|
|||
return unless source.exist?
|
||||
|
||||
begin
|
||||
FileUtils.mkdir_p File.dirname(destination), options
|
||||
FileUtils.mkdir_p File.dirname(destination), **options
|
||||
|
||||
begin
|
||||
FileUtils.ln source, destination, options
|
||||
FileUtils.ln source, destination, **options
|
||||
rescue Errno::EEXIST
|
||||
FileUtils.rm destination
|
||||
retry
|
||||
end
|
||||
rescue
|
||||
FileUtils.cp source, destination, options
|
||||
FileUtils.cp source, destination, **options
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -469,7 +469,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|||
subdirs.each do |name|
|
||||
subdir = File.join dir, name
|
||||
next if File.exist? subdir
|
||||
FileUtils.mkdir_p subdir, options rescue nil
|
||||
FileUtils.mkdir_p subdir, **options rescue nil
|
||||
end
|
||||
ensure
|
||||
File.umask old_umask
|
||||
|
|
|
@ -129,7 +129,7 @@ By default, this RubyGems will install gem as:
|
|||
end
|
||||
|
||||
module MakeDirs
|
||||
def mkdir_p(path, *opts)
|
||||
def mkdir_p(path, **opts)
|
||||
super
|
||||
(@mkdirs ||= []) << path
|
||||
end
|
||||
|
|
|
@ -513,7 +513,7 @@ EOM
|
|||
path = File.expand_path(path + File::SEPARATOR + basename)
|
||||
lstat = File.lstat path rescue nil
|
||||
if !lstat || !lstat.directory?
|
||||
unless normalize_path(path).start_with? normalize_path(destination_dir) and (FileUtils.mkdir path, mkdir_options rescue false)
|
||||
unless normalize_path(path).start_with? normalize_path(destination_dir) and (FileUtils.mkdir path, **mkdir_options rescue false)
|
||||
raise Gem::Package::PathError.new(file_name, destination_dir)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -128,7 +128,7 @@ class Tempfile < DelegateClass(File)
|
|||
|
||||
@unlinked = false
|
||||
@mode = mode|File::RDWR|File::CREAT|File::EXCL
|
||||
::Dir::Tmpname.create(basename, tmpdir, options) do |tmpname, n, opts|
|
||||
::Dir::Tmpname.create(basename, tmpdir, **options) do |tmpname, n, opts|
|
||||
opts[:perm] = 0600
|
||||
@tmpfile = File.open(tmpname, @mode, opts)
|
||||
@opts = opts.freeze
|
||||
|
@ -326,7 +326,7 @@ end
|
|||
#
|
||||
def Tempfile.create(basename="", tmpdir=nil, mode: 0, **options)
|
||||
tmpfile = nil
|
||||
Dir::Tmpname.create(basename, tmpdir, options) do |tmpname, n, opts|
|
||||
Dir::Tmpname.create(basename, tmpdir, **options) do |tmpname, n, opts|
|
||||
mode |= File::RDWR|File::CREAT|File::EXCL
|
||||
opts[:perm] = 0600
|
||||
tmpfile = File.open(tmpname, mode, opts)
|
||||
|
|
|
@ -82,9 +82,9 @@ class Dir
|
|||
# FileUtils.remove_entry dir
|
||||
# end
|
||||
#
|
||||
def self.mktmpdir(prefix_suffix=nil, *rest)
|
||||
def self.mktmpdir(prefix_suffix=nil, *rest, **options)
|
||||
base = nil
|
||||
path = Tmpname.create(prefix_suffix || "d", *rest) {|path, _, _, d|
|
||||
path = Tmpname.create(prefix_suffix || "d", *rest, **options) {|path, _, _, d|
|
||||
base = d
|
||||
mkdir(path, 0700)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue