-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_lists.rb
executable file
·35 lines (35 loc) · 1.12 KB
/
get_lists.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env ruby
# ENV['TM_GTD_CONTEXT'] = "email home office online writing errand reading someday programming"
# ENV['TM_GTD_DIRECTORY'] = "/Users/haris/Documents/MyGTD"
# ENV['TM_BUNDLE_SUPPORT'] = '/Users/haris/Library/Application Support/TextMate/Bundles/GTDAlt.tmbundle/Support'
require File.join(File.dirname(__FILE__),'GTD.rb')
include GTD
GTD.process_directory
all_actions = GTD.actions
contexts = GTD.get_contexts
contxts = []
def esc(str)
str.gsub('"','\\"')
end
for context in contexts
# puts context
ar = "{context:\"#{context}\",actions:{"
actions = all_actions.find_all{ |a| a.context == context}
acts = []
for act in actions
it = "{action:\"#{esc(act.name)}\""
unless act.due.nil? then
it << ",#{act.due_type || 'due'}date:\"#{act.due}\""
end
unless act.note.nil? or act.note == "" then
it << ",nte:\"#{esc(act.note)}\""
end
it << ",completed:\"#{act.completed? ? 'yes' : 'no'}\""
it << ",link:\"#{act.txmt}\",file:\"#{act.file}\",line:\"#{act.line}\""
it << "}"
acts << it
end
ar << acts.join(",") << "}}"
contxts << ar
end
puts "{" + contxts.join(",") + "}"