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
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
43 44 45 |
# File 'lib/reviewer/setup/detector.rb', line 43 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.
37 38 39 |
# File 'lib/reviewer/setup/detector.rb', line 37 def project_dir @project_dir end |
Instance Method Details
#detect ⇒ Array<Result>
Scans the project and returns detection results for matching tools
50 51 52 53 54 55 56 57 |
# File 'lib/reviewer/setup/detector.rb', line 50 def detect gems = GemfileLock.new(project_dir.join('Gemfile.lock')).gem_names Catalog.all.filter_map do |key, definition| sources = sources_for(definition[:detect], gems) Result.new(key: key, sources: sources) if sources.any? end end |