Skip to content

Instantly share code, notes, and snippets.

@komasaru
Last active April 18, 2017 21:56
Show Gist options
  • Save komasaru/5835997 to your computer and use it in GitHub Desktop.
Save komasaru/5835997 to your computer and use it in GitHub Desktop.
Ruby script to get gist lists by octokit.
require 'octokit'
# API 呼び出し回数
ratelimit = Octokit.ratelimit
ratelimit_remaining = Octokit.ratelimit_remaining
puts "Rate Limit Remaining: #{ratelimit_remaining} / #{ratelimit}"
puts
# インスタンス化
# ==== 認証無しの場合
gists = Octokit.gists("komasaru")
# ==== OAuth 認証の場合
# cl = Octokit::Client.new(login: "komasaru", oauth_token: "token_string")
# gists = cl.gists("komasaru")
# 値取得
gists.each do |gist|
file = Hash.new
gist.files.each {|k, v| file = v}
puts "[ #{file.filename} ]"
puts "\tUser : #{gist.user.login}"
puts "\tDescription : #{gist.description}"
puts "\tURL : #{gist.html_url}"
puts "\tPublic : #{gist.public}"
puts "\tLanguage : #{file.language}"
puts "\tID : #{gist.id}"
puts "\tCreated at : #{gist.created_at}"
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment