Class: RSpecTelemetry::Trace::Viewer::Screen::TimelineScreen

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_telemetry/trace/viewer/screen/timeline_screen.rb

Overview

Timeline-only state: filtering, folding, failure jumps, and live refresh.

Instance Method Summary collapse

Constructor Details

#initialize(document, list) ⇒ TimelineScreen

Returns a new instance of TimelineScreen.



17
18
19
20
21
22
23
24
# File 'lib/rspec_telemetry/trace/viewer/screen/timeline_screen.rb', line 17

def initialize(document, list)
  @document = document
  @list = list
  @filter = nil
  @collapsed = Set.new
  rebuild
  compute_durations
end

Instance Method Details

#activateObject



31
32
33
34
35
# File 'lib/rspec_telemetry/trace/viewer/screen/timeline_screen.rb', line 31

def activate
  @collapsed.clear
  rebuild
  compute_durations
end

#countObject



29
# File 'lib/rspec_telemetry/trace/viewer/screen/timeline_screen.rb', line 29

def count = @visible.size

#current_sourceObject



62
63
64
65
66
67
68
# File 'lib/rspec_telemetry/trace/viewer/screen/timeline_screen.rb', line 62

def current_source
  entry = current_entry
  return entry.source if entry.is_a?(Document::Action)

  action = entry.is_a?(Document::Event) ? @document.action(entry.action) : nil
  action&.source
end

#detail_lines(width) ⇒ Object



55
56
57
58
59
60
# File 'lib/rspec_telemetry/trace/viewer/screen/timeline_screen.rb', line 55

def detail_lines(width)
  entry = current_entry
  children = entry.is_a?(Document::Action) ? @document.events_for(entry.seq) : []
  duration = entry.is_a?(Document::Action) ? @durations[entry.seq] : nil
  DetailLines.for(entry, children: children, duration: duration, width: width)
end

#draw_list(canvas, rect, focused:) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rspec_telemetry/trace/viewer/screen/timeline_screen.rb', line 42

def draw_list(canvas, rect, focused:)
  TimelinePane
    .new(
      @visible,
      list: @list,
      focus: focused,
      collapsed: @collapsed,
      childful: @childful,
      durations: @durations
    )
    .draw(canvas, rect)
end

#handle_key_event(event, app) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/rspec_telemetry/trace/viewer/screen/timeline_screen.rb', line 77

def handle_key_event(event, app)
  case event.key
  when "/"
    open_filter(app)
  when "a"
    open_example_jump(app)
  when "n"
    jump_error(app, 1)
  when "N"
    jump_error(app, -1)
  when "\r"
    toggle_fold(app)
  when "z"
    toggle_all_folds(app)
  end
end

#refreshObject



37
38
39
40
# File 'lib/rspec_telemetry/trace/viewer/screen/timeline_screen.rb', line 37

def refresh
  rebuild
  compute_durations
end

#source?Boolean

Returns:

  • (Boolean)


28
# File 'lib/rspec_telemetry/trace/viewer/screen/timeline_screen.rb', line 28

def source? = @document.actions.any?(&:source)

#time_bar?Boolean

Returns:

  • (Boolean)


27
# File 'lib/rspec_telemetry/trace/viewer/screen/timeline_screen.rb', line 27

def time_bar? = true

#time_bar_currentObject



70
71
72
73
74
75
# File 'lib/rspec_telemetry/trace/viewer/screen/timeline_screen.rb', line 70

def time_bar_current
  entry = current_entry
  return nil if entry.nil?

  entry.is_a?(Document::Action) ? entry.wall_ms : entry.fields["wall_ms"]
end

#titleObject



26
# File 'lib/rspec_telemetry/trace/viewer/screen/timeline_screen.rb', line 26

def title = nil