Class: Reviewer::Setup::Formatter

Inherits:
Object
  • Object
show all
Includes:
Output::Formatting
Defined in:
lib/reviewer/setup/formatter.rb

Overview

Display logic for the first-run setup flow

Constant Summary

Constants included from Output::Formatting

Output::Formatting::CHECKMARK, Output::Formatting::XMARK

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Formatter

Creates a formatter for setup flow display

Parameters:

  • output (Output)

    the console output handler



18
19
20
21
# File 'lib/reviewer/setup/formatter.rb', line 18

def initialize(output)
  @output = output
  @printer = output.printer
end

Instance Method Details

#first_run_greetingvoid

This method returns an undefined value.

Displays the welcome message when Reviewer has no configuration file



26
27
28
29
30
31
32
# File 'lib/reviewer/setup/formatter.rb', line 26

def first_run_greeting
  output.newline
  printer.puts(:bold, "It looks like you're setting up Reviewer for the first time on this project.")
  output.newline
  printer.puts(:muted, 'This will auto-detect your tools and generate a .reviewer.yml configuration file.')
  output.newline
end

#first_run_skipvoid

This method returns an undefined value.

Displays a hint about ‘rvw init` when the user declines initial setup



37
38
39
40
# File 'lib/reviewer/setup/formatter.rb', line 37

def first_run_skip
  printer.puts(:muted, 'You can run `rvw init` any time to auto-detect and configure your tools.')
  output.newline
end

#setup_already_exists(config_file) ⇒ void

This method returns an undefined value.

Displays a notice when ‘rvw init` is run but .reviewer.yml already exists

Parameters:

  • config_file (Pathname)

    the existing configuration file path



46
47
48
49
50
51
52
53
# File 'lib/reviewer/setup/formatter.rb', line 46

def setup_already_exists(config_file)
  output.newline
  printer.puts(:bold, "Configuration already exists: #{config_file.basename}")
  output.newline
  printer.puts(:muted, 'Run `rvw doctor` for a diagnostic report.')
  printer.puts(:muted, 'To regenerate, remove the file and run `rvw init` again.')
  output.newline
end

#setup_no_tools_detectedvoid

This method returns an undefined value.

Displays a message when auto-detection finds no supported tools in the project



58
59
60
61
62
63
64
65
# File 'lib/reviewer/setup/formatter.rb', line 58

def setup_no_tools_detected
  output.newline
  printer.puts(:bold, 'No supported tools detected.')
  output.newline
  printer.puts(:muted, 'Create .reviewer.yml manually:')
  printer.puts(:muted, "  #{Setup::CONFIG_URL}")
  output.newline
end

#setup_success(results) ⇒ void

This method returns an undefined value.

Displays the results of a successful setup with the detected tools

Parameters:

  • results (Array<Detector::Result>)

    the tools that were detected and configured



71
72
73
74
75
76
# File 'lib/reviewer/setup/formatter.rb', line 71

def setup_success(results)
  output.newline
  printer.puts(:success, 'Created .reviewer.yml')
  print_detected_tools(results)
  print_setup_footer
end