class CitizenCodeScripts::Doctor::Check

Attributes

command[R]
name[R]
problems[R]
remedy[R]

Public Class Methods

new(name:, command:, remedy:) click to toggle source
# File lib/citizen_code_scripts/doctor.rb, line 7
def initialize(name:, command:, remedy:)
  @name = name
  @command = command
  @remedy = remedy
  @problems = []
end

Public Instance Methods

run!() click to toggle source
# File lib/citizen_code_scripts/doctor.rb, line 14
def run!
  print "Checking: #{name}... "

  success = if command.respond_to?(:call)
    command.call
  else
    system "#{command} > /dev/null 2>&1"
  end

  if success
    puts 'OK'
  else
    print colorize(:error, 'F')
    fix = remedy.respond_to?(:join) ? remedy.join(" ") : remedy
    puts "\n  To fix: #{fix}\n\n"

    problems << name
  end
end