lib/trace_location/collector.rb in trace_location-0.11.0 vs lib/trace_location/collector.rb in trace_location-0.12.0
- old
+ new
@@ -6,19 +6,21 @@
module Collector # :nodoc:
require_relative 'event'
Result = Struct.new(:events, :return_value)
class << self
- def collect(match:, ignore:, &block)
+ def collect(match:, ignore:, methods:, &block)
+ methods = Array(methods) if methods
events = []
hierarchy = 0
id = 0
cache = {}
method_source_cache = {}
tracer = TracePoint.new(:call, :return) do |trace_point|
next if match && !trace_point.path.to_s.match?(/#{Array(match).join('|')}/)
next if ignore && trace_point.path.to_s.match?(/#{Array(ignore).join('|')}/)
+ next if methods && !methods.include?(trace_point.method_id)
id += 1
caller_loc = caller_locations(2, 1)[0]
caller_path = caller_loc.absolute_path
caller_lineno = caller_loc.lineno