Skip to content

Instantly share code, notes, and snippets.

@sashazykov
Created November 24, 2012 15:57
Show Gist options
  • Save sashazykov/4140273 to your computer and use it in GitHub Desktop.
Save sashazykov/4140273 to your computer and use it in GitHub Desktop.
Export tasks from Things to PlainTasks TODO file
# -*- encoding : utf-8 -*-
require 'rubygems'
require 'appscript'
OPEN_TASK_BULLET = "☐" # Valid: - ❍ ❑ ■ □ ☐ ▪ ▫ – — ≡ → ›
CLOSE_TASK_BULLET = "✔" # Valid: + ✓ ☑
things = Appscript.app('Things')
def write_todo todo
name = todo.name.get
notes = todo.notes.get
status = todo.status.get.to_s
out = " "
out += status == 'open' ? OPEN_TASK_BULLET : CLOSE_TASK_BULLET
out += ' '
out += name
if notes.size > 0
out += " - "
out += notes.gsub("\n", " / ").gsub(' ', ' ').gsub(/\[url=([^\[]+)\]([^\[]+)\[\/url\]/){|match| $1 }
end
case status
when 'completed'
out += " @done (#{todo.completion_date.get.strftime('%y-%m-%d %H:%M')})"
when 'canceled'
out += " @canceled (#{todo.cancellation_date.get.strftime('%y-%m-%d %H:%M')})"
when 'open'
else
out += " @#{status}"
end
puts out
end
puts "Inbox:"
things.lists[0].to_dos.get.each do |todo|
write_todo todo
end
puts "\nSomeday:"
things.lists[5].to_dos.get.each do |todo|
write_todo todo if todo.areas.get.to_s == 'missing_value' && todo.projects.get.to_s == 'missing_value'
end
things.projects.get.each do |project|
puts "\n" + project.name.get + ":"
project.to_dos.get.each do |todo|
write_todo todo
end
end
things.areas.get.each do |area|
puts "\n" + area.name.get + ":"
area.to_dos.get.each do |todo|
write_todo todo
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment