Merge pull request #13557 from Homebrew/dependabot/bundler/Library/Homebrew/warning-1.3.0

build(deps): bump warning from 1.2.1 to 1.3.0 in /Library/Homebrew
This commit is contained in:
Rylan Polster 2022-07-15 09:18:51 +02:00 committed by GitHub
commit 1fa7420c4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 9 deletions

View File

@ -191,7 +191,7 @@ GEM
diff-lcs (~> 1.3)
parser (>= 3.1.0)
uri_template (0.7.0)
warning (1.2.1)
warning (1.3.0)
webrick (1.7.0)
webrobots (0.1.2)
yard (0.9.28)

View File

@ -105,4 +105,4 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/spoom-1.1.11/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/yard-0.9.28/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/yard-sorbet-0.6.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/tapioca-0.7.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/warning-1.2.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/warning-1.3.0/lib"

View File

@ -24,19 +24,52 @@ module Warning
# Map of action symbols to procs that return the symbol
ACTION_PROC_MAP = {
raise: proc{|_| :raise},
default: proc{|_| :default},
backtrace: proc{|_| :backtrace},
raise: proc{|_| :raise},
}
private_constant :ACTION_PROC_MAP
# Clear all current ignored warnings, warning processors, and duplicate check cache.
# Also disables deduplicating warnings if that is currently enabled.
#
# If a block is passed, the previous values are restored after the block exits.
#
# Examples:
#
# # Clear warning state
# Warning.clear
#
# Warning.clear do
# # Clear warning state inside the block
# ...
# end
# # Previous warning state restored when block exists
def clear
synchronize do
@ignore.clear
@process.clear
@dedup = false
if block_given?
ignore = process = dedup = nil
synchronize do
ignore = @ignore.dup
process = @process.dup
dedup = @dedup.dup
end
begin
clear
yield
ensure
synchronize do
@ignore = ignore
@process = process
@dedup = dedup
end
end
else
synchronize do
@ignore.clear
@process.clear
@dedup = false
end
end
end
@ -144,6 +177,10 @@ module Warning
#
# Warning.process(__FILE__, :missing_ivar=>:backtrace, :keyword_separation=>:raise)
def process(path='', actions=nil, &block)
unless path.is_a?(String)
raise ArgumentError, "path must be a String (given an instance of #{path.class})"
end
if block
if actions
raise ArgumentError, "cannot pass both actions and block to Warning.process"
@ -173,14 +210,16 @@ module Warning
if RUBY_VERSION >= '3.0'
method_args = ', category: nil'
super_ = "category ? super : super(str)"
# :nocov:
else
super_ = "super"
# :nocov:
end
class_eval(<<-END, __FILE__, __LINE__+1)
def warn(str#{method_args})
synchronize{@ignore.dup}.each do |path, regexp|
if str.start_with?(path) && str =~ regexp
if str.start_with?(path) && regexp.match?(str)
return
end
end
@ -198,7 +237,7 @@ module Warning
if str.start_with?(path)
if block.is_a?(Hash)
block.each do |regexp, blk|
if str =~ regexp
if regexp.match?(str)
throw :action, blk.call(str)
end
end