Method: Analyst::Parser.for_files

Defined in:
lib/analyst/parser.rb

.for_files(*path_to_files) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/analyst/parser.rb', line 10

def self.for_files(*path_to_files)
  file_paths = path_to_files.flatten.map do |path|
    if File.directory?(path)
      Dir.glob(File.join(path, "**", "*.rb"))
    else
      path
    end
  end.flatten

  asts = file_paths.map do |path|
    File.open(path) do |file|
      parse_source(file.read, path)
    end
  end.compact

  new(asts)
end