class GithubAnalyze::Cli
Public Instance Methods
csv(organization, file_path)
click to toggle source
# File lib/github_analyze/cli.rb, line 21 def csv(organization, file_path) CSV.open(file_path, 'wb') do |csv| csv << ['Repository', 'Language', 'Created At'] client.organization(name: organization).repositories.each do |repository| primary_language = repository.primary_language csv << [ repository.name, (primary_language ? primary_language.name : 'None'), repository.created_at ] end end end
stats(organization)
click to toggle source
# File lib/github_analyze/cli.rb, line 8 def stats(organization) languages = [] languages << ['Rank', 'Language', 'Repo Count'] client .organization(name: organization) .ranked_languages .each.with_index { |l, i| languages << [i, l[0], l[1]] } print_table languages end
Private Instance Methods
client()
click to toggle source
# File lib/github_analyze/cli.rb, line 38 def client if ENV['GITHUB_AUTHENTICATION_TOKEN'] GithubAnalyze::Client.new( github_authentication_token: ENV['GITHUB_AUTHENTICATION_TOKEN'] ) else say( "You must set GITHUB_AUTHENTICATION_TOKEN environment variable\ne.g. GITHUB_AUTHENTICATION_TOKEN=token github_analyze #{ARGV.join(' ')}", Thor::Shell::Color::RED ) exit end end