Class: ImportGraph::Parser::Autoload
- Inherits:
-
Object
- Object
- ImportGraph::Parser::Autoload
- Includes:
- Util, RuboCop::AST
- Defined in:
- lib/import_graph/parser/autoload.rb
Constant Summary collapse
- AUTOLOAD_PATTERN =
NodePattern.new <<~PATTERN (send nil? :autoload (sym ...) (str $_)) PATTERN
Instance Method Summary collapse
-
#initialize(file_trees) ⇒ Autoload
constructor
A new instance of Autoload.
- #parse ⇒ Object
- #parse_file(file_path) ⇒ Object
Methods included from Util
#build_match_object, #cleanup_absolute_path
Constructor Details
#initialize(file_trees) ⇒ Autoload
Returns a new instance of Autoload.
13 14 15 |
# File 'lib/import_graph/parser/autoload.rb', line 13 def initialize(file_trees) @file_trees = file_trees end |
Instance Method Details
#parse ⇒ Object
17 18 19 20 21 |
# File 'lib/import_graph/parser/autoload.rb', line 17 def parse matches = Set.new @file_trees.keys.each { |file_path| matches.merge(parse_file(file_path)) } matches end |
#parse_file(file_path) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/import_graph/parser/autoload.rb', line 23 def parse_file(file_path) matches = Set.new @file_trees[file_path].each_node do |node| match = AUTOLOAD_PATTERN.match node next if match.nil? matches.add(build_match_object(:autoload, file_path, match)) unless match.nil? end matches end |