Skip to content

Instantly share code, notes, and snippets.

@JackBracken
Created June 10, 2013 00:01
Show Gist options
  • Save JackBracken/5745805 to your computer and use it in GitHub Desktop.
Save JackBracken/5745805 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'json'
require 'uri'
class GitHub < Plugin
def help(plugin, topic="")
"Github plugin, print information about github user"
end
def get_user_info(user_name)
uri = URI.parse("https://api.github.com/users/#{user_name}/events/public")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
result = JSON.parse(response.body)
puts "In their last push to github, #{user_name} pushed the following #{result[0]['payload']['commits'].length} commits to the reposiory #{result[0]['repo']['name']}."
result[0]['payload']['commits'].each do |i|
puts "\t- #{i['message']}"
end
end
end
plugin = GitHub.new
plugin.register("gh")
plugin.map 'user :name', :action => 'get_user_info'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment