Method: #call_graph
- Defined in:
- lib/code_explorer/call_graph.rb
#call_graph(filename_rb) ⇒ Object
filename_rb [String] file with a ruby program
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/code_explorer/call_graph.rb', line 9 def call_graph(filename_rb) ruby = File.read(filename_rb) ast = Parser::CurrentRuby.parse(ruby, filename_rb) defs = defs_from_ast(ast) def_names = defs.map {|d| def_name(d) } defs_to_hrefs = defs.map {|d| [def_name(d), "/files/" + def_location(d)] }.to_h defs_to_calls = {} defs.each do |d| calls = calls_from_def(d) call_names = calls.map {|c| send_name(c)} call_names = call_names.find_all{ |cn| def_names.include?(cn) } defs_to_calls[def_name(d)] = call_names end dot_from_hash(defs_to_calls, defs_to_hrefs) end |