6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/gitpoint/app.rb', line 6
def langstats
say Rainbow("Connecting to github & fetching organization\'s repos...").bright
repos = Git.new.fetch(:all, {org: options[:organization], visibility: 'public'})
if repos[:status] == 200
say Rainbow("Organization\'s repos fetched successfully!").green
else
say Rainbow("Something went wrong!").red
raise Error, Rainbow(repos[:error_message]).red
end
@repositories = repos[:response]
raise Error, Rainbow("Github API response is empty! Process cannot continue").red if @repositories.nil?
fetch_repository_names
@languages = []
say Rainbow("Fetching repos\'s languages...").bright
@repository_names.each do |repo|
repo_languages = Git.new.fetch(:list_languages, {user: options[:organization], repo: repo})
if repo_languages[:status] == 200
@languages << repo_languages[:response].keys unless repo_languages[:response].nil?
else
say Rainbow("Something went wrong!").red
raise Error, Rainbow(repos[:error_message]).red
end
end
say Rainbow("Computng results...").bright
calculate_language_appearance
results = {
"organization" => options[:organization],
"languages" => Hash[@language_hash.sort_by {|k, v| -v}]
}
say Rainbow(JSON.pretty_generate(results)).green
end
|