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
# 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)
end

Instance Method Details

#match?(format) ⇒ Boolean

Returns:

  • (Boolean)


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

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


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

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


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

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


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

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