Class: Kafo::SystemChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/kafo/system_checker.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SystemChecker

Returns a new instance of SystemChecker.



13
14
15
# File 'lib/kafo/system_checker.rb', line 13

def initialize(path)
  @checkers = Dir.glob(path).sort
end

Instance Attribute Details

#checkersObject (readonly)

Returns the value of attribute checkers.



5
6
7
# File 'lib/kafo/system_checker.rb', line 5

def checkers
  @checkers
end

Class Method Details

.checkObject



7
8
9
10
11
# File 'lib/kafo/system_checker.rb', line 7

def self.check
  KafoConfigure.check_dirs.all? do |dir|
    new(File.join(dir, '*')).check
  end
end

Instance Method Details

#checkObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/kafo/system_checker.rb', line 21

def check
  @checkers.map! do |checker|
    logger.debug "Executing checker: #{checker}"
    stdout = `#{checker}`
    logger.error stdout unless stdout.empty?
    $?.exitstatus == 0
  end

  @checkers.all?
end

#loggerObject



17
18
19
# File 'lib/kafo/system_checker.rb', line 17

def logger
  ::Logging::logger['checks']
end