Class: Analyst::FileProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/analyst.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path_to_files) ⇒ FileProcessor

Returns a new instance of FileProcessor.



33
34
35
# File 'lib/analyst.rb', line 33

def initialize(path_to_files)
  @path_to_files = path_to_files
end

Instance Attribute Details

#path_to_filesObject (readonly)

Returns the value of attribute path_to_files.



31
32
33
# File 'lib/analyst.rb', line 31

def path_to_files
  @path_to_files
end

Instance Method Details

#astObject



45
46
47
48
49
50
51
52
# File 'lib/analyst.rb', line 45

def ast
  ::Parser::AST::Node.new(
    :root, source_files.map do |file|
      content = File.open(file, "r").read
      ::Parser::CurrentRuby.parse(content)
    end
  )
end

#source_filesObject



37
38
39
40
41
42
43
# File 'lib/analyst.rb', line 37

def source_files
  if File.directory?(path_to_files)
    return Dir.glob(File.join(path_to_files, "**", "*.rb"))
  else
    return [path_to_files]
  end
end