Skip to content

Instantly share code, notes, and snippets.

@postmodern
Created March 8, 2011 23:59
Show Gist options
  • Save postmodern/861401 to your computer and use it in GitHub Desktop.
Save postmodern/861401 to your computer and use it in GitHub Desktop.
Lists prior "art" (aka all of your repositories).
#!/usr/bin/env ruby
require 'net/http'
require 'json'
require 'date'
class PriorArt < Struct.new(:name,:description,:created_at,:updated_at)
end
prior_art = {}
ARGV.each do |user|
response = Net::HTTP.get(URI("http://github.com/api/v2/json/repos/show/#{user}"))
data = JSON.parse(response)
repos = data['repositories']
repos.each do |repo|
# skip forks
next if repo['fork']
# skip empty repos
next unless repo['pushed_at']
prior_art[repo['name']] = PriorArt.new(
repo['name'],
repo['description'],
Date.parse(repo['created_at']),
Date.parse(repo['pushed_at'])
)
end
end
prior_art.values.sort_by { |art| art.name }.each do |art|
puts "Name: #{art.name}"
puts "Date: #{art.created_at.year} - #{art.updated_at.year}"
puts "Description:\n\n"
puts "\t#{art.description}\n\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment