Class: Zwischen::Scanner::Orchestrator
- Inherits:
-
Object
- Object
- Zwischen::Scanner::Orchestrator
- Defined in:
- lib/zwischen/scanner/orchestrator.rb
Instance Method Summary collapse
- #available_scanners ⇒ Object
-
#initialize(config:) ⇒ Orchestrator
constructor
A new instance of Orchestrator.
- #missing_scanners ⇒ Object
- #scan(project_root = Dir.pwd, only: nil, pre_push: false, files: nil) ⇒ Object
Constructor Details
#initialize(config:) ⇒ Orchestrator
Returns a new instance of Orchestrator.
10 11 12 13 |
# File 'lib/zwischen/scanner/orchestrator.rb', line 10 def initialize(config:) @config = config @scanners = build_scanners end |
Instance Method Details
#available_scanners ⇒ Object
42 43 44 |
# File 'lib/zwischen/scanner/orchestrator.rb', line 42 def available_scanners @scanners.select(&:available?) end |
#missing_scanners ⇒ Object
46 47 48 |
# File 'lib/zwischen/scanner/orchestrator.rb', line 46 def missing_scanners @scanners.reject(&:available?) end |
#scan(project_root = Dir.pwd, only: nil, pre_push: false, files: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/zwischen/scanner/orchestrator.rb', line 15 def scan(project_root = Dir.pwd, only: nil, pre_push: false, files: nil) enabled_scanners = select_scanners(only) available_scanners = enabled_scanners.select(&:available?) if available_scanners.empty? warn "No scanners available. Run 'zwischen doctor' to check installation." unless pre_push return [] end # Run scanners in parallel using threads threads = available_scanners.map do |scanner| Thread.new do [scanner.name, scanner.scan(project_root, files: files)] end end results = {} threads.each do |thread| scanner_name, findings = thread.value results[scanner_name] = findings end # Flatten all findings # Note: In pre-push mode, we pass file lists to scanners when available reject_ignored(results.values.flatten, project_root) end |