Class: FeduxOrgStdlib::SupportInformation

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

Overview

Gather support information

info = SupportInformation.new puts info

Examples:

Gather information

Instance Method Summary collapse

Constructor Details

#initialize(logger: FeduxOrgStdlib::Logging::Logger.new, headlines: {}, underline_character: '-') ⇒ SupportInformation

Returns a new instance of SupportInformation.



20
21
22
23
24
# File 'lib/fedux_org_stdlib/support_information.rb', line 20

def initialize(logger: FeduxOrgStdlib::Logging::Logger.new, headlines: {}, underline_character: '-')
  @logger              = logger
  @headlines           = headlines
  @underline_character = underline_character
end

Instance Method Details

#to_sString

Output support information as string

Returns:

  • (String)

    The available information



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fedux_org_stdlib/support_information.rb', line 30

def to_s
  result = []

  max_field_length = determine_max_field_length(facter_fields)

  result << headlines.fetch(:system_information, 'System Information').underline(character: underline_character)
  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 << headlines.fetch(:rubygems_information, 'Rubygems Information').underline(character: underline_character)
  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 << headlines.fetch(:installed_rubygems, 'Installed Rubygems').underline(character: underline_character)
  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