Module: ArchSpec::Analyzer

Extended by:
Analyzer
Included in:
Analyzer
Defined in:
lib/archspec/analyzer.rb

Defined Under Namespace

Modules: SourceVisitor, SuppressionParser

Instance Method Summary collapse

Instance Method Details

#analyze(definition, root:) ⇒ Object



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

def analyze(definition, root:)
  root = File.expand_path(root)
  graph = Graph.new(root)

  ruby_files(definition, root).each do |path|
    result = Prism.parse_file(path)
    graph.add_file(
      path: path,
      expected_constant: expected_constant_for(path, root),
      parse_errors: parse_errors_for(path, result.errors),
      suppressions: suppressions_for(result.comments)
    )

    SourceVisitor.visit(graph, path, result.value) if result.value
  end

  graph.assign_components(definition.component_specs.values)
  graph
end