class Depdump::Parser

Attributes

tracer[R]

Public Class Methods

new() click to toggle source
# File lib/depdump/parser.rb, line 5
def initialize
  @tracer = Tracer.new
end

Public Instance Methods

dependency_graph() click to toggle source
# File lib/depdump/parser.rb, line 17
def dependency_graph
  DependencyGraph.new(tracer.registry_tree)
end
parse(files) click to toggle source
# File lib/depdump/parser.rb, line 9
def parse(files)
  expand_directory(files).each do |file|
    source = File.read(file)
    ast = ::Parser::CurrentRuby.parse(source)
    tracer.trace_node(ast)
  end
end

Private Instance Methods

expand_directory(paths) click to toggle source
# File lib/depdump/parser.rb, line 23
def expand_directory(paths)
  paths.flat_map do |path|
    if File.directory?(path)
      Dir.glob(File.join(path, "**", "*.rb"))
    else
      path
    end
  end
end