Class: Dependagrab::ConsoleWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/dependagrab/console_writer.rb

Overview

For writing output in a human readable format in the terminal

Instance Method Summary collapse

Instance Method Details

#write!(result) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dependagrab/console_writer.rb', line 6

def write!(result)
  puts ["SEVERITY".ljust(8), "PACKAGE".ljust(32), "SUMMARY"].join("\t")
  puts '-' * 120

  result.each do |line|
    attr = [
      line[:severity].ljust(8),
      "#{line[:package_name]} (#{line[:vulnerable_version_range]})".ljust(32),
      "#{line[:summary]} (#{line[:ghsa_id]})"
    ]
    puts(attr.join("\t"))
  end

  puts
  puts "Total: #{result.count}"
end