class Object
Constants
- Pomodoro
- Task
Public Instance Methods
fetch_top_task()
click to toggle source
# File bin/tacgo, line 115 def fetch_top_task require 'mechanize' agent = Mechanize.new sign_in agent Task.parse(JSON(agent.get('https://tacoapp.com/tasks.json').body)[0]) end
sign_in(agent)
click to toggle source
# File bin/tacgo, line 127 def sign_in(agent) page = agent.get('https://tacoapp.com/tasks') login_form = page.form_with(id: 'new_user') credentials = Credentials.new login_form.field_with(name: 'user[email]').value = credentials.email login_form.field_with(name: 'user[password]').value = credentials.password page = agent.submit(login_form) raise 'bad credentials' unless signed_in?(page) end
signed_in?(page)
click to toggle source
# File bin/tacgo, line 123 def signed_in?(page) page.form_with(id: 'new_user').nil? end
start()
click to toggle source
# File bin/tacgo, line 84 def start task = fetch_top_task pomodoro = Pomodoro.new(task) pomodoro.start(store) progress = ProgressBar.create(title: task.label[0..40], total: pomodoro.duration, format: '%t: |%B| %p%%') Thread.abort_on_exception = true Thread.new(pomodoro, progress) do |pomodoro, progress| $stdin.echo = false Signal.trap('INT') { pomodoro.cancel } Signal.trap('QUIT') { pomodoro.restart } while pomodoro.active? progress.progress = pomodoro.progress sleep 0.1 end unless pomodoro.canceled? progress.finish pomodoro.complete store `osascript -e 'display notification "Pomodoro complete" with title "Pomodoro complete" sound name "Glass"'` end end.join end
store()
click to toggle source
# File bin/tacgo, line 111 def store @store ||= YAML::Store.new('tacgo.yaml') end