Class: Aid::Scripts::Doctor
Defined Under Namespace
Classes: Check, CommandRemedy, Remedy
Constant Summary
Constants included
from Colorize
Colorize::COLOR_CODES
Instance Attribute Summary
Attributes inherited from Aid::Script
#argv
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Aid::Script
#description, #exit_with_help!, #help, name, #project_root, run, #step, #system!, #within_dir
included
Methods included from Colorize
colorize, included
Constructor Details
#initialize(*args) ⇒ Doctor
Returns a new instance of Doctor.
14
15
16
17
|
# File 'lib/aid/scripts/doctor.rb', line 14
def initialize(*args)
super
@checks = []
end
|
Class Method Details
.description ⇒ Object
6
7
8
|
# File 'lib/aid/scripts/doctor.rb', line 6
def self.description
'Checks the health of your development environment'
end
|
.help ⇒ Object
10
11
12
|
# File 'lib/aid/scripts/doctor.rb', line 10
def self.help
'doctor - helps you diagnose any setup issues with this application'
end
|
Instance Method Details
#check(**options) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/aid/scripts/doctor.rb', line 19
def check(**options)
check = Check.new(options)
@checks << check
check.run!
end
|
#command(cmd) ⇒ Object
59
60
61
|
# File 'lib/aid/scripts/doctor.rb', line 59
def command(cmd)
CommandRemedy.new(cmd)
end
|
#exit_code ⇒ Object
55
56
57
|
# File 'lib/aid/scripts/doctor.rb', line 55
def exit_code
problems.size
end
|
#problems ⇒ Object
51
52
53
|
# File 'lib/aid/scripts/doctor.rb', line 51
def problems
@checks.map(&:problems).flatten
end
|
#run ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# 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
|