Revisions
-
jkatz revised this gist
Jul 23, 2010 . 1 changed file with 28 additions and 18 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,29 +2,39 @@ 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 -
anthonycintron renamed this gist
Jul 23, 2010 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
anthonycintron created this gist
Jul 23, 2010 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ require 'net/http' require 'json' class GithubAPI attr_reader :response, :host, :api, :format def initialize @host = "github.com" @api = "/api/v2" @format = "json" end def get_user_info (user_name, password, token) connect "#{api}/#{format}/user/show/", user_name, password, token end def get_all_commit_history (value) end private def connect (command, user_name, password, token) Net::HTTP.start(@host) do |http| req = Net::HTTP::Get.new("#{command}#{user_name}?token='#{token}'") req.basic_auth user_name, password @response = http.request(req) @user = JSON.parse(@response.body) end end end