brew vendor-gems: commit updates.
This commit is contained in:
parent
ac5127db74
commit
6fd1469287
@ -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"
|
||||
|
||||
@ -24,21 +24,54 @@ 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
|
||||
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
|
||||
|
||||
# Deduplicate warnings, suppress warning messages if the same warning message
|
||||
# has already occurred. Note that this can lead to unbounded memory use
|
||||
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user