Class: ConfCtl::HealthChecks::Systemd::Properties

Inherits:
Base
  • Object
show all
Defined in:
lib/confctl/health_checks/systemd/properties.rb

Instance Attribute Summary

Attributes inherited from Base

#errors, #machine

Instance Method Summary collapse

Methods inherited from Base

#run, #successful?

Constructor Details

#initialize(machine, property_checks:, pattern: nil) ⇒ Properties

Returns a new instance of Properties.

Parameters:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/confctl/health_checks/systemd/properties.rb', line 8

def initialize(machine, property_checks:, pattern: nil)
  super(machine)
  @pattern = pattern
  @property_checks = property_checks
  @shortest_timeout = property_checks.inject(nil) do |acc, check|
    if acc.nil? || check.timeout < acc
      check.timeout
    else
      acc
    end
  end
  @shortest_cooldown = property_checks.inject(nil) do |acc, check|
    if acc.nil? || check.cooldown < acc
      check.cooldown
    else
      acc
    end
  end
end

Instance Method Details

#descriptionObject



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/confctl/health_checks/systemd/properties.rb', line 28

def description
  ret = ''

  if @pattern
    ret << @pattern << ': '
  else
    ret << 'systemd: '
  end

  ret << @property_checks.map(&:to_s).join(', ')
  ret
end

#messageObject



41
42
43
44
45
46
47
# File 'lib/confctl/health_checks/systemd/properties.rb', line 41

def message
  if @pattern
    "#{@pattern}: #{super}"
  else
    super
  end
end