summaryrefslogtreecommitdiff
path: root/lib
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
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')
-rw-r--r--lib/csv.rb36
-rw-r--r--lib/csv/core_ext/array.rb2
-rw-r--r--lib/csv/core_ext/string.rb2
-rw-r--r--lib/csv/row.rb2
-rw-r--r--lib/csv/table.rb4
-rw-r--r--lib/net/ftp.rb2
-rw-r--r--lib/net/protocol.rb2
-rw-r--r--lib/rdoc/generator/darkfish.rb12
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/commands/setup_command.rb2
-rw-r--r--lib/rubygems/package.rb2
-rw-r--r--lib/tempfile.rb4
-rw-r--r--lib/tmpdir.rb4
13 files changed, 38 insertions, 38 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
#
diff --git a/lib/csv/core_ext/array.rb b/lib/csv/core_ext/array.rb
index 94df7d5c35..8beb06b082 100644
--- a/lib/csv/core_ext/array.rb
+++ b/lib/csv/core_ext/array.rb
@@ -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
diff --git a/lib/csv/core_ext/string.rb b/lib/csv/core_ext/string.rb
index 8f2070f3bd..9b1d31c2a4 100644
--- a/lib/csv/core_ext/string.rb
+++ b/lib/csv/core_ext/string.rb
@@ -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
diff --git a/lib/csv/row.rb b/lib/csv/row.rb
index c79d75cd8a..1e1f27587b 100644
--- a/lib/csv/row.rb
+++ b/lib/csv/row.rb
@@ -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
diff --git a/lib/csv/table.rb b/lib/csv/table.rb
index 71eb885de5..29b188a6d7 100644
--- a/lib/csv/table.rb
+++ b/lib/csv/table.rb
@@ -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("")
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb
index e68d825dcf..757daa9224 100644
--- a/lib/net/ftp.rb
+++ b/lib/net/ftp.rb
@@ -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
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index 60e23f1aa5..07fbc6a21f 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -322,7 +322,7 @@ module Net # :nodoc:
class InternetMessageIO < BufferedIO #:nodoc: internal use only
- def initialize(*)
+ def initialize(*, **)
super
@wbuf = nil
end
diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb
index a07f74e716..c5d47ef355 100644
--- a/lib/rdoc/generator/darkfish.rb
+++ b/lib/rdoc/generator/darkfish.rb
@@ -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
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 1e79e408fb..4d06d98fdf 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -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
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 1cbc980eb0..3448fdfb4e 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -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
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 06b1dc0db3..b5f83205b3 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -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
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 4678a191a7..66d206a938 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -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)
diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
index 05e74eb523..d7a8f799fe 100644
--- a/lib/tmpdir.rb
+++ b/lib/tmpdir.rb
@@ -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)
}