lib/anyway/tracing.rb in runger_config-2.7.0 vs lib/anyway/tracing.rb in runger_config-3.0.0
- old
+ new
@@ -5,11 +5,11 @@
module Tracing
using Anyway::Ext::DeepDup
using(Module.new do
refine Thread::Backtrace::Location do
- def path_lineno() = "#{path}:#{lineno}"
+ def path_lineno = "#{path}:#{lineno}"
end
end)
class Trace
UNDEF = Object.new
@@ -24,32 +24,32 @@
def dig(...)
value.dig(...)
end
- def record_value(val, *path, **opts)
+ def record_value(val, *path, **)
key = path.pop
trace = if val.is_a?(Hash)
- Trace.new.tap { _1.merge_values(val, **opts) }
+ Trace.new.tap { _1.merge_values(val, **) }
else
- Trace.new(:value, val, **opts)
+ Trace.new(:value, val, **)
end
target_trace = path.empty? ? self : value.dig(*path)
target_trace.record_key(key.to_s, trace)
val
end
- def merge_values(hash, **opts)
+ def merge_values(hash, **)
return hash unless hash
hash.each do |key, val|
if val.is_a?(Hash)
- value[key.to_s].merge_values(val, **opts)
+ value[key.to_s].merge_values(val, **)
else
- value[key.to_s] = Trace.new(:value, val, **opts)
+ value[key.to_s] = Trace.new(:value, val, **)
end
end
hash
end
@@ -76,23 +76,23 @@
def keep_if(...)
raise ArgumentError, "You can only filter :trace type, and this is :#{type}" unless trace?
value.keep_if(...)
end
- def clear() = value.clear
+ def clear = value.clear
- def trace?() = type == :trace
+ def trace? = type == :trace
def to_h
if trace?
value.transform_values(&:to_h).tap { _1.default_proc = nil }
else
{value:, source:}
end
end
- def dup() = self.class.new(type, value.dup, **source)
+ def dup = self.class.new(type, value.dup, **source)
def pretty_print(q)
if trace?
q.nest(2) do
q.breakable ""
@@ -144,11 +144,11 @@
def trace_stack
(Thread.current[:__anyway__trace_stack__] ||= [])
end
- def current_trace() = trace_stack.last
+ def current_trace = trace_stack.last
alias_method :tracing?, :current_trace
def source_stack
(Thread.current[:__anyway__trace_source_stack__] ||= [])
@@ -172,16 +172,16 @@
end
end
module_function
- def trace!(type, *path, **opts)
+ def trace!(type, *path, **)
return yield unless Tracing.tracing?
val = yield
if val.is_a?(Hash)
- Tracing.current_trace.merge_values(val, type:, **opts)
+ Tracing.current_trace.merge_values(val, type:, **)
elsif !path.empty?
- Tracing.current_trace.record_value(val, *path, type:, **opts)
+ Tracing.current_trace.record_value(val, *path, type:, **)
end
val
end
end
end