Module: FunCi::Tui::RowFormatter

Defined in:
lib/fun_ci/tui/row_formatter.rb

Constant Summary collapse

STAGE_NAMES =
{ "lint" => "Lint", "build" => "Build", "fast" => "Fast", "slow" => "Slow" }.freeze
STATUS_LABELS =
{
  "completed" => "PASSED", "failed" => "FAILED", "timed_out" => "TIMED OUT",
  "running" => "RUNNING", "scheduled" => "Scheduled...", "cancelled" => "CANCELLED"
}.freeze
PROJECT_COLORS =
%w[31 32 33 34 35 36 91 92 93 94].freeze

Class Method Summary collapse

Class Method Details

.format(run, now: Time.now, spinner_frame: nil, elapsed_seconds: nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fun_ci/tui/row_formatter.rb', line 17

def self.format(run, now: Time.now, spinner_frame: nil, elapsed_seconds: nil)
  commit = run[:commit_hash][0, 7]
  branch = run[:branch]
  status = run[:status]
  project = format_project(run[:project_path])

  case status
  when "scheduled"
    format_scheduled(commit, branch, project, run[:updated_at], now)
  when "cancelled"
    format_cancelled(commit, branch, project, run[:stages], run[:updated_at], now)
  else
    stages_text = format_stages(run[:stages], status, spinner_frame, elapsed_seconds)
    status_text = format_status(status)
    time_text = Ansi.dim(RelativeTime.format(run[:updated_at], now: now))
    "  #{commit}  #{branch}#{project}  #{stages_text}  #{status_text}  #{time_text}"
  end
end