-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.rb
83 lines (78 loc) · 2.24 KB
/
status.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
71
72
73
74
75
76
77
78
79
80
81
82
83
# encoding: utf-8
# The status of a bench.
require_relative 'black_list'
class Status
attr_reader :status
def initialize(name, version, status, dry_without_coq_output, deps_output, package_output)
black_listed = BlackList.any? do |black_list_item|
package_full_name, content = black_list_item
if package_full_name == "#{name}.#{version}" then
[dry_without_coq_output, deps_output, package_output].any? do |output|
output.include?(content)
end
else
false
end
end
dependencies_resolution_timeout_message = "[ERROR] Sorry, resolution of the request timed out."
with_dependencies_resolution_timeout =
dry_without_coq_output.include?(dependencies_resolution_timeout_message)
download_error_message = "[ERROR] The sources of the following couldn't be obtained, aborting:"
with_download_error = [deps_output, package_output].any? do |output|
output.include?(download_error_message)
end
zarith_reinstall_error_message = "ocamlfind: Package zarith is already installed"
with_zarith_reinstall_error = deps_output.include?(zarith_reinstall_error_message)
@status =
black_listed || with_dependencies_resolution_timeout || with_download_error || with_zarith_reinstall_error ?
"BlackList" :
status
end
# The color to display.
def css_class
case @status
when "Success"
"success"
when "NotCompatible"
"info"
when "DepsError"
"warning"
when "LintError", "Error", "UninstallError"
"danger"
when "BlackList"
"default"
else
raise "unknown status #{@status.inspect}"
end
end
# A number to classify and order a status.
def to_i
case @status
when "NotCompatible"
4
when "BlackList"
3
when "Success"
2
when "DepsError"
1
when "LintError", "Error", "UninstallError"
0
else
raise "unknown status #{@status}"
end
end
# A unicode symbol representing the error status.
def unicode_error_symbol
case @status
when "DepsError"
"🔶"
when "LintError", "Error", "UninstallError"
"❌"
when "NotCompatible", "Success", "BlackList"
nil
else
raise "unknown status #{@status}"
end
end
end