Skip to content

Instantly share code, notes, and snippets.

@jkatz
Forked from anthonycintron/GithubAPI.rb
Created July 23, 2010 02:46
Show Gist options
  • Save jkatz/486935 to your computer and use it in GitHub Desktop.
Save jkatz/486935 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'json'
class GithubAPI
HOST = "github.com"
API = "/api/v2"
attr_accessor :format
attr_reader :response, :user
def initialize(username, token, params={})
@username, @token = username, token
@format = params[:format] || "json"
end
def api
API
end
def get_user_info(username, token)
path = [api,format,'user','show'].join('/')
connect(path, username, token)
end
def get_all_commit_history(value)
end
def host
HOST
end
private
def connect(path, username, token)
params = { :token => token, :login => username }
query = params.map { |k,v| "k=v" }.join('&')
Net::HTTP.start(host) do |http|
req = Net::HTTP::Get.new("#{path}?#{query}")
@response = http.request(req)
@user = JSON.parse(@response.body)
end
end
end
@jkatz
Copy link
Author

jkatz commented Jul 23, 2010

Just a quick passthrough with my thoughts...nothing earth-shattering on my end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment