Class: RubyDetective::AST::FileParser
- Inherits:
-
Object
- Object
- RubyDetective::AST::FileParser
- Defined in:
- lib/ruby_detective/ast/file_parser.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#project_path ⇒ Object
readonly
Returns the value of attribute project_path.
-
#rich_ast ⇒ Object
readonly
Returns the value of attribute rich_ast.
Instance Method Summary collapse
-
#initialize(file_path, project_path) ⇒ FileParser
constructor
A new instance of FileParser.
- #parse ⇒ Object
Constructor Details
#initialize(file_path, project_path) ⇒ FileParser
Returns a new instance of FileParser.
6 7 8 9 |
# File 'lib/ruby_detective/ast/file_parser.rb', line 6 def initialize(file_path, project_path) @path = file_path @project_path = project_path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/ruby_detective/ast/file_parser.rb', line 4 def path @path end |
#project_path ⇒ Object (readonly)
Returns the value of attribute project_path.
4 5 6 |
# File 'lib/ruby_detective/ast/file_parser.rb', line 4 def project_path @project_path end |
#rich_ast ⇒ Object (readonly)
Returns the value of attribute rich_ast.
4 5 6 |
# File 'lib/ruby_detective/ast/file_parser.rb', line 4 def rich_ast @rich_ast end |
Instance Method Details
#parse ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# 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 |