Method: CLI::UI::Spinner::SpinGroup#debrief

Defined in:
lib/cli/ui/spinner/spin_group.rb

#debrief(to: $stdout) ⇒ Object (private)

Debriefs failed tasks is auto_debrief is true

Options

  • :to - Target stream, like $stdout or $stderr. Can be anything with print and puts methods, or under Sorbet, IO or StringIO. Defaults to $stdout

: (?to: io_like) -> bool



564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
# File 'lib/cli/ui/spinner/spin_group.rb', line 564

def debrief(to: $stdout)
  @m.synchronize do
    @tasks.each do |task|
      next unless task.done

      title = task.title
      out = task.stdout
      err = task.stderr

      if task.success
        next @success_debrief&.call(title, out, err)
      end

      # exception will not be set if the wait loop is stopped before the task is checked
      e = task.exception
      next @failure_debrief.call(title, e, out, err) if @failure_debrief

      CLI::UI::Frame.open('Task Failed: ' + title, color: :red, timing: Time.new - @start) do
        if e
          to.puts("#{e.class}: #{e.message}")
          to.puts("\tfrom #{e.backtrace.join("\n\tfrom ")}")
        end

        CLI::UI::Frame.divider('STDOUT')
        out = '(empty)' if out.nil? || out.strip.empty?
        to.puts(out)

        CLI::UI::Frame.divider('STDERR')
        err = '(empty)' if err.nil? || err.strip.empty?
        to.puts(err)
      end
    end
    @tasks.all?(&:success)
  end
end