Class: GithubAnalyze::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/github_analyze/cli.rb

Instance Method Summary collapse

Instance Method Details

#csv(organization, file_path) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# 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