Class: SystemCheck::SimpleExecutor
- Inherits:
-
Object
- Object
- SystemCheck::SimpleExecutor
- Defined in:
- lib/system_check/simple_executor.rb
Overview
Simple Executor is current default executor for GitLab It is a simple port from display logic in the old check.rake
There is no concurrency level and the output is progressively printed into the STDOUT
Instance Attribute Summary collapse
-
#checks ⇒ Array<BaseCheck>
readonly
classes of corresponding checks to be executed in the same order.
-
#component ⇒ String
readonly
name of the component relative to the checks being executed.
Instance Method Summary collapse
-
#<<(check) ⇒ Object
Add a check to be executed.
-
#execute ⇒ Object
Executes defined checks in the specified order and outputs confirmation or error information.
-
#initialize(component) ⇒ SimpleExecutor
constructor
A new instance of SimpleExecutor.
-
#run_check(check_klass) ⇒ Object
Executes a single check.
Constructor Details
#initialize(component) ⇒ SimpleExecutor
Returns a new instance of SimpleExecutor.
17 18 19 20 21 22 |
# File 'lib/system_check/simple_executor.rb', line 17 def initialize(component) raise ArgumentError unless component.is_a? String @component = component @checks = Set.new end |
Instance Attribute Details
#checks ⇒ Array<BaseCheck> (readonly)
classes of corresponding checks to be executed in the same order
12 13 14 |
# File 'lib/system_check/simple_executor.rb', line 12 def checks @checks end |
#component ⇒ String (readonly)
name of the component relative to the checks being executed
12 13 14 |
# File 'lib/system_check/simple_executor.rb', line 12 def component @component end |
Instance Method Details
#<<(check) ⇒ Object
Add a check to be executed
27 28 29 30 31 |
# File 'lib/system_check/simple_executor.rb', line 27 def <<(check) raise ArgumentError unless check.is_a?(Class) && check < BaseCheck @checks << check end |
#execute ⇒ Object
Executes defined checks in the specified order and outputs confirmation or error information
34 35 36 37 38 39 40 41 42 |
# File 'lib/system_check/simple_executor.rb', line 34 def execute start_checking(component) @checks.each do |check| run_check(check) end finished_checking(component) end |
#run_check(check_klass) ⇒ Object
Executes a single check
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/system_check/simple_executor.rb', line 47 def run_check(check_klass) print_display_name(check_klass) check = check_klass.new # When implements skip method, we run it first, and if true, skip the check if check.can_skip? && check.skip? $stdout.puts check.skip_reason.try(:color, :magenta) || check_klass.skip_reason.color(:magenta) return end # When implements a multi check, we don't control the output if check.multi_check? check.multi_check return end if check.check? print_check_pass(check_klass) else print_check_failure(check_klass) if check.can_repair? $stdout.print 'Trying to fix error automatically. ...' if check.repair! print_success return else print_failure end end check.show_error end rescue StandardError => e $stdout.puts "Exception: #{e.}".color(:red) end |