module Kontena::Cli::TableGenerator::Helper
Public Class Methods
included(base)
click to toggle source
# File lib/kontena/cli/table_generator.rb, line 17 def self.included(base) if base.respond_to?(:option) base.option ['-q', '--quiet'], :flag, "Output the identifying column only" end end
Public Instance Methods
generate_table(array, fields = nil, &block)
click to toggle source
# File lib/kontena/cli/table_generator.rb, line 27 def generate_table(array, fields = nil, &block) fields ||= self.fields if self.respond_to?(:fields) table_generator.new( array, fields, row_format_proc: block_given? ? block.to_proc : nil, header_format_proc: lambda { |item| pastel.bold(item.to_s.upcase) }, render_options: self.respond_to?(:render_options) ? DEFAULT_RENDER_OPTS.merge(self.render_options) : DEFAULT_RENDER_OPTS ).render end
print_table(array, fields = nil, &block)
click to toggle source
# File lib/kontena/cli/table_generator.rb, line 38 def print_table(array, fields = nil, &block) output = generate_table(array, fields, &block) puts output unless output.strip.empty? end
table_generator()
click to toggle source
# File lib/kontena/cli/table_generator.rb, line 23 def table_generator Kontena::Cli::TableGenerator end