Class: Taski::Progress::Theme::Base

Inherits:
Object
  • Object
show all
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.

Examples:

Custom theme

class MyTheme < Taski::Progress::Theme::Base
  def task_start
    "Starting {{ task.name }}..."
  end
end

layout = Taski::Progress::Layout::Log.new(theme: MyTheme.new)

Direct Known Subclasses

Default

Instance Method Summary collapse

Instance Method Details

#clean_failObject



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_startObject

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_successObject



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_dimString

Dim color ANSI escape code

Returns:

  • (String)

    ANSI code for dim



162
163
164
# File 'lib/taski/progress/theme/base.rb', line 162

def color_dim
  "\e[2m"
end

#color_greenString

Green color ANSI escape code

Returns:

  • (String)

    ANSI code for green



144
145
146
# File 'lib/taski/progress/theme/base.rb', line 144

def color_green
  "\e[32m"
end

#color_redString

Red color ANSI escape code

Returns:

  • (String)

    ANSI code for red



150
151
152
# File 'lib/taski/progress/theme/base.rb', line 150

def color_red
  "\e[31m"
end

#color_resetString

Reset color ANSI escape code

Returns:

  • (String)

    ANSI code to reset color



168
169
170
# File 'lib/taski/progress/theme/base.rb', line 168

def color_reset
  "\e[0m"
end

#color_yellowString

Yellow color ANSI escape code

Returns:

  • (String)

    ANSI code for yellow



156
157
158
# File 'lib/taski/progress/theme/base.rb', line 156

def color_yellow
  "\e[33m"
end

#execution_completeObject



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_failObject



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_runningObject



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_startObject

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.

Examples:

def format_count(count)
  "#{count}"
end

Parameters:

  • count (Integer)

    The count value

Returns:

  • (String)

    Formatted count



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.

Examples:

def format_duration(ms)
  "#{ms}ミリ秒"
end

Parameters:

  • ms (Integer, Float)

    Duration in milliseconds

Returns:

  • (String)

    Formatted duration



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_failObject



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_startObject

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_successObject



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_failureString

Icon for failure

Returns:

  • (String)

    Failure icon



124
125
126
# File 'lib/taski/progress/theme/base.rb', line 124

def icon_failure
  ""
end

#icon_pendingString

Icon for pending state

Returns:

  • (String)

    Pending icon



130
131
132
# File 'lib/taski/progress/theme/base.rb', line 130

def icon_pending
  ""
end

#icon_skipString

Icon for skipped state

Returns:

  • (String)

    Skipped icon



136
137
138
# File 'lib/taski/progress/theme/base.rb', line 136

def icon_skip
  ""
end

#icon_successString

Icon for successful completion

Returns:

  • (String)

    Success icon



118
119
120
# File 'lib/taski/progress/theme/base.rb', line 118

def icon_success
  ""
end

#render_intervalFloat

Screen render interval in seconds

Returns:

  • (Float)

    Interval between screen updates



110
111
112
# File 'lib/taski/progress/theme/base.rb', line 110

def render_interval
  0.1
end

#spinner_framesArray<String>

Spinner animation frames

Returns:

  • (Array<String>)

    Array of spinner frame characters



98
99
100
# File 'lib/taski/progress/theme/base.rb', line 98

def spinner_frames
  %w[         ]
end

#spinner_intervalFloat

Spinner frame update interval in seconds

Returns:

  • (Float)

    Interval between spinner frame updates



104
105
106
# File 'lib/taski/progress/theme/base.rb', line 104

def spinner_interval
  0.08
end

#task_failObject



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_pendingObject

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_skipObject



44
45
46
# File 'lib/taski/progress/theme/base.rb', line 44

def task_skip
  "[SKIP] {{ task.name | short_name }}"
end

#task_startObject



32
33
34
# File 'lib/taski/progress/theme/base.rb', line 32

def task_start
  "[START] {{ task.name | short_name }}"
end

#task_successObject



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_separatorString

Separator for truncate_list filter.

Returns:

  • (String)

    Separator between list items



206
207
208
# File 'lib/taski/progress/theme/base.rb', line 206

def truncate_list_separator
  ", "
end

#truncate_list_suffixString

Suffix for truncate_list filter when list is truncated.

Returns:

  • (String)

    Suffix to append when items are omitted



212
213
214
# File 'lib/taski/progress/theme/base.rb', line 212

def truncate_list_suffix
  "..."
end

#truncate_text_suffixString

Suffix for truncate_text filter when text is truncated.

Returns:

  • (String)

    Suffix to append when text is truncated



218
219
220
# File 'lib/taski/progress/theme/base.rb', line 218

def truncate_text_suffix
  "..."
end