Skip to content

Instantly share code, notes, and snippets.

@craigeley
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigeley/11335910 to your computer and use it in GitHub Desktop.
Save craigeley/11335910 to your computer and use it in GitHub Desktop.
Allows you to mirror Taskpaper enrties to BusyCal as Reminders
# Mirror TaskPaper Files in BusyCal by Craig Eley 2014
#!/usr/bin/env ruby
# encoding: utf-8
require 'time'
files = Dir["/Users/Path/To/Listacular/*.taskpaper"]
item = ''
due = ''
time = ''
content = ''
files.each do |file|
if File.exists?(file.strip)
f = File.open(file.strip, encoding: 'UTF-8')
project = File.basename(file).gsub(/.taskpaper/, ' ').strip
- # The "downcase" in the next line can be changed to "capitalize" if your Reminder Lists start with caps
proj = project.downcase
lines = f.read
f.close
lines.each_line do |line|
if line =~ /&/
line.gsub!(/&/, 'and')
end
if line =~ /@done/
next
end
if line !~ /@due/
/-\s(?<item>.*)/ =~ line
item = item.to_s.strip
item = item.gsub(/\s/, '%20').strip
tag = tag.to_s
if tag.length > 2
tag = tag
else tag = ''
end
if item.length > 1
content = "busycalevent://new/-#{item}%20%2F#{proj}"
%x{open "#{content}"}
end
end
if line !~ /@done/
/-\s(?<item>.*?)(#.*?\s|@)(due\((?<t>.*)\))/ =~ line
item = item.to_s.strip
item = item.gsub(/\s/, '%20').gsub(/:/, '%3A').gsub(/\//, '%2F').strip
t = t.to_s
if t.length > 3
date = Time.parse(t)
due = date.strftime("%B %d ")
due = due.gsub(/\s/, '%20')
content = "busycalevent://new/-#{item}%20#{due}%20%2F#{proj}"
%x{open "#{content}"}
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment