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.
113 114 115 116 117 118 119 |
# File 'lib/aid/scripts/doctor.rb', line 113 def initialize(name:, command:, remedy:) @name = name @command = command @remedy = remedy.is_a?(Remedy) ? remedy : Remedy.new(remedy) @problems = [] @checked_once = false end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
111 112 113 |
# File 'lib/aid/scripts/doctor.rb', line 111 def command @command end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
111 112 113 |
# File 'lib/aid/scripts/doctor.rb', line 111 def name @name end |
#problems ⇒ Object (readonly)
Returns the value of attribute problems.
111 112 113 |
# File 'lib/aid/scripts/doctor.rb', line 111 def problems @problems end |
#remedy ⇒ Object (readonly)
Returns the value of attribute remedy.
111 112 113 |
# File 'lib/aid/scripts/doctor.rb', line 111 def remedy @remedy end |
Instance Method Details
#run! ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/aid/scripts/doctor.rb', line 121 def run! print "Checking: #{name}... " success = run_command if success puts 'OK' else puts colorize(:error, 'F') if @checked_once || !remedy.auto_fixable? puts "\n To fix: #{remedy}\n\n" problems << name elsif remedy.auto_fixable? @checked_once = true puts '==> attempting autofix' remedy.auto_fix! puts '==> retrying check' run! end end end |