Module: Reviewer::Setup

Defined in:
lib/reviewer/setup.rb,
lib/reviewer/setup/catalog.rb,
lib/reviewer/setup/detector.rb,
lib/reviewer/setup/formatter.rb,
lib/reviewer/setup/generator.rb,
lib/reviewer/setup/tool_block.rb,
lib/reviewer/setup/gemfile_lock.rb

Overview

Handles first-run setup: detecting tools and generating .reviewer.yml

Defined Under Namespace

Modules: Catalog Classes: Detector, Formatter, GemfileLock, Generator, ToolBlock

Constant Summary collapse

CONFIG_URL =

URL to the configuration documentation for setup output messages

'https://github.com/garrettdimon/reviewer#configuration'

Class Method Summary collapse

Class Method Details

.run(configuration:, project_dir: Pathname.pwd, output: Output.new) ⇒ void

This method returns an undefined value.

Runs the full setup flow: detect tools, generate config, display results

Parameters:

  • project_dir (Pathname, String) (defaults to: Pathname.pwd)

    the project root to scan (defaults to pwd)

  • output (Output) (defaults to: Output.new)

    the console output handler



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/reviewer/setup.rb', line 20

def self.run(configuration:, project_dir: Pathname.pwd, output: Output.new)
  config_file = configuration.file
  formatter = Formatter.new(output)

  if config_file.exist?
    formatter.setup_already_exists(config_file)
    return
  end

  results = Detector.new(project_dir).detect

  if results.empty?
    formatter.setup_no_tools_detected
    return
  end

  yaml = Generator.new(results.map(&:key), project_dir: project_dir).generate
  config_file.write(yaml)
  formatter.setup_success(results)
end