Class: Ace::Retro::Molecules::RetroDisplayFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/retro/molecules/retro_display_formatter.rb

Overview

Formats retro objects for terminal display.

Constant Summary collapse

STATUS_SYMBOLS =
{
  "active" => "",
  "done" => ""
}.freeze
STATUS_COLORS =
{
  "active" => Ace::Support::Items::Atoms::AnsiColors::YELLOW,
  "done" => Ace::Support::Items::Atoms::AnsiColors::GREEN
}.freeze
TYPE_LABELS =
{
  "standard" => "standard",
  "conversation-analysis" => "conversation",
  "self-review" => "self-review"
}.freeze
STATUS_ORDER =
%w[active done].freeze

Class Method Summary collapse

Class Method Details

.format(retro, show_content: false) ⇒ String

Format a single retro for display

Parameters:

  • retro (Retro)

    Retro to format

  • show_content (Boolean) (defaults to: false)

    Whether to include full content

Returns:

  • (String)

    Formatted output



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ace/retro/molecules/retro_display_formatter.rb', line 37

def self.format(retro, show_content: false)
  c = Ace::Support::Items::Atoms::AnsiColors
  status_sym = colored_status_sym(retro.status)
  id_str = show_content ? retro.id : c.colorize(retro.id, c::DIM)
  tags_str = retro.tags.any? ? c.colorize(" [#{retro.tags.join(", ")}]", c::DIM) : ""
  folder_str = retro.special_folder ? c.colorize(" (#{retro.special_folder})", c::DIM) : ""
  type_str = c.colorize(" <#{TYPE_LABELS[retro.type] || retro.type}>", c::DIM)
  lines = []
  lines << "#{status_sym} #{id_str} #{retro.title}#{type_str}#{tags_str}#{folder_str}"

  if show_content && retro.content && !retro.content.strip.empty?
    lines << ""
    lines << retro.content
  end

  if retro.folder_contents&.any?
    lines << ""
    lines << "Files: #{retro.folder_contents.join(", ")}"
  end

  lines.join("\n")
end

.format_list(retros, total_count: nil, global_folder_stats: nil) ⇒ String

Format a list of retros for display

Parameters:

  • retros (Array<Retro>)

    Retros to format

  • total_count (Integer, nil) (defaults to: nil)

    Total items before folder filtering

  • global_folder_stats (Hash, nil) (defaults to: nil)

    Folder name → count hash from full scan

Returns:

  • (String)

    Formatted list output



65
66
67
68
69
70
# File 'lib/ace/retro/molecules/retro_display_formatter.rb', line 65

def self.format_list(retros, total_count: nil, global_folder_stats: nil)
  return "No retros found." if retros.empty?

  lines = retros.map { |retro| format(retro) }.join("\n")
  "#{lines}\n\n#{format_stats_line(retros, total_count: total_count, global_folder_stats: global_folder_stats)}"
end

.format_stats_line(retros, total_count: nil, global_folder_stats: nil) ⇒ String

Format a stats summary line for a list of retros.

Parameters:

  • retros (Array<Retro>)

    Retros to summarize

  • total_count (Integer, nil) (defaults to: nil)

    Total items before folder filtering

  • global_folder_stats (Hash, nil) (defaults to: nil)

    Folder name → count hash from full scan

Returns:

  • (String)

    e.g. “Retros: ○ 2 | ✓ 5 • 2 of 7”



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/ace/retro/molecules/retro_display_formatter.rb', line 79

def self.format_stats_line(retros, total_count: nil, global_folder_stats: nil)
  stats = Ace::Support::Items::Atoms::ItemStatistics.count_by(retros, :status)
  folder_stats = Ace::Support::Items::Atoms::ItemStatistics.count_by(retros, :special_folder)
  Ace::Support::Items::Atoms::StatsLineFormatter.format(
    label: "Retros",
    stats: stats,
    status_order: STATUS_ORDER,
    status_icons: STATUS_SYMBOLS,
    folder_stats: folder_stats,
    total_count: total_count,
    global_folder_stats: global_folder_stats
  )
end