Ruby interface to GitHub API
Posted by admin, Sat Apr 18 01:11:00 UTC 2009
Update: I have made major updates to this API, take a look at this new article.
I spent the last couple of hours baking a Ruby wrapper for the GitHub API v2.
Right now their API interface appears to be down, so I wanted to put this out there and open up for forking.
Here is an example of how the API works:
DSL flavor (work in progress)
include Octopi connect "fcoury", "<<user-token>>" do |git| # the contents of the key whose title is "Local Server" puts git.keys.find { |k| k.title == "Local Server" }.key # prints current user name puts git.user.name # sets user name to Fernanda # and saves it on GitHub git.user.name = "Fernanda" git.user.save end |
API flavor
# initializes the API and authenticates the user github = Octopi::Api.new('fcoury', '<<user-token>>') # the contents of the key whose title is "Local Server" puts github.keys.find { |k| k.title == "Local Server" }.key # retrieves current user information and prints the name user = github.user puts user.name # sets user name to Fernanda # and saves it on GitHub user.name = "Fernanda" user.save |
For it away here:
http://github.com/fcoury/octopi