Created
July 11, 2011 05:38
-
-
Save allynbauer/1075357 to your computer and use it in GitHub Desktop.
a ruby script that uses applescript to build a git commit from taskpaper based on @done items
This file contains 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
rvm use 1.8.7 | |
ruby taskpaper_git_commit.rb ~/Desktop/TODO.taskpaper |
This file contains 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 | |
# MUST BE RUBY 1.8.7 | |
require 'rubygems' | |
require 'appscript' # sudo gem install rb-appscript | |
include Appscript | |
TaskPaper = app('TaskPaper') | |
if !TaskPaper.is_running? && ARGV.length > 0 | |
TaskPaper.launch | |
TaskPaper.open(ARGV[0]) | |
elsif TaskPaper.is_running? | |
TaskPaper.document.save | |
else | |
puts "TaskPaper is not running and no file to open provided; aborting" | |
exit | |
end | |
entries = TaskPaper.document.entries.get.flatten | |
done_entries = entries.select { |entry| entry.tags.get.any? { |tag| tag.name.get == "done" } } | |
if done_entries.empty? | |
puts "TaskPaper has no done tagged entries; aborting" | |
exit | |
end | |
git_message = done_entries.collect { |entry| "FIXED: #{entry.name.get}" }.join("\n") | |
puts "committing with message:\n#{git_message}\n" | |
system("git add .") | |
system("git commit -m \"#{git_message}\"") | |
done_entries.each { |entry| entry.delete } | |
TaskPaper.document.save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment