Class: Licensure::Formatters::Table

Inherits:
Base
  • Object
show all
Defined in:
lib/licensure/formatters/table.rb

Overview

Renders terminal-friendly ASCII tables.

Constant Summary collapse

LIST_HEADERS =
["Gem", "Version", "License", "Source", "Homepage"].freeze
CHECK_HEADERS =
["Gem", "Version", "License", "Source", "Reason"].freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Licensure::Formatters::Base

Instance Method Details

#render(gem_license_infos) ⇒ String

Parameters:

Returns:

  • (String)


12
13
14
15
# File 'lib/licensure/formatters/table.rb', line 12

def render(gem_license_infos)
  rows = gem_license_infos.map { |info| gem_row(info) }
  write_output(build_table(LIST_HEADERS, rows))
end

#render_check_result(check_result) ⇒ String

Parameters:

Returns:

  • (String)


19
20
21
22
23
24
25
26
# File 'lib/licensure/formatters/table.rb', line 19

def render_check_result(check_result)
  sections = []
  sections << section("PASSED", build_table(LIST_HEADERS, check_result.passed.map { |info| gem_row(info) }))
  sections << section("VIOLATIONS", build_table(CHECK_HEADERS, check_result.violations.map { |item| violation_row(item) }))
  sections << section("WARNINGS", build_table(CHECK_HEADERS, check_result.warnings.map { |item| violation_row(item) }))

  write_output(sections.join("\n\n"))
end