Sha256: 012ca598a51255dc624413f49a96958ffc08e7920e8dd847518396843678b943
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
require_relative '../../command' require 'tty-table' module Dri module Commands class Fetch class Triaged < Dri::Command def initialize(options) @options = options end def execute(input: $stdin, output: $stdout) 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 response = api_client.fetch_triaged_failures(emoji: emoji, state: 'opened') if response.empty? logger.info "There are no failures triaged yet with #{add_color(emoji, :black, :on_white)}." exit 0 end response.each do |triaged| title = truncate(triaged["title"], 70) url = triaged["web_url"] labels = triaged["labels"] type = "" labels.each do |label| type = label.gsub!('failure::', ' ').to_s if label.include? "failure::" end labels = triaged["labels"] failures_triaged << [title, url, type] end spinner.stop table = TTY::Table.new(table_labels,failures_triaged) puts table.render(:ascii, resize: true, alignments: [:center, :center, :center]) end private def truncate(string, max) string.length > max ? "#{string[0...max]}..." : string end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dri-0.1.2 | lib/dri/commands/fetch/triaged.rb |