lib/fasten/ui/curses.rb in fasten-0.7.6 vs lib/fasten/ui/curses.rb in fasten-0.8.0
- old
+ new
@@ -7,12 +7,12 @@
module UI
class Curses
include ::Curses
extend Forwardable
- def_delegators :runner, :worker_list, :tasks, :worker_list
- def_delegators :runner, :name, :workers, :workers=, :state, :state=
+ def_delegators :runner, :workers, :tasks
+ def_delegators :runner, :name, :jobs, :jobs=, :state, :state=
attr_accessor :n_rows, :n_cols, :selected, :sel_index, :clear_needed, :message, :runner
SPINNER_STR = '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
SPINNER_LEN = SPINNER_STR.length
@@ -26,11 +26,11 @@
def update
setup unless @setup_done
ui_keyboard
clear if clear_needed
draw_title
- ui_workers
+ ui_jobs
ui_tasks
refresh
self.clear_needed = false
end
@@ -94,19 +94,19 @@
return unless (key = stdscr.getch)
self.message = nil
if key == Curses::Key::LEFT
- if workers <= 1
+ if jobs <= 1
self.message = "Can't remove 1 worker left, press [P] to pause"
else
- self.workers -= 1
- self.message = "Decreasing workers to #{workers}"
+ self.jobs -= 1
+ self.message = "Decreasing jobs to #{jobs}"
end
elsif key == Curses::Key::RIGHT
- self.workers += 1
- self.message = "Increasing workers to #{workers}"
+ self.jobs += 1
+ self.message = "Increasing jobs to #{jobs}"
elsif key == Curses::Key::DOWN
self.sel_index = sel_index ? [sel_index + 1, tasks.count - 1].min : 0
self.selected = tasks[sel_index]
elsif key == Curses::Key::UP
self.sel_index = sel_index ? [sel_index - 1, 0].max : tasks.count - 1
@@ -122,22 +122,22 @@
end
force_clear
end
- def ui_workers_summary
+ def ui_jobs_summary
running_count = tasks.running.count
waiting_count = tasks.waiting.count
- workers_count = worker_list.count
+ workers_count = workers.count
- "Procs running: #{running_count} idle: #{workers_count - running_count} waiting: #{waiting_count} #{runner.use_threads ? 'threads' : 'processes'}: #{workers}"
+ "Procs running: #{running_count} idle: #{workers_count - running_count} waiting: #{waiting_count} #{runner.use_threads ? 'threads' : 'processes'}: #{jobs}"
end
- def ui_workers
- l = ui_text_aligned(1, :left, ui_workers_summary) + 1
+ def ui_jobs
+ l = ui_text_aligned(1, :left, ui_jobs_summary) + 1
- worker_list.each_with_index do |worker, index|
+ workers.each_with_index do |worker, index|
setpos 1, l + index
attrs = worker.running? ? A_STANDOUT : color_pair(4) | A_DIM
attrset attrs
addstr worker.running? ? 'R' : '_'
attroff attrs
@@ -225,10 +225,10 @@
x + str.length
end
def ui_tasks
- worker_list.each do |worker|
+ workers.each do |worker|
worker.spinner = (worker.spinner + 1) % SPINNER_LEN if worker.running?
end
count_done = tasks.done.count
count_total = tasks.count