Class: Overcommit::Reporter
- Inherits:
-
Object
- Object
- Overcommit::Reporter
show all
- Includes:
- ConsoleMethods
- Defined in:
- lib/overcommit/reporter.rb
Instance Method Summary
collapse
#bold, #error, #notice, #success, #warning
Constructor Details
#initialize(name, checks) ⇒ Reporter
Returns a new instance of Reporter.
5
6
7
8
9
10
|
# File 'lib/overcommit/reporter.rb', line 5
def initialize(name, checks)
@name = name
@checks = checks
@width = 70 - (@checks.map { |s| s.name.length }.max || 0)
@results = []
end
|
Instance Method Details
22
23
24
|
# File 'lib/overcommit/reporter.rb', line 22
def
puts "Running #{@name} checks"
end
|
#print_result ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/overcommit/reporter.rb', line 26
def print_result
puts
case final_result
when :good
success "+++ All #{@name} checks passed"
exit 0
when :bad
error "!!! One or more #{@name} checks failed"
exit 1
when :stop
warning "*** One or more #{@name} checks needs attention"
warning "*** If you really want to commit, use SKIP_CHECKS"
warning "*** (takes a space-separated list of checks to skip, or 'all')"
exit 1
end
end
|
#with_status(check, &block) ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/overcommit/reporter.rb', line 12
def with_status(check, &block)
title = " Checking #{check.name}..."
print title unless check.stealth?
status, output = yield
print_incremental_result(title, status, output, check.stealth?)
@results << status
end
|