-
Notifications
You must be signed in to change notification settings - Fork 0
/
badges.rb
70 lines (61 loc) · 1.66 KB
/
badges.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
69
70
require "multi_json"
require_relative "badge_methods"
$paths = [
"windows",
"linux",
"macos",
"solaris",
"devel",
"release",
"r-devel-linux-x86_64-debian-clang",
"r-devel-linux-x86_64-debian-gcc",
"r-devel-linux-x86_64-fedora-clang",
"r-devel-linux-x86_64-fedora-gcc",
"r-devel-windows-x86_64",
"r-oldrel-macos-x86_64",
"r-oldrel-windows-x86_64",
"r-patched-linux-x86_64",
"r-release-linux-x86_64",
"r-release-macos-x86_64",
"r-release-windows-x86_64"]
def badge_create_type(package, type)
ignore = false
color = nil
d = MultiJson.load(File.read("jsons/%s.json" % package))
if type == "summary"
do_badge(package, ignore, color, d)
elsif type == "worst"
do_badge_worst(package, color, d)
else
return nil
end
end
def badge_create_flavor(package, flavor)
ignore = false
d = MultiJson.load(File.read("jsons/%s.json" % package))
do_badge_flavor(package, flavor, ignore, d)
end
def mkdir_if(path)
full_path = "svgs/badges/flavor/" + path
puts full_path
Dir.exist?(full_path) ? nil : Dir.mkdir(full_path)
end
def make_svgs
pkgs = []
File.open("names.txt", "r") do |f|
f.each_line do |line|
pkgs << line.chomp.gsub(/"/, '')
end
end
$paths.map { |e| mkdir_if(e) }
pkgs.map { |pkg|
svg = badge_create_type(pkg, 'summary')
File.open("svgs/badges/summary/" + pkg + ".svg", 'w') { |f| f.puts svg }
svg = badge_create_type(pkg, 'worst')
File.open("svgs/badges/worst/" + pkg + ".svg", 'w') { |f| f.puts svg }
$paths.map { |path|
svg = badge_create_flavor(pkg, path)
File.open("svgs/badges/flavor/%s/" % path + pkg + ".svg", 'w') { |f| f.puts svg }
}
}
end