Skip to content

Instantly share code, notes, and snippets.

@komasaru
Last active December 18, 2015 19:49
Show Gist options
  • Save komasaru/5835990 to your computer and use it in GitHub Desktop.
Save komasaru/5835990 to your computer and use it in GitHub Desktop.
Ruby script to get github repositories by octokit.
require 'octokit'
# API 呼び出し回数
ratelimit = Octokit.ratelimit
ratelimit_remaining = Octokit.ratelimit_remaining
puts "Rate Limit Remaining: #{ratelimit_remaining} / #{ratelimit}"
puts
# インスタンス化
# ==== 認証無しの場合
repos = Octokit.repositories("komasaru", {sort: :pushed_at})
# ==== OAuth 認証の場合
#cl = Octokit::Client.new(login: "komasaru", oauth_token: "token_string")
#repos = cl.repositories("komasaru", {sort: :pushed_at})
# 値取得
repos.each do |repo|
puts "[ #{repo.name} ]"
puts "\tOwner : #{repo.owner.login}"
puts "\tFull Name : #{repo.full_name}"
puts "\tDescription : #{repo.description}"
puts "\tPrivate : #{repo.private}"
puts "\tLanguage : #{repo.language}"
puts "\tURL : #{repo.html_url}"
puts "\tCreated at : #{repo.created_at}"
puts "\tUpdated at : #{repo.updated_at}"
puts "\tPushed at : #{repo.pushed_at}"
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment