Class: CallTracer
- Inherits:
-
Tracer::Base
- Object
- Tracer::Base
- CallTracer
- Defined in:
- lib/tracer/call_tracer.rb
Constant Summary
Constants inherited from Tracer::Base
Tracer::Base::DIR, Tracer::Base::HOME, Tracer::Base::M_CLASS, Tracer::Base::M_INSPECT, Tracer::Base::M_INSTANCE_VARIABLE_GET, Tracer::Base::M_IS_A, Tracer::Base::M_OBJECT_ID
Constants included from Tracer::Color
Tracer::Color::BLUE, Tracer::Color::BOLD, Tracer::Color::CLEAR, Tracer::Color::CYAN, Tracer::Color::GREEN, Tracer::Color::MAGENTA, Tracer::Color::RED, Tracer::Color::REVERSE, Tracer::Color::UNDERLINE, Tracer::Color::YELLOW
Instance Attribute Summary
Attributes inherited from Tracer::Base
Instance Method Summary collapse
Methods inherited from Tracer::Base
#colorizable?, #description, #initialize, #key, #minfo, #out, #pretty_path, #puts, #safe_inspect, #skip?, #skip_internal?, #start, #started?, #stop, #stopped?, #to_s
Methods included from Tracer::Color
clear, colorize, #colorize, #colorize_blue, #colorize_cyan, #colorize_magenta
Constructor Details
This class inherits a constructor from Tracer::Base
Instance Method Details
#setup_tp ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tracer/call_tracer.rb', line 6 def setup_tp TracePoint.new(:a_call, :a_return) do |tp| next if skip?(tp) location = caller_locations(2, 1).first.to_s next if location.match?(DIR) || location.match?(/<internal:/) depth = caller.size call_identifier_str = (tp.defined_class ? minfo(tp) : "block") call_identifier_str = colorize_blue(call_identifier_str) case tp.event when :call, :c_call, :b_call depth += 1 if tp.event == :c_call sp = " " * depth out tp, ">#{sp}#{call_identifier_str}", depth: depth - 2 - @depth_offset, location: location when :return, :c_return, :b_return depth += 1 if tp.event == :c_return sp = " " * depth return_str = colorize_magenta(safe_inspect(tp.return_value)) out tp, "<#{sp}#{call_identifier_str} #=> #{return_str}", depth: depth - 2 - @depth_offset, location: location end end end |
#skip_with_pattern?(tp) ⇒ Boolean
38 39 40 |
# File 'lib/tracer/call_tracer.rb', line 38 def skip_with_pattern?(tp) super && !tp.method_id&.match?(@pattern) end |