module VisualCallGraph
Public Instance Methods
node_count(graph)
click to toggle source
# File lib/visual_call_graph.rb, line 32 def node_count(graph) "#{graph.node_count} #{(graph.node_count > 1 ? 'nodes' : 'node')}" end
trace(options = {}) { || ... }
click to toggle source
# 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