Class: WSDirector::ResultsHolder
- Inherits:
-
Object
- Object
- WSDirector::ResultsHolder
- Defined in:
- lib/wsdirector/results_holder.rb
Overview
Holds all results for all groups of clients
Instance Method Summary collapse
- #<<(result) ⇒ Object
- #groups ⇒ Object
-
#initialize ⇒ ResultsHolder
constructor
A new instance of ResultsHolder.
- #print_summary(printer: $stdout, colorize: false) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize ⇒ ResultsHolder
Returns a new instance of ResultsHolder.
6 7 8 |
# File 'lib/wsdirector/results_holder.rb', line 6 def initialize @groups = Concurrent::Map.new end |
Instance Method Details
#<<(result) ⇒ Object
37 38 39 |
# File 'lib/wsdirector/results_holder.rb', line 37 def <<(result) @groups[result.group] = result end |
#groups ⇒ Object
14 15 16 |
# File 'lib/wsdirector/results_holder.rb', line 14 def groups @groups.values end |
#print_summary(printer: $stdout, colorize: false) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/wsdirector/results_holder.rb', line 18 def print_summary(printer: $stdout, colorize: false) single_group = groups.size == 1 @groups.each do |group, result| color = result.success? ? :green : :red prefix = single_group ? "" : "Group #{group}: " msg = "#{prefix}#{result.total_count} clients, #{result.failures_count} failures\n" msg = msg.colorize(color) if colorize printer.puts(msg) unless result.success? print_errors(result.errors, printer: printer, colorize: colorize) printer.puts "\n" end end end |
#success? ⇒ Boolean
10 11 12 |
# File 'lib/wsdirector/results_holder.rb', line 10 def success? @groups.values.all?(&:success?) end |