class BladeRunner::Console::Tab
Attributes
content_window[R]
status_window[R]
window[R]
Public Class Methods
active()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 37 def active all.detect(&:active?) end
draw()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 23 def draw window.clear window.noutrefresh all.each(&:draw) end
install(options = {})
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 11 def install(options = {}) top = options[:top] @window = create_window(top: top, height: 3) top = @window.begy + @window.maxy + 1 @status_window = create_window(top: top, height: 1) top = @status_window.begy + @status_window.maxy + 1 @content_window = create_window(top: top) @content_window.scrollok(true) end
remove(id)
click to toggle source
Calls superclass method
BladeRunner::Model::remove
# File lib/blade_runner/interface/console_tab.rb, line 29 def remove(id) tab = find(id) tab.deactivate tab.window.close super draw end
stale()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 41 def stale threshold = Time.now - 2 all.select { |t| t.last_ping_at && t.last_ping_at < threshold } end
Public Instance Methods
activate()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 115 def activate return if active? if tab = tabs.active tab.deactivate end self.active = true draw tabs.status_window.addstr(session.to_s) tabs.status_window.noutrefresh tabs.content_window.addstr(session.test_results.to_s) tabs.content_window.noutrefresh end
activate_next()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 145 def activate_next tabs = tabs.all if tabs.last == self tabs.first.activate elsif tab = tabs[index + 1] tab.activate end end
activate_previous()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 155 def activate_previous tabs = tabs.all if tabs.first == self tabs.last.activate elsif tab = tabs[index - 1] tab.activate end end
active?()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 111 def active? active end
color()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 165 def color case status when "running" then colors.yellow when "finished" then colors.green when /fail/ then colors.red else colors.white end end
deactivate()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 132 def deactivate return unless active? self.active = false draw tabs.status_window.clear tabs.status_window.noutrefresh tabs.content_window.clear tabs.content_window.noutrefresh end
dot()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 95 def dot status == "pending" ? "○" : "●" end
draw()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 71 def draw window.clear active? ? draw_active : draw_inactive window.noutrefresh end
draw_active()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 77 def draw_active window.addstr "╔═══╗" window.addstr "║ " window.attron(color) window.addstr(dot) window.attroff(color) window.addstr(" ║") window.addstr "╝ ╚" end
draw_inactive()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 87 def draw_inactive window.addstr "\n" window.attron(color) window.addstr(" #{dot}\n") window.attroff(color) window.addstr "═════" end
height()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 51 def height 3 end
index()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 99 def index tabs.all.index(self) end
left()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 63 def left tabs.window.begx + index * width end
session()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 103 def session BR::Session.find(id) end
status()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 107 def status session.test_results.status end
tabs()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 47 def tabs self.class end
top()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 59 def top tabs.window.begy end
width()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 55 def width 5 end
window()
click to toggle source
# File lib/blade_runner/interface/console_tab.rb, line 67 def window @window ||= create_window(height: height, width: width, top: top, left: left) end