Class: Reviewer::Doctor::ConfigCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/doctor/config_check.rb

Overview

Validates the configuration file by delegating to Configuration::Loader

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(report, configuration:) ⇒ ConfigCheck

Creates a config check that validates the .reviewer.yml file

Parameters:



14
15
16
17
# File 'lib/reviewer/doctor/config_check.rb', line 14

def initialize(report, configuration:)
  @report = report
  @configuration = configuration
end

Instance Attribute Details

#reportObject (readonly)

Returns the value of attribute report.



7
8
9
# File 'lib/reviewer/doctor/config_check.rb', line 7

def report
  @report
end

Instance Method Details

#checkObject

Checks for .reviewer.yml existence and validity



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/reviewer/doctor/config_check.rb', line 20

def check
  config_file = @configuration.file

  unless config_file.exist?
    report.add(:configuration, status: :error,
                               message: 'No .reviewer.yml found', detail: 'Run `rvw init` to generate one')
    return
  end

  report.add(:configuration, status: :ok, message: '.reviewer.yml found')
  validate_via_loader
end