Class: Aid::Scripts::Doctor::Check
- Inherits:
-
Object
- Object
- Aid::Scripts::Doctor::Check
- Includes:
- Colorize
- Defined in:
- lib/aid/scripts/doctor.rb
Constant Summary
Constants included from Colorize
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#problems ⇒ Object
readonly
Returns the value of attribute problems.
-
#remedy ⇒ Object
readonly
Returns the value of attribute remedy.
Instance Method Summary collapse
-
#initialize(name:, command:, remedy:) ⇒ Check
constructor
A new instance of Check.
- #run! ⇒ Object
Methods included from Colorize
Constructor Details
#initialize(name:, command:, remedy:) ⇒ Check
Returns a new instance of Check.
9 10 11 12 13 14 |
# File 'lib/aid/scripts/doctor.rb', line 9 def initialize(name:, command:, remedy:) @name = name @command = command @remedy = remedy @problems = [] end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
7 8 9 |
# File 'lib/aid/scripts/doctor.rb', line 7 def command @command end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/aid/scripts/doctor.rb', line 7 def name @name end |
#problems ⇒ Object (readonly)
Returns the value of attribute problems.
7 8 9 |
# File 'lib/aid/scripts/doctor.rb', line 7 def problems @problems end |
#remedy ⇒ Object (readonly)
Returns the value of attribute remedy.
7 8 9 |
# File 'lib/aid/scripts/doctor.rb', line 7 def remedy @remedy end |
Instance Method Details
#run! ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/aid/scripts/doctor.rb', line 16 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: #{colorize(:command, fix)}\n\n" problems << name end end |