forked from JonJagger/cyber-dojo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
count.rb
68 lines (61 loc) · 1.64 KB
/
count.rb
1
2
3
4
5
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# A ruby script to display the count of
# dojos per day, dojos per language, and dojos per exercise
# to see the ids of all counted dojos (in their catagories)
# $ruby count.rb true
require './script_lib.rb'
show_ids = (ARGV[0] || "false")
stats = { }
languages = { }
exercises = { }
index('katas') do |kata_dir,id|
begin
manifest_filename = "#{kata_dir}/manifest.rb"
if File.exists? manifest_filename
begin
content = "# encoding: utf-8\n\n" + readfile(manifest_filename)
manifest = eval content
created = Time.mktime(*manifest[:created])
ymd = [created.year, created.month, created.day, created.strftime('%a')]
stats[ymd] ||= 0
stats[ymd] += 1
language = manifest[:language]
languages[language] ||= [ ]
languages[language] << id
exercise = manifest[:exercise]
exercises[exercise] ||= [ ]
exercises[exercise] << id
rescue Exception => e
puts "Exception from #{kata_dir}"
end
end
rescue Exception => e
puts "---->Exception raised for #{kata_dir}: #{e.message}"
end
end
puts ""
puts "dojos per day"
puts "-------------"
stats.sort.each do |ymdw,n|
puts ymdw.inspect + "\t" + n.to_s
end
puts ""
puts "dojos per language"
puts "------------------"
languages.sort.each do |language,n|
if show_ids == "true"
puts language + "\t" + n.to_s
else
puts n.length.to_s + "\t" + language
end
end
puts ""
puts "dojos per exercise"
puts "------------------"
exercises.sort.each do |exercise,n|
if show_ids == "true"
puts exercise + "\t" + n.to_s
else
puts n.length.to_s + "\t" + exercise
end
end
puts ""