Class: Mutineer::Project

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

Overview

Subject discovery: parse each path and walk its AST for method definitions, tracking the enclosing class/module namespace.

Defined Under Namespace

Classes: SubjectVisitor

Class Method Summary collapse

Class Method Details

.discover(paths, only: nil) ⇒ Array<Mutineer::Subject>

Discovers subjects from source paths.

Parameters:

  • paths (Array<String>)

    source file paths.

  • only (String, nil) (defaults to: nil)

    optional qualified-name filter.

Returns:



17
18
19
20
21
22
23
24
25
26
# File 'lib/mutineer/project.rb', line 17

def self.discover(paths, only: nil)
  subjects = Array(paths).flat_map do |path|
    result = Parser.parse_file(path)
    visitor = SubjectVisitor.new(path)
    visitor.visit(result.value)
    visitor.promote_module_functions!
    visitor.subjects
  end
  only ? subjects.select { |s| s.qualified_name == only } : subjects
end