Created
June 9, 2010 22:04
-
-
Save citizen428/432255 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
require 'httparty' | |
class GitHub | |
include HTTParty | |
base_uri 'http://github.com/api/v2/yaml' | |
API_METHODS = { | |
:watched => '/repos/watched/' } | |
class << self | |
def show_watched | |
@user = ARGV[0] || 'citizen428' | |
get_watched_repos.shuffle.reject{ |r| r[:owner] == @user }.each do |r| | |
puts "%30s: %-55s (%d)" % | |
["#{r[:owner]}/#{r[:name]}", shorten_desc(r[:description]), r[:watchers]] | |
end | |
end | |
private | |
def get_watched_repos | |
self.get(API_METHODS[:watched]+@user)["repositories"] | |
end | |
def shorten_desc(str) | |
str.length < 50 ? str : str[0..49]+'...' | |
end | |
end | |
end | |
GitHub.show_watched |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I thought about that, but thought it might require a second look later to remember why.