Skip to content

Instantly share code, notes, and snippets.

@crcastle
Last active December 26, 2021 18:20
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save crcastle/fc7189aa9e8acd3538fc to your computer and use it in GitHub Desktop.
Save crcastle/fc7189aa9e8acd3538fc to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
# Requirements:
# - rb-dayone and doing gems installed for the system Ruby.
# (Mine (OSX 10.10) are in /Library/Ruby/Gems/2.0.0/gems/)
#
# How to run:
# $./dayone-to-doing.rb 0A8BE4BB9F7E40B5A6F3F621797FC6F5.doentry
# The parameter passed to the script is the doentry file that was just created.
# The script will:
# 1) Parse the doentry
# 2) Check if it has the 'wwid' tag
# 3) If so, add it to your doing file in the default section
#
# So the overall flow for me is:
# 1) Set Day One to prompt me hourly from the menu bar
# 2) Setup this Ruby script to run when a new file is added to my Day One journal entries folder.
# Mine is at ~/Dropbox/Apps/Day One/Journal.dayone/entries. You can use either Hazel or
# Finder's built-in Folder Actions functionality to trigger the script with the doentry file as the first argument.
# 2) When Day One prompt appears, write what I've done over the past hour, end it with #wwid, and hit command+enter
# 3) Nothing! Any journal entry you write in Day One with the #wwid tag will show up in your doing file!
require 'rb-dayone'
require 'doing'
doentry = ARGV[0]
abort('doentry file not provided as first argument') unless doentry
entry = DayOne::EntryImporter.from_file(doentry).to_entry
if entry.tags.include? 'wwid'
doing = WWID.new
doing.init_doing_file
tagged_entry = entry.entry_text.gsub('#','@')
doing.add_item(tagged_entry, nil, {:back => entry.created_at.localtime})
doing.write(doing.doing_file)
else
abort('No #wwid tag')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment