module Ruby::Pomodoro

Constants

POMODORO_SIZE
REPEAT_ALERT_TIME
VERSION

Attributes

editor[R]
tasks_file_path[R]

Public Class Methods

start() click to toggle source
# File lib/ruby/pomodoro.rb, line 42
def start
  Worker.instance.then do |worker|
    add_observer(worker)
    worker.pomodoro_size = POMODORO_SIZE
  end

  @tasks_file_path = File.join(init_app_folder, "tasks")

  @editor = Tasks::Editor.new(file_path: tasks_file_path)
  editor.load
  Cmd::Main.new.call
  reader = TTY::Reader.new
  reader.subscribe(CommandController)
  loop do
    reader.read_char
  rescue => e
    Cmd::ErrorHandler.new.call(e)
  end
end

Private Class Methods

add_observer(worker) click to toggle source
# File lib/ruby/pomodoro.rb, line 64
def add_observer(worker)
  notify_ch = TerminalNotifierChannel
  pause_notification = Notification.new("Task is paused, resume?", notify_ch)
  stop_notification =
    Notification.new("Work is stopped, choose task for resume", notify_ch)

  worker.add_observer(
    NotificationObserver.new(
      stop: stop_notification, pause: pause_notification, time: REPEAT_ALERT_TIME
    )
  )
end
init_app_folder() click to toggle source
# File lib/ruby/pomodoro.rb, line 77
def init_app_folder
  path = File.join(Dir.home, ".ruby-pomodoro")
  unless Dir.exists?(path)
    Dir.mkdir(path)
  end
  path
end