Class: InspecPlugins::Parallelism::SuperReporter::Status
- Defined in:
- lib/plugins/inspec-parallel/lib/inspec-parallel/super_reporter/status.rb
Instance Attribute Summary collapse
-
#slots ⇒ Object
readonly
Returns the value of attribute slots.
-
#status_by_pid ⇒ Object
readonly
Returns the value of attribute status_by_pid.
Instance Method Summary collapse
- #child_exited(pid) ⇒ Object
- #child_forked(pid, invocation) ⇒ Object
-
#child_spawned(pid, invocation) ⇒ Object
——– SuperReporter API ——–.
- #child_status_update_line(pid, update_line) ⇒ Object
-
#initialize(job_count, invocations) ⇒ Status
constructor
A new instance of Status.
Constructor Details
#initialize(job_count, invocations) ⇒ Status
Returns a new instance of Status.
9 10 11 12 13 14 |
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/super_reporter/status.rb', line 9 def initialize(job_count, invocations) @status_by_pid = {} @slots = Array.new(job_count) paint_header(job_count, invocations) paint end |
Instance Attribute Details
#slots ⇒ Object (readonly)
Returns the value of attribute slots.
7 8 9 |
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/super_reporter/status.rb', line 7 def slots @slots end |
#status_by_pid ⇒ Object (readonly)
Returns the value of attribute status_by_pid.
7 8 9 |
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/super_reporter/status.rb', line 7 def status_by_pid @status_by_pid end |
Instance Method Details
#child_exited(pid) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/super_reporter/status.rb', line 27 def child_exited(pid) slots[status_by_pid[pid][:slot]] = "exited" status_by_pid[pid][:pct] = 100.0 status_by_pid[pid][:slot] = nil status_by_pid[pid][:exit] = $? # TODO: consider holding slot in 100 status for UI grace paint end |
#child_forked(pid, invocation) ⇒ Object
23 24 25 |
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/super_reporter/status.rb', line 23 def child_forked(pid, invocation) new_child("forked", pid, invocation) end |
#child_spawned(pid, invocation) ⇒ Object
SuperReporter API
19 20 21 |
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/super_reporter/status.rb', line 19 def child_spawned(pid, invocation) new_child("spawned", pid, invocation) end |
#child_status_update_line(pid, update_line) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/plugins/inspec-parallel/lib/inspec-parallel/super_reporter/status.rb', line 39 def child_status_update_line(pid, update_line) control_serial, status, control_count, title = update_line.split("/") percent = 100.0 * control_serial.to_i / control_count.to_i.to_f status_by_pid[pid][:pct] = percent status_by_pid[pid][:last_control] = title status_by_pid[pid][:last_status] = status sleep 0.5 paint end |