Class: Spandx::Cli::Printers::Table

Inherits:
Spandx::Cli::Printer show all
Defined in:
lib/spandx/cli/printers/table.rb

Constant Summary collapse

HEADINGS =
['Name', 'Version', 'Licenses', 'Location'].freeze

Instance Method Summary collapse

Methods inherited from Spandx::Cli::Printer

for

Methods included from Spandx::Core::Registerable

#all, #each, #inherited, #registry

Constructor Details

#initialize(output: $stderr) ⇒ Table

Returns a new instance of Table.



9
10
11
12
# File 'lib/spandx/cli/printers/table.rb', line 9

def initialize(output: $stderr)
  @spinner = TTY::Spinner.new('[:spinner] Scanning...', output: output, clear: true, format: :dots)
  super()
end

Instance Method Details

#match?(format) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/spandx/cli/printers/table.rb', line 14

def match?(format)
  format.to_sym == :table
end


27
28
29
30
31
# File 'lib/spandx/cli/printers/table.rb', line 27

def print_footer(io)
  @spinner.stop
  @spinner.reset
  io.puts(to_table(@dependencies.map(&:to_a)))
end


18
19
20
21
# File 'lib/spandx/cli/printers/table.rb', line 18

def print_header(_io)
  @spinner.auto_spin
  @dependencies = SortedSet.new
end


23
24
25
# File 'lib/spandx/cli/printers/table.rb', line 23

def print_line(dependency, _io)
  @dependencies << dependency
end