Sha256: def2539a1e44bed5f0b4d0d31190ff6edab3e5149c0291416042f0f692cf6937

Contents?: true

Size: 864 Bytes

Versions: 2

Compression:

Stored size: 864 Bytes

Contents

require 'tty-markdown'

module Inferno
  module CLI
    class Suites
      def run
        ENV['NO_DB'] = 'true'

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
inferno_core-0.6.1 lib/inferno/apps/cli/suites.rb
inferno_core-0.6.0 lib/inferno/apps/cli/suites.rb