class RubyDetective::AST::FileParser
Attributes
path[R]
project_path[R]
rich_ast[R]
Public Class Methods
new(file_path, project_path)
click to toggle source
# File lib/ruby_detective/ast/file_parser.rb, line 6 def initialize(file_path, project_path) @path = file_path @project_path = project_path end
Public Instance Methods
parse()
click to toggle source
# File lib/ruby_detective/ast/file_parser.rb, line 11 def parse code = File.read(path) raw_ast = Parser::CurrentRuby.parse(code) return false if raw_ast.nil? # Empty file scenario factory = AST::NodeFactory.new(raw_ast, file_path: clean_path) @rich_ast = factory.build factory.process_all_children AST::Interpreter.interpret_node_and_populate_store( rich_ast, clean_path ) end
Private Instance Methods
clean_path()
click to toggle source
# File lib/ruby_detective/ast/file_parser.rb, line 29 def clean_path path.sub(project_path, "") end