Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save levycarneiro/282462 to your computer and use it in GitHub Desktop.
Save levycarneiro/282462 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'httparty'
require 'time'
require 'active_support'
File.read("#{ENV['HOME']}/.gitconfig").match(/token = (\w+)/)
TOKEN = $1
class Github
include HTTParty
base_uri 'http://github.com/api/v1/xml'
default_params :login => 'jnunemaker', :token => TOKEN
format :xml
def self.commits(username_project, page=1)
p "Getting page #{page} of commits"
get("/#{username_project}/commits/master", :query => {:page => page})['commits']
end
end
# I knew I had 14 pages so I used 1..14.
(1..14).inject([]) do |collection, page|
collection.push *Github.commits('orderedlist/harmony', page)
end.group_by do |commit|
Time.parse(commit['committed_date']).beginning_of_month
end.each do |group|
p "#{group[0]}: #{group[1].size}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment