Class: Dplyr::Report
Instance Attribute Summary collapse
Instance Method Summary
collapse
#debug?, #logger, stderr, #stderr
Constructor Details
#initialize(hosts, exit_statuses, messages) ⇒ Report
Returns a new instance of Report.
8
9
10
11
12
|
# File 'lib/dplyr/report.rb', line 8
def initialize(hosts, exit_statuses, messages)
@hosts = hosts
@exit_statuses = exit_statuses
@messages = messages
end
|
Instance Attribute Details
#exit_statuses ⇒ Object
Returns the value of attribute exit_statuses.
6
7
8
|
# File 'lib/dplyr/report.rb', line 6
def exit_statuses
@exit_statuses
end
|
#hosts ⇒ Object
Returns the value of attribute hosts.
6
7
8
|
# File 'lib/dplyr/report.rb', line 6
def hosts
@hosts
end
|
Instance Method Details
#failed ⇒ Object
28
29
30
31
32
|
# File 'lib/dplyr/report.rb', line 28
def failed
@failed ||= exit_statuses.keys.select do |k|
exit_statuses[k] != 0
end
end
|
#print_failed_jobs ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/dplyr/report.rb', line 44
def print_failed_jobs
return if failed.count == 0
puts "failed".red
failed.each do |host|
puts " - #{host[:id]}"
end
end
|
#print_full ⇒ Object
15
16
17
18
19
20
|
# File 'lib/dplyr/report.rb', line 15
def print_full
logger.marker "summary_start"
print_successful_jobs
print_failed_jobs
print_summary
end
|
#print_successful_jobs ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/dplyr/report.rb', line 34
def print_successful_jobs
puts "succeeded".green
succeeded.each do |host|
messages = @messages[host]
puts " - #{host[:id]}:"
next if not messages.is_a? Array
messages.each { |m| puts " #{m}"}
end
end
|
#print_summary ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/dplyr/report.rb', line 53
def print_summary
total_hosts = hosts.count
run_count = @exit_statuses.count
not_run = total_hosts - run_count
if (failed.count > 0 || not_run > 0 )
not_run_error = "not run on #{not_run} of #{total_hosts} hosts" if not_run > 0
failed_error = "failed on #{failed.count} of #{total_hosts} hosts" if failed.count > 0
errors = []
errors << not_run_error if not_run_error
errors << failed_error if failed_error
error_str = "task #{errors.join(", ")}"
raise ::Dply::Error, error_str
end
puts "tasks ran successfully on #{succeeded.count}/#{total_hosts} hosts"
end
|
#succeeded ⇒ Object
22
23
24
25
26
|
# File 'lib/dplyr/report.rb', line 22
def succeeded
@succeeded ||= exit_statuses.keys.select do |k|
exit_statuses[k] == 0
end
end
|