Module: FunCi::Tui::AnimationCompositor
- Defined in:
- lib/fun_ci/tui/animation_compositor.rb
Constant Summary collapse
Class Method Summary collapse
- .footer_overlay(animation, width) ⇒ Object
- .header_overlay(animation, width) ⇒ Object
- .stage_col_for(run, stage_name) ⇒ Object
- .stage_column_overlay(animation, stage_text, col) ⇒ Object
- .stage_text_for(run, stage_name) ⇒ Object
Class Method Details
.footer_overlay(animation, width) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/fun_ci/tui/animation_compositor.rb', line 24 def self.(animation, width) frames = case animation.type when :failure AnimationFrames.(animation.stage || "stage", width) when :success then AnimationFrames.(width) else return nil end frame_at(frames, animation.frame) end |
.header_overlay(animation, width) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/fun_ci/tui/animation_compositor.rb', line 14 def self.(animation, width) frames = case animation.type when :failure then AnimationFrames.failure_header(width) when :success then AnimationFrames.success_header(width) when :timeout then AnimationFrames.timeout_header(width) else return nil end frame_at(frames, animation.frame) end |
.stage_col_for(run, stage_name) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/fun_ci/tui/animation_compositor.rb', line 57 def self.stage_col_for(run, stage_name) project = run[:project_path] ? " #{File.basename(run[:project_path])}" : "" prefix_len = 2 + 7 + 2 + run[:branch].to_s.length + project.length + 2 (run[:stages] || []).each do |s| return prefix_len + 1 if s[:stage] == stage_name prefix_len += stage_text_for(run, s[:stage]).to_s.length + 2 end nil end |
.stage_column_overlay(animation, stage_text, col) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/fun_ci/tui/animation_compositor.rb', line 34 def self.(animation, stage_text, col) case animation.type when :stage_pass then color_flash(animation, stage_text, AnimationFrames.stage_pass_colors) when :timeout then color_flash(animation, stage_text, AnimationFrames.timeout_colors) when :failure then failure_flanks(animation, stage_text) when :success then sparkle_sweep(animation, stage_text) end end |
.stage_text_for(run, stage_name) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fun_ci/tui/animation_compositor.rb', line 43 def self.stage_text_for(run, stage_name) stage = run[:stages]&.find { |s| s[:stage] == stage_name } return nil unless stage name = RowFormatter::STAGE_NAMES[stage[:stage]] || stage[:stage] dur = stage[:duration] ? DurationFormatter.format(stage[:duration]) : "--" case stage[:status] when "completed" then "#{name} #{dur}" when "failed" then "#{name} FAIL #{dur}" when "timed_out" then "#{name} TIMEOUT #{dur}" else "#{name} --" end end |