Skip to content

Instantly share code, notes, and snippets.

@kiyoto
Created November 1, 2015 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiyoto/830ba2de6f6511bc0459 to your computer and use it in GitHub Desktop.
Save kiyoto/830ba2de6f6511bc0459 to your computer and use it in GitHub Desktop.
Fetching GitHub Users
require 'octokit'
def check_email_validity(email)
if not email.is_a?(String)
return false
end
r = /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
if r.match(email)
true
else
false
end
end
puts ['github_project_name', 'github_user_name', 'Starred_at', 'Email', 'Company', 'Email_is_valid'].join("\t")
repo_path = 'apache/spark'
client = Octokit::Client.new(:login => 'github_user', :password => 'github_password')
user_client = Octokit::Client.new(:login => 'github_user', :password => 'github_password')
for stargazer in client.stargazers(repo_path, per_page:100, accept:'application/vnd.github.v3.star+json')
user_detail = user_client.user(stargazer.user.login)
puts [repo_path,stargazer.user.login, stargazer.starred_at, user_detail["email"], user_detail["company"], check_email_validity(user_detail["email"])].join("\t")
sleep 1
end
last_response = client.last_response
until last_response.rels[:next].nil?
last_response = last_response.rels[:next].get(headers: {accept: 'application/vnd.github.v3.star+json'})
for stargazer in last_response.data
user_detail = user_client.user(stargazer.user.login)
puts [repo_path,stargazer.user.login, stargazer.starred_at, user_detail["email"], user_detail["company"], check_email_validity(user_detail["email"])].join("\t")
sleep 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment