7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/visual_call_graph.rb', line 7
def trace(options = {})
unless block_given?
puts "Block required"
return
end
graph = GraphManager.new(options)
trace =
TracePoint.new(:call, :return) do |event|
case event.event
when :return then graph.pop
when :call then graph.add_edges(event)
end
end
trace.enable
yield
trace.disable
graph.output(png: "#{Dir.pwd}/call_graph.png")
puts "Call graph created with a total of #{node_count(graph)}."
end
|