Created
December 13, 2016 00:43
-
-
Save matiasgarciaisaia/d76c2d45a55c4174e491b889bdc6006f to your computer and use it in GitHub Desktop.
Dumping a repo's stargazers' information to a JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem "octokit", "~> 4.0" | |
gem "highline", "~> 1.7" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'octokit' | |
require 'highline/import' | |
username = ENV['GITHUB_USER'] || ask("GitHub user:") | |
password = ENV['GITHUB_PASSWORD'] || ask("Password:") {|q| q.echo = false} | |
repo = ENV['STARGAZERS_REPO'] || ask("Repo (org/repo):") | |
client = Octokit::Client.new login: username, password: password, auto_paginate: true | |
stargazers = client.stargazers(repo) | |
users = stargazers.map { |stargazer| | |
client.user(stargazer.login).to_hash | |
} | |
File.open("#{repo.sub '/', '_-_'}_stargazers.json", 'w') { |f| | |
f.puts users.to_json | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment