Skip to content

Commit

Permalink
Suppress warning about keyword argument introduced from ruby 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
ganmacs committed Oct 24, 2019
1 parent 077508a commit 446b8e0
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 21 deletions.
8 changes: 4 additions & 4 deletions lib/fluent/config/configure_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ def merge(other) # self is base class, other is subclass

merged = if self.root?
options[:root] = true
self.class.new(other.name, options)
self.class.new(other.name, **options)
else
self.class.new(@name, options)
self.class.new(@name, **options)
end

# configured_in MUST be kept
Expand Down Expand Up @@ -172,9 +172,9 @@ def merge_for_finalized(other)

merged = if self.root?
options[:root] = true
self.class.new(other.name, options)
self.class.new(other.name, **options)
else
self.class.new(@name, options)
self.class.new(@name, **options)
end

merged.configured_in_section = self.configured_in_section || other.configured_in_section
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/buffer/chunk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def open(**kwargs, &block)
if kwargs[:compressed] == :gzip
super
else
super(kwargs) do |chunk_io|
super(**kwargs) do |chunk_io|
output_io = if chunk_io.is_a?(StringIO)
StringIO.new
else
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/formatter_csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def configure(conf)
end

def format(tag, time, record)
csv = (@cache[Thread.current] ||= CSV.new("".force_encoding(Encoding::ASCII_8BIT), @generate_opts))
csv = (@cache[Thread.current] ||= CSV.new("".force_encoding(Encoding::ASCII_8BIT), **@generate_opts))
line = (csv << record).string.dup
# Need manual cleanup because CSV writer doesn't provide such method.
csv.rewind
Expand All @@ -65,7 +65,7 @@ def format(tag, time, record)
end

def format_with_nested_fields(tag, time, record)
csv = (@cache[Thread.current] ||= CSV.new("".force_encoding(Encoding::ASCII_8BIT), @generate_opts))
csv = (@cache[Thread.current] ||= CSV.new("".force_encoding(Encoding::ASCII_8BIT), **@generate_opts))
values = @accessors.map { |a| a.call(record) }
line = (csv << values).string.dup
# Need manual cleanup because CSV writer doesn't provide such method.
Expand Down
6 changes: 3 additions & 3 deletions lib/fluent/plugin_helper/child_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,19 @@ def child_process_execute_once(
end

if mode.include?(:write)
writeio.set_encoding(external_encoding, internal_encoding, encoding_options)
writeio.set_encoding(external_encoding, internal_encoding, **encoding_options)
writeio_in_use = true
else
writeio.reopen(IO::NULL) if writeio
end
if mode.include?(:read) || mode.include?(:read_with_stderr)
readio.set_encoding(external_encoding, internal_encoding, encoding_options)
readio.set_encoding(external_encoding, internal_encoding, **encoding_options)
readio_in_use = true
else
readio.reopen(IO::NULL) if readio
end
if mode.include?(:stderr)
stderrio.set_encoding(external_encoding, internal_encoding, encoding_options)
stderrio.set_encoding(external_encoding, internal_encoding, **encoding_options)
stderrio_in_use = true
else
stderrio.reopen(IO::NULL) if stderrio && stderr == :discard
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin_helper/extract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module ExtractParams
config_param :time_type, :enum, list: [:float, :unixtime, :string], default: :float

Fluent::TimeMixin::TIME_PARAMETERS.each do |name, type, opts|
config_param name, type, opts
config_param(name, type, **opts)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin_helper/inject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module InjectParams
config_param :time_type, :enum, list: [:float, :unixtime, :string], default: :float

Fluent::TimeMixin::TIME_PARAMETERS.each do |name, type, opts|
config_param name, type, opts
config_param(name, type, **opts)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin_helper/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,9 @@ def write(data)
end

if RUBY_VERSION.to_f >= 2.3
NONBLOCK_ARG = {exception: false}
NONBLOCK_ARG = { exception: false }
def try_handshake
@_handler_socket.accept_nonblock(NONBLOCK_ARG)
@_handler_socket.accept_nonblock(**NONBLOCK_ARG)
end
else
def try_handshake
Expand Down
17 changes: 15 additions & 2 deletions lib/fluent/test/driver/base_owned.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,26 @@ def initialize(klass, opts: {}, &block)
@section_name = ''
end

def configure(conf, syntax: :v1)
def configure(conf)
if conf.is_a?(Fluent::Config::Element)
@config = conf
elsif conf.is_a?(Hash)
@config = Fluent::Config::Element.new(@section_name, "", Hash[conf.map{|k,v| [k.to_s, v]}], [])
else
@config = Fluent::Config.parse(conf, @section_name, "", syntax: syntax)
@config = Fluent::Config.parse(conf, @section_name, "", syntax: :v1)
end
@instance.configure(@config)
self
end

# this is special method for v0 and should be deleted
def configure_v0(conf)
if conf.is_a?(Fluent::Config::Element)
@config = conf
elsif conf.is_a?(Hash)
@config = Fluent::Config::Element.new(@section_name, "", Hash[conf.map{|k,v| [k.to_s, v]}], [])
else
@config = Fluent::Config.parse(conf, @section_name, "", syntax: :v0)
end
@instance.configure(@config)
self
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ module TimeMixin
module TimeParameters
include Fluent::Configurable
TIME_FULL_PARAMETERS.each do |name, type, opts|
config_param name, type, opts
config_param(name, type, **opts)
end

def configure(conf)
Expand Down
12 changes: 8 additions & 4 deletions test/counter/test_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ def travel(sec)
test 'raise an error when @scope is nil' do
@client.instance_variable_set(:@scope, nil)
assert_raise 'Call `establish` method to get a `scope` before calling this method' do
@client.init(name: 'key1', reset_interval: 10).get
params = { name: 'key1', reset_interval: 10 }
@client.init(params).get
end
end

Expand All @@ -151,7 +152,8 @@ def travel(sec)
]
)
test 'return an error object' do |(param, expected_error)|
@client.init(:name => 'key1', :reset_interval => 10).get
params = { name: 'key1', reset_interval: 10 }
@client.init(params).get
response = @client.init(param).get
errors = response.errors.first

Expand All @@ -164,7 +166,8 @@ def travel(sec)
end

test 'return an existing value when passed key already exists and ignore option is true' do
res1 = @client.init(name: 'key1', reset_interval: 10).get
params = { name: 'key1', reset_interval: 10 }
res1 = @client.init(params).get
res2 = nil
assert_nothing_raised do
res2 = @client.init({ name: 'key1', reset_interval: 10 }, options: { ignore: true }).get
Expand Down Expand Up @@ -312,7 +315,8 @@ def travel(sec)
test 'raise an error when @scope is nil' do
@client.instance_variable_set(:@scope, nil)
assert_raise 'Call `establish` method to get a `scope` before calling this method' do
@client.inc(name: 'name', value: 1).get
params = { name: 'name', value: 1 }
@client.inc(params).get
end
end

Expand Down

0 comments on commit 446b8e0

Please sign in to comment.