Class: Inferno::CLI::Suites

Inherits:
Object
  • Object
show all
Defined in:
lib/inferno/apps/cli/suites.rb

Instance Method Summary collapse

Instance Method Details

#runObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/inferno/apps/cli/suites.rb', line 6

def run
  ENV['NO_DB'] = 'true'

  require_relative '../../../inferno'

  Inferno::Application.start(:suites)

  suites = Inferno::Repositories::TestSuites.new.all
  suite_hash = suites.each_with_object({}) { |suite, hash| hash[suite.id] = suite.title }

  id_column_length = suite_hash.keys.map(&:length).max + 2
  title_column_length = suite_hash.values.map(&:length).max + 1

  output = ''
  output += "| #{'Title'.ljust(title_column_length)}| #{'ID'.ljust(id_column_length)}|\n"
  output += "|-#{'-' * title_column_length}|-#{'-' * id_column_length}|\n"

  suite_hash.each do |id, title|
    output += "| #{title.ljust(title_column_length)}| #{id.ljust(id_column_length)}|\n"
  end

  puts TTY::Markdown.parse(output)
end