Fix inreplace signature.

This commit is contained in:
Markus Reiter 2020-09-19 01:53:59 +02:00
parent e3646c9b4e
commit cc3eceb04f
2 changed files with 3 additions and 3 deletions

View File

@ -3,9 +3,8 @@
module Utils::Inreplace
include Kernel
sig { params(paths: T::Array[T.untyped], before: T.nilable(String), after: T.nilable(String), audit_result: T::Boolean).void }
sig { params(paths: T::Array[T.untyped], before: T.nilable(String), after: T.nilable(T.any(String, Symbol)), audit_result: T::Boolean).void }
def inreplace(paths, before = nil, after = nil, audit_result = true); end
end
class StringInreplaceExtension

View File

@ -28,6 +28,8 @@ module Utils
#
# @api public
def inreplace(paths, before = nil, after = nil, audit_result = true) # rubocop:disable Style/OptionalBooleanParameter
after = after.to_s if after.is_a? Symbol
errors = {}
errors["`paths` (first) parameter"] = ["`paths` was empty"] if paths.blank?
@ -39,7 +41,6 @@ module Utils
if before.nil? && after.nil?
yield s
else
after = after.to_s if after.is_a? Symbol
s.gsub!(before, after, audit_result)
end