Class: Taski::Progress::Theme::Base
- Inherits:
-
Object
- Object
- Taski::Progress::Theme::Base
- Defined in:
- lib/taski/progress/theme/base.rb
Overview
Base class for theme definitions. Theme classes are thin layers that only return Liquid template strings. Rendering (Liquid parsing) is handled by Layout classes.
Themes have access to two Drop objects:
task: Task-specific info (name, state, duration, error_message, group_name, stdout)
execution: Execution-level info (state, pending_count, done_count, completed_count,
failed_count, total_count, total_duration, root_task_name, task_names)
Use if variable % to conditionally render when a value is present.
Direct Known Subclasses
Instance Method Summary collapse
- #clean_fail ⇒ Object
-
#clean_start ⇒ Object
Clean lifecycle templates ===.
- #clean_success ⇒ Object
-
#color_dim ⇒ String
Dim color ANSI escape code.
-
#color_green ⇒ String
Green color ANSI escape code.
-
#color_red ⇒ String
Red color ANSI escape code.
-
#color_reset ⇒ String
Reset color ANSI escape code.
-
#color_yellow ⇒ String
Yellow color ANSI escape code.
- #execution_complete ⇒ Object
- #execution_fail ⇒ Object
- #execution_running ⇒ Object
-
#execution_start ⇒ Object
Execution lifecycle templates ===.
-
#format_count(count) ⇒ String
Format a count value for display.
-
#format_duration(ms) ⇒ String
Format a duration value for display.
- #group_fail ⇒ Object
-
#group_start ⇒ Object
Group lifecycle templates ===.
- #group_success ⇒ Object
-
#icon_failure ⇒ String
Icon for failure.
-
#icon_pending ⇒ String
Icon for pending state.
-
#icon_skip ⇒ String
Icon for skipped state.
-
#icon_success ⇒ String
Icon for successful completion.
-
#render_interval ⇒ Float
Screen render interval in seconds.
-
#spinner_frames ⇒ Array<String>
Spinner animation frames.
-
#spinner_interval ⇒ Float
Spinner frame update interval in seconds.
- #task_fail ⇒ Object
-
#task_pending ⇒ Object
Task lifecycle templates ===.
- #task_skip ⇒ Object
- #task_start ⇒ Object
- #task_success ⇒ Object
-
#truncate_list_separator ⇒ String
Separator for truncate_list filter.
-
#truncate_list_suffix ⇒ String
Suffix for truncate_list filter when list is truncated.
-
#truncate_text_suffix ⇒ String
Suffix for truncate_text filter when text is truncated.
Instance Method Details
#clean_fail ⇒ Object
58 59 60 |
# File 'lib/taski/progress/theme/base.rb', line 58 def clean_fail "[CLEAN FAIL] {{ task.name | short_name }}{% if task.error_message %}: {{ task.error_message }}{% endif %}" end |
#clean_start ⇒ Object
Clean lifecycle templates ===
50 51 52 |
# File 'lib/taski/progress/theme/base.rb', line 50 def clean_start "[CLEAN] {{ task.name | short_name }}" end |
#clean_success ⇒ Object
54 55 56 |
# File 'lib/taski/progress/theme/base.rb', line 54 def clean_success "[CLEAN DONE] {{ task.name | short_name }}{% if task.duration %} ({{ task.duration | format_duration }}){% endif %}" end |
#color_dim ⇒ String
Dim color ANSI escape code
162 163 164 |
# File 'lib/taski/progress/theme/base.rb', line 162 def color_dim "\e[2m" end |
#color_green ⇒ String
Green color ANSI escape code
144 145 146 |
# File 'lib/taski/progress/theme/base.rb', line 144 def color_green "\e[32m" end |
#color_red ⇒ String
Red color ANSI escape code
150 151 152 |
# File 'lib/taski/progress/theme/base.rb', line 150 def color_red "\e[31m" end |
#color_reset ⇒ String
Reset color ANSI escape code
168 169 170 |
# File 'lib/taski/progress/theme/base.rb', line 168 def color_reset "\e[0m" end |
#color_yellow ⇒ String
Yellow color ANSI escape code
156 157 158 |
# File 'lib/taski/progress/theme/base.rb', line 156 def color_yellow "\e[33m" end |
#execution_complete ⇒ Object
86 87 88 |
# File 'lib/taski/progress/theme/base.rb', line 86 def execution_complete "[TASKI] Completed: {{ execution.done_count }}/{{ execution.total_count }} tasks ({{ execution.total_duration | format_duration }})" end |
#execution_fail ⇒ Object
90 91 92 |
# File 'lib/taski/progress/theme/base.rb', line 90 def execution_fail "[TASKI] Failed: {{ execution.failed_count }}/{{ execution.total_count }} tasks ({{ execution.total_duration | format_duration }})" end |
#execution_running ⇒ Object
82 83 84 |
# File 'lib/taski/progress/theme/base.rb', line 82 def execution_running "[TASKI] Running: {{ execution.done_count }}/{{ execution.total_count }} tasks" end |
#execution_start ⇒ Object
Execution lifecycle templates ===
78 79 80 |
# File 'lib/taski/progress/theme/base.rb', line 78 def execution_start "[TASKI] Starting {{ execution.root_task_name | short_name }}" end |
#format_count(count) ⇒ String
Format a count value for display. Override in subclasses to customize count formatting.
183 184 185 |
# File 'lib/taski/progress/theme/base.rb', line 183 def format_count(count) count.to_s end |
#format_duration(ms) ⇒ String
Format a duration value for display. Override in subclasses to customize duration formatting.
196 197 198 199 200 201 202 |
# File 'lib/taski/progress/theme/base.rb', line 196 def format_duration(ms) if ms >= 1000 "#{(ms / 1000.0).round(1)}s" else "#{ms}ms" end end |
#group_fail ⇒ Object
72 73 74 |
# File 'lib/taski/progress/theme/base.rb', line 72 def group_fail '[GROUP FAIL] {{ task.name | short_name }}#{{ task.group_name }}{% if task.error_message %}: {{ task.error_message }}{% endif %}' end |
#group_start ⇒ Object
Group lifecycle templates ===
64 65 66 |
# File 'lib/taski/progress/theme/base.rb', line 64 def group_start '[GROUP] {{ task.name | short_name }}#{{ task.group_name }}' end |
#group_success ⇒ Object
68 69 70 |
# File 'lib/taski/progress/theme/base.rb', line 68 def group_success '[GROUP DONE] {{ task.name | short_name }}#{{ task.group_name }}{% if task.duration %} ({{ task.duration | format_duration }}){% endif %}' end |
#icon_failure ⇒ String
Icon for failure
124 125 126 |
# File 'lib/taski/progress/theme/base.rb', line 124 def icon_failure "✗" end |
#icon_pending ⇒ String
Icon for pending state
130 131 132 |
# File 'lib/taski/progress/theme/base.rb', line 130 def icon_pending "○" end |
#icon_skip ⇒ String
Icon for skipped state
136 137 138 |
# File 'lib/taski/progress/theme/base.rb', line 136 def icon_skip "⊘" end |
#icon_success ⇒ String
Icon for successful completion
118 119 120 |
# File 'lib/taski/progress/theme/base.rb', line 118 def icon_success "✓" end |
#render_interval ⇒ Float
Screen render interval in seconds
110 111 112 |
# File 'lib/taski/progress/theme/base.rb', line 110 def render_interval 0.1 end |
#spinner_frames ⇒ Array<String>
Spinner animation frames
98 99 100 |
# File 'lib/taski/progress/theme/base.rb', line 98 def spinner_frames %w[⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏] end |
#spinner_interval ⇒ Float
Spinner frame update interval in seconds
104 105 106 |
# File 'lib/taski/progress/theme/base.rb', line 104 def spinner_interval 0.08 end |
#task_fail ⇒ Object
40 41 42 |
# File 'lib/taski/progress/theme/base.rb', line 40 def task_fail "[FAIL] {{ task.name | short_name }}{% if task.error_message %}: {{ task.error_message }}{% endif %}" end |
#task_pending ⇒ Object
Task lifecycle templates ===
28 29 30 |
# File 'lib/taski/progress/theme/base.rb', line 28 def task_pending "[PENDING] {{ task.name | short_name }}" end |
#task_skip ⇒ Object
44 45 46 |
# File 'lib/taski/progress/theme/base.rb', line 44 def task_skip "[SKIP] {{ task.name | short_name }}" end |
#task_start ⇒ Object
32 33 34 |
# File 'lib/taski/progress/theme/base.rb', line 32 def task_start "[START] {{ task.name | short_name }}" end |
#task_success ⇒ Object
36 37 38 |
# File 'lib/taski/progress/theme/base.rb', line 36 def task_success "[DONE] {{ task.name | short_name }}{% if task.duration %} ({{ task.duration | format_duration }}){% endif %}" end |
#truncate_list_separator ⇒ String
Separator for truncate_list filter.
206 207 208 |
# File 'lib/taski/progress/theme/base.rb', line 206 def truncate_list_separator ", " end |
#truncate_list_suffix ⇒ String
Suffix for truncate_list filter when list is truncated.
212 213 214 |
# File 'lib/taski/progress/theme/base.rb', line 212 def truncate_list_suffix "..." end |
#truncate_text_suffix ⇒ String
Suffix for truncate_text filter when text is truncated.
218 219 220 |
# File 'lib/taski/progress/theme/base.rb', line 218 def truncate_text_suffix "..." end |