Created
March 6, 2017 22:29
-
-
Save stengland/51c360b6fa9372fa4b7f825354f3684b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
require 'json' | |
require 'date' | |
wunderlist = JSON.parse(File.read ARGV[0]) | |
tasks, lists = wunderlist['data']["tasks"], wunderlist['data']["lists"] | |
tasks.map! do |task| | |
due_date = task["due_date"] | |
completed_at = Date.parse(task["completed_at"]).strftime if task["completed_at"] | |
list = lists.detect { |l| l['id'] == task['list_id'] } | |
project_title = (list ? list['title'] : 'inbox').split(' ').map(&:capitalize).join | |
completed = "x #{completed_at} " if completed_at | |
title = task['title'] | |
project = "+#{project_title}" | |
note = "- #{task['note'].gsub("\n", " ")}" if task['note'] | |
due = "due:#{due_date}" if due_date | |
recurrence = "rec:#{task['recurrence_count']}#{task['recurrence_type'][0]}" if task['recurrence_type'] | |
[completed, title, note, project, due, recurrence].compact.join(' ').squeeze(' ') | |
end | |
puts tasks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment