Module: StillActive::TerminalHelper

Extended by:
TerminalHelper
Included in:
TerminalHelper
Defined in:
lib/helpers/terminal_helper.rb

Constant Summary collapse

HEADERS =
["Name", "Version", "Activity", "OpenSSF", "Vulns", "License"].freeze

Instance Method Summary collapse

Instance Method Details

#render(result, ruby_info: nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/helpers/terminal_helper.rb', line 15

def render(result, ruby_info: nil)
  names = result.keys.sort
  rows = names.map { |name| build_row(name, result[name]) }
  widths = column_widths(rows)

  lines = []
  lines << header_line(widths)
  lines << separator_line(widths)
  names.each_with_index do |name, i|
    lines << row_line(rows[i], widths)
    extra = alternatives_line(result[name])
    lines << extra if extra
  end
  lines << ""
  lines << summary_line(result)
  lines << ruby_summary_line(ruby_info) if ruby_info
  lines.join("\n")
end