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



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

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)
    data = result[name]
    # Transitive gems can't be swapped directly, so point at the direct
    # parent instead of suggesting alternatives for them (#60).
    extra = data[:direct] == false ? dependency_path_line(data) : alternatives_line(data)
    lines << extra if extra
  end
  lines << ""
  lines << summary_line(result)
  lines << ruby_summary_line(ruby_info) if ruby_info
  lines.join("\n")
end