class SidekiqSpy::Display::Screen

Constants

CURSES_GETCH_TIMEOUT

Attributes

height[R]
width[R]

Public Class Methods

new() click to toggle source
# File lib/sidekiq-spy/display/screen.rb, line 13
def initialize
  Curses.init_screen
  Curses.nl
  Curses.noecho
  Curses.curs_set(0)
  Curses.timeout = CURSES_GETCH_TIMEOUT
  
  @height = term_height
  @width  = term_width
  
  @panels = { # attach panels, defining height, width, top, left
    :header        => Display::Panels::Header.new(      1, @width, 0, 0),
    :redis_stats   => Display::Panels::RedisStats.new(  3, @width, 1, 0),
    :sidekiq_stats => Display::Panels::SidekiqStats.new(2, @width, 5, 0),
  }
  
  self.panel_main = :workers
  
  Curses.refresh
rescue
  close
  
  raise
end

Public Instance Methods

close() click to toggle source
# File lib/sidekiq-spy/display/screen.rb, line 38
def close
  @panels.each { |pname, panel| panel.close } if @panels
  
  Curses.close_screen
end
missized?() click to toggle source
# File lib/sidekiq-spy/display/screen.rb, line 52
def missized?
  @height != term_height || @width != term_width
end
next_key() click to toggle source
# File lib/sidekiq-spy/display/screen.rb, line 48
def next_key
  Curses.getch
end
panel_main() click to toggle source
# File lib/sidekiq-spy/display/screen.rb, line 56
def panel_main
  @panels[:header].panel_main
end
panel_main=(pname) click to toggle source
# File lib/sidekiq-spy/display/screen.rb, line 60
def panel_main=(pname)
  @panels[:header].panel_main = pname
  
  @panels[:main].close if @panels[:main]
  
  @panels[:main] = case pname
  when :workers
    Display::Panels::Workers.new((@height - 8), @width, 8, 0)
  when :queues
    Display::Panels::Queues.new((@height - 8), @width, 8, 0)
  when :retries
    Display::Panels::Retries.new((@height - 8), @width, 8, 0)
  when :schedules
    Display::Panels::Schedules.new((@height - 8), @width, 8, 0)
  end
end
refresh() click to toggle source
# File lib/sidekiq-spy/display/screen.rb, line 44
def refresh
  @panels.each { |pname, panel| panel.refresh }
end

Private Instance Methods

term_height() click to toggle source
# File lib/sidekiq-spy/display/screen.rb, line 79
def term_height
  (ENV['LINES'] || Curses.lines).to_i
end
term_width() click to toggle source
# File lib/sidekiq-spy/display/screen.rb, line 83
def term_width
  (ENV['COLUMNS'] || Curses.cols).to_i
end