Created
June 25, 2015 14:45
-
-
Save masnick/56389a686c2a3dacbb08 to your computer and use it in GitHub Desktop.
LaunchBar 6 Action for posting to iDoneThis
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
#!/Users/max/.rbenv/versions/2.1.3/bin/ruby | |
# ^^^ Note that this is custom to my computer. | |
# Necessary for loading from Gemfile without `bundle exec` | |
# Use `bundle install --standalone` to get this file | |
# Won't work if there are spaces in the path to the folder with the Gemfile? | |
# I had to copy the Gemfile to my desktop and run this there. | |
require File.join(File.expand_path('..', __FILE__), 'bundle/bundler/setup') | |
require 'json' | |
require 'idonethis' | |
client = IDoneThis::Client.new("api-key-here") | |
done = client.done(ARGV.join(" "), 'team-short-name-here') | |
if done.has_key? 'errors' | |
error_for_applescript = done['errors'].to_json.gsub(/\\/, '\\').gsub('"', '\"') | |
`osascript -e 'tell application "LaunchBar" to display alert "Could not post to iDoneThis" message "Error: #{error_for_applescript}"'` | |
else | |
puts [{"title" => "Posted!", "url" => done['permalink']}].to_json | |
end |
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
source "https://rubygems.org" | |
gem 'json' | |
gem 'idonethis' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment