class VisualizeRuby::ExecutionTracer
Constants
- TRACE_POINT_OPTIONS
Attributes
calling_code[R]
executed_events[R]
ruby_code[R]
temp_files[R]
trace_point_options[R]
Public Class Methods
new(builder = nil, ruby_code: builder.ruby_code, calling_code:, trace_point_options: TRACE_POINT_OPTIONS)
click to toggle source
@param [String, File, Pathname] ruby_code
@param [File, String, Pathname, Proc] calling_code
@param [Array<Symbol>] trace_point_options
# File lib/visualize_ruby/execution_tracer.rb, line 13 def initialize(builder = nil, ruby_code: builder.ruby_code, calling_code:, trace_point_options: TRACE_POINT_OPTIONS) @ruby_code = InputCoercer.new(ruby_code, name: :ruby_code).tap(&:to_file) @calling_code = InputCoercer.new(calling_code, name: :calling_code).tap(&:to_proc) @trace_point_options = trace_point_options @temp_files = [] @executed_events = [] end
Public Instance Methods
trace()
click to toggle source
# File lib/visualize_ruby/execution_tracer.rb, line 21 def trace ruby_code.load_file tracer.enable(&calling_code.to_proc) self ensure ruby_code.close! calling_code.close! end
Private Instance Methods
tracer()
click to toggle source
# File lib/visualize_ruby/execution_tracer.rb, line 37 def tracer @tracer ||= TracePoint.new(*trace_point_options) do |tp| if tp.path == ruby_code.to_file.path executed_events << { line: tp.lineno, event: tp.event} end end end