Created
January 8, 2018 13:09
-
-
Save ascruggs/c910adfa2607d1ff62dc680cfc5ada80 to your computer and use it in GitHub Desktop.
Write all todos in your inbox to a file on your desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#gem install rb-scpt (ruby < 2.5.0) | |
require 'rb-scpt' | |
APP = Appscript.app("Things3.app") | |
def inbox | |
APP.lists.get.detect{|l| l.name.get == 'Inbox'} | |
end | |
def todos | |
inbox.to_dos.get | |
end | |
def todo_texts | |
todos.map do |todo| | |
[todo.name.get + todo.notes.get] | |
end.flatten | |
end | |
def file_text | |
todo_texts.select do |text| | |
text.strip != "" | |
end.join("\n") | |
end | |
def filepath | |
ENV['HOME'] + "/Desktop/inbox.txt" | |
end | |
def write_to_file | |
open(filepath, 'a') { |f| | |
f.puts file_text | |
} | |
end | |
write_to_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment