class Aid::Scripts::Doctor

Public Class Methods

description() click to toggle source
# File lib/aid/scripts/doctor.rb, line 6
def self.description
  'Checks the health of your development environment'
end
help() click to toggle source
# File lib/aid/scripts/doctor.rb, line 10
def self.help
  'doctor - helps you diagnose any setup issues with this application'
end
new(*args) click to toggle source
Calls superclass method Aid::Script::new
# File lib/aid/scripts/doctor.rb, line 14
def initialize(*args)
  super
  @checks = []
end

Public Instance Methods

check(**options) click to toggle source
# File lib/aid/scripts/doctor.rb, line 19
def check(**options)
  check = Check.new(options)
  @checks << check

  check.run!
end
command(cmd) click to toggle source
# File lib/aid/scripts/doctor.rb, line 59
def command(cmd)
  CommandRemedy.new(cmd)
end
exit_code() click to toggle source
# File lib/aid/scripts/doctor.rb, line 55
def exit_code
  problems.size
end
problems() click to toggle source
# File lib/aid/scripts/doctor.rb, line 51
def problems
  @checks.map(&:problems).flatten
end
run() click to toggle source
# File lib/aid/scripts/doctor.rb, line 26
      def run
        puts <<~HELP
          To implement this script for your repository, create the following
          file in #{colorize(:green, "#{aid_directory}/doctor.rb")}:

          class Doctor < Aid::Scripts::Doctor
            def run
              check_phantomjs_installed
            end

            private

            def check_phantomjs_installed
              check name: "PhantomJS installed",
                command: "which phantomjs",
                remedy: command("brew install phantomjs")
            end
          end

          You can add as many checks to your script as you want.
        HELP

        exit
      end