-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypechecker.rb
43 lines (37 loc) · 984 Bytes
/
typechecker.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
# typed: false
require 'rubygems'
require 'bundler/setup'
require 'sorbet-runtime'
require 'open3'
class Typechecker
class << self
def run_checks_on
output, status = Open3.capture2e('srb tc --ignore=.bundle/')
puts lineify(status_text("Static Check", status.success?))
puts "#{output}\n"
puts lineify("🎬 Start of runtime evaluation")
begin
yield
rescue => exc
puts "\n#{lineify("❌ Runtime check")}"
raise exc.to_s # it shortens the stacktrace so it looks better
end
puts "#{lineify("🔚 End of runtime evaluation")}\n\n"
puts lineify("✅ Runtime check")
end
private
def status_text(str, success)
if success
"✅ #{str}"
else
"❌ #{str}"
end
end
def lineify(str, line_len = 50)
str_len = str.length
spacer_count = (line_len - str_len)/2
spacer = "-"*spacer_count
"#{spacer} #{str} #{spacer}"
end
end
end