Class: Reviewer::Setup::Detector
- Inherits:
-
Object
- Object
- Reviewer::Setup::Detector
- Defined in:
- lib/reviewer/setup/detector.rb
Overview
Scans a project directory to detect which review tools are applicable based on Gemfile.lock contents, config files, and directory structure.
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#project_dir ⇒ Object
readonly
Returns the value of attribute project_dir.
Instance Method Summary collapse
-
#detect ⇒ Array<Result>
Scans the project and returns detection results for matching tools.
-
#initialize(project_dir = Pathname.pwd) ⇒ Detector
constructor
Creates a detector for scanning a project directory for supported tools.
Constructor Details
#initialize(project_dir = Pathname.pwd) ⇒ Detector
Creates a detector for scanning a project directory for supported tools
26 27 28 |
# File 'lib/reviewer/setup/detector.rb', line 26 def initialize(project_dir = Pathname.pwd) @project_dir = Pathname(project_dir) end |
Instance Attribute Details
#project_dir ⇒ Object (readonly)
Returns the value of attribute project_dir.
20 21 22 |
# File 'lib/reviewer/setup/detector.rb', line 20 def project_dir @project_dir end |
Instance Method Details
#detect ⇒ Array<Result>
Scans the project and returns detection results for matching tools
33 34 35 36 37 38 39 40 |
# File 'lib/reviewer/setup/detector.rb', line 33 def detect gems = GemfileLock.new(project_dir.join('Gemfile.lock')).gem_names Catalog.all.filter_map do |key, definition| reasons = reasons_for(definition[:detect], gems) Result.new(key: key, reasons: reasons) if reasons.any? end end |