Skip to content

Instantly share code, notes, and snippets.

@vaclavbohac
Created June 26, 2013 19:33
Show Gist options
  • Save vaclavbohac/5870789 to your computer and use it in GitHub Desktop.
Save vaclavbohac/5870789 to your computer and use it in GitHub Desktop.
First raw version of desktop GitHub notifications
require "octokit"
require "libnotify"
def get_notification_type type
if type == "PullRequest"
"Pull Request"
else
type
end
end
def get_summary notification
"GitHub " + get_notification_type(notification.subject.type)
end
def show_notification(notification)
Libnotify.show :summary => get_summary(notification), :body => notification.subject.title, :icon_path => '/home/wopice/repo/r/github-notifications/octocat.png'
end
# @return [Array<Hashie::Mash>] Array of notifications.
def get_github_notifications(client)
client.notifications({all: true, since: '2013-06-22T23:39:01Z'})
end
def authenticate(login, password)
Octokit::Client.new(:login => login, :password => password)
end
if __FILE__ == $0
client = authenticate("username", "password")
notifications = get_github_notifications(client)
notifications.each do |notification|
show_notification notification
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment