Created
October 29, 2011 18:41
-
-
Save fxposter/1324914 to your computer and use it in GitHub Desktop.
This file contains 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
module Api | |
extend self | |
def repository(owner, name) | |
fetch("repos/show/#{owner}/#{name}")['repository'] | |
end | |
def organization(name) | |
fetch("organizations/#{name}/public_members") | |
end | |
def user(name) | |
fetch("user/show/#{name}")['user'] | |
end | |
private | |
def fetch(path) | |
uri = URI.parse("http://github.com/api/v2/json/#{path}") | |
response = Net::HTTP.get_response(uri) | |
ActiveSupport::JSON.decode(response.body) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment