Skip to content

Instantly share code, notes, and snippets.

@jamesridgway
Created November 11, 2017 21:22
Show Gist options
  • Save jamesridgway/b9c3018176d986fefd01699af694f4e8 to your computer and use it in GitHub Desktop.
Save jamesridgway/b9c3018176d986fefd01699af694f4e8 to your computer and use it in GitHub Desktop.
List language and byte count statistics for all GitHub repositories
require 'octokit'
client = Octokit::Client.new(:access_token => ENV['GITHUB_ACCESS_TOKEN'])
repos = client.repos({}, query: {type: 'owner', sort: 'asc'}).select { |repo| !repo.fork }
language_stats = {}
repos.each do |repo|
repo_id = "#{repo.owner.login}/#{repo.name}"
repo_languages = client.languages(repo_id).to_h
language_stats.merge!(repo_languages){ |k, a_value, b_value| a_value + b_value }
end
language_stats.each do |language, bytes|
puts "#{language}: #{bytes}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment