Class: CitizenCodeScripts::Doctor::Check
- Inherits:
-
Object
- Object
- CitizenCodeScripts::Doctor::Check
- Includes:
- Colorize
- Defined in:
- lib/citizen_code_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.
7 8 9 10 11 12 |
# File 'lib/citizen_code_scripts/doctor.rb', line 7 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.
5 6 7 |
# File 'lib/citizen_code_scripts/doctor.rb', line 5 def command @command end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/citizen_code_scripts/doctor.rb', line 5 def name @name end |
#problems ⇒ Object (readonly)
Returns the value of attribute problems.
5 6 7 |
# File 'lib/citizen_code_scripts/doctor.rb', line 5 def problems @problems end |
#remedy ⇒ Object (readonly)
Returns the value of attribute remedy.
5 6 7 |
# File 'lib/citizen_code_scripts/doctor.rb', line 5 def remedy @remedy end |
Instance Method Details
#run! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 |