Class: FeduxOrgStdlib::SupportInformation

Inherits:
Object
  • Object
show all
Defined in:
lib/fedux_org_stdlib/support_information.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger: FeduxOrgStdlib::Logging::Logger.new) ⇒ SupportInformation

Returns a new instance of SupportInformation.



12
13
14
# File 'lib/fedux_org_stdlib/support_information.rb', line 12

def initialize(logger: FeduxOrgStdlib::Logging::Logger.new)
  @logger = logger
end

Instance Method Details

#to_sString

Output support information as string

Returns:

  • (String)

    The available information



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fedux_org_stdlib/support_information.rb', line 20

def to_s
  result = []

  max_field_length = determine_max_field_length(facter_fields)

  result << format("%#{max_field_length}s | %s", 'Information', 'Value')
  result << format("%s + %s", '-' * max_field_length, '-' * 40)
  result.concat system_information.sort_by { |key, value| key }.map { |key, value| format("%#{max_field_length}s | %s", key, value) }

  result << ""
  result << ""
  result << ""

  max_field_length = determine_max_field_length(rubygems_information.keys)

  result << format("%#{max_field_length}s | %s", 'Information', 'Value')
  result << format("%s + %s", '-' * max_field_length, '-' * 40)
  result.concat rubygems_information.sort_by { |key, value| key }.map { |key, value| format("%#{max_field_length}s | %s", key, value) }

  result << ""
  result << ""
  result << ""

  max_field_length = determine_max_field_length(installed_rubygems.keys)

  result << format("%#{max_field_length}s | %s", 'Name', 'version')
  result << format("%s + %s", '-' * max_field_length, '-' * 40)
  result.concat installed_rubygems.sort_by { |key, value| key }.map { |key, value| format("%#{max_field_length}s | %s", key, value) }

  result.join "\n"
end