Produce a Markdown file enumerating the starred repos of a GitHub user (with HTML links) using the Unicorn API gem
# The 'github_api' gem is implicility assumed to have been loaded at this point... | |
# Configuration data is passed to Github::Client#new as a Hash whose keys are Symbols | |
CONFIG_DATA = { | |
user: 'github-username', | |
login: 'github-login-email@host.com', | |
oauth_token: 'personal-access-token' # one of many valid authentication methods (see the gem docs for more) | |
} | |
# Data is returned from the API as a Github::ResponseWrapper object | |
starred = Github.new(CONFIG_DATA).activity.starring.starred | |
File.open('path-to-output-dir/starred.md', 'w') do |f| | |
# By default, entries are dispensed 30-per-call. Thanks to helpers provided in Github::Paginate, the entire | |
# result set can be collated into a single Array; just call 'auto_paginate' with 'true' as parameter. | |
starred.auto_paginate(true).each do |r| | |
f.puts "- [#{r['full_name']}](#{r['html_url']})" # Markdown links are easy to generate | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment