Guest User

Untitled

a guest
Jan 16th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. #gem install rb-scpt (ruby < 2.5.0)
  4. require 'rb-scpt'
  5.  
  6. APP = Appscript.app("Things3.app")
  7.  
  8. def inbox
  9. APP.lists.get.detect{|l| l.name.get == 'Inbox'}
  10. end
  11.  
  12. def todos
  13. inbox.to_dos.get
  14. end
  15.  
  16. def todo_texts
  17. todos.map do |todo|
  18. [todo.name.get + todo.notes.get]
  19. end.flatten
  20. end
  21.  
  22. def file_text
  23. todo_texts.select do |text|
  24. text.strip != ""
  25. end.join("\n")
  26. end
  27.  
  28. def filepath
  29. ENV['HOME'] + "/Desktop/inbox.txt"
  30. end
  31.  
  32. def write_to_file
  33. open(filepath, 'a') { |f|
  34. f.puts file_text
  35. }
  36. end
  37.  
  38. write_to_file
Add Comment
Please, Sign In to add comment