Sha256: 18cd3294eac60ac52bc6d4bde9d205675d834035ab2082e2e6446313e991e46e

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

require_relative '../../command'
require_relative '../../utils/table'
require_relative '../../utils/constants'

module Dri
  module Commands
    class Fetch
      class Triaged < Dri::Command
        include Dri::Utils::Table
        include Dri::Utils::Constants::Triage::Labels
        using Refinements

        def initialize(options)
          @options = options
        end

        def execute(input: $stdin, output: $stdout) # rubocop:disable Metrics/AbcSize
          verify_config_exists

          title = add_color('Title', :magenta)
          url = add_color('URL', :magenta)
          type_label = add_color('Type', :magenta)

          table_labels = [title, url, type_label]
          failures_triaged = []

          logger.info "Fetching your triaged failures..."
          spinner.start

          failures = api_client.fetch_all_triaged_failures(emoji: emoji, state: 'opened')

          if failures.empty?
            logger.info "There are no failures triaged yet with #{add_color(emoji, :black, :on_white)}."
            exit 0
          end

          failures.each do |triaged|
            title = triaged["title"].truncate(70)
            url = triaged["web_url"]
            labels = triaged["labels"]
            type = ""

            labels.each do |label|
              type = label.gsub!(FAILURE, ' ').to_s if label.include? FAILURE
            end

            failures_triaged << [title, url, type]
          end

          spinner.stop

          print_table(table_labels, failures_triaged)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dri-0.10.2 lib/dri/commands/fetch/triaged.rb
dri-0.10.1 lib/dri/commands/fetch/triaged.rb
dri-0.10.0 lib/dri/commands/fetch/triaged.rb
dri-0.9.0 lib/dri/commands/fetch/triaged.rb
dri-0.8.0 lib/dri/commands/fetch/triaged.rb