mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
refactored to remove repeated code.
Signed-off-by: Aaron Lippold <lippold@gmail.com>
This commit is contained in:
parent
1150ef2d30
commit
ffd4706608
1 changed files with 12 additions and 18 deletions
|
@ -54,34 +54,28 @@ module InspecPlugins::StreamingReporterProgressBar
|
|||
end
|
||||
|
||||
def example_passed(notification)
|
||||
control_id = notification.example.metadata[:id]
|
||||
title = notification.example.metadata[:title]
|
||||
full_description = notification.example.metadata[:full_description]
|
||||
control_impact = notification.example.metadata[:impact]
|
||||
set_status_mapping(control_id, "passed")
|
||||
show_progress(control_id, title, full_description, control_impact) if control_ended?(control_id)
|
||||
set_example(notification, "passed")
|
||||
end
|
||||
|
||||
def example_failed(notification)
|
||||
control_id = notification.example.metadata[:id]
|
||||
title = notification.example.metadata[:title]
|
||||
full_description = notification.example.metadata[:full_description]
|
||||
control_impact = notification.example.metadata[:impact]
|
||||
set_status_mapping(control_id, "failed")
|
||||
show_progress(control_id, title, full_description, control_impact) if control_ended?(control_id)
|
||||
set_example(notification, "failed")
|
||||
end
|
||||
|
||||
def example_pending(notification)
|
||||
control_id = notification.example.metadata[:id]
|
||||
title = notification.example.metadata[:title]
|
||||
full_description = notification.example.metadata[:full_description]
|
||||
control_impact = notification.example.metadata[:impact]
|
||||
set_status_mapping(control_id, "skipped")
|
||||
show_progress(control_id, title, full_description, control_impact) if control_ended?(control_id)
|
||||
set_example(notification, "skipped")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_example(notification, status)
|
||||
@control_id = notification.example.metadata[:id]
|
||||
@title = notification.example.metadata[:title]
|
||||
@full_description = notification.example.metadata[:full_description]
|
||||
@control_impact = notification.example.metadata[:impact]
|
||||
set_status_mapping(@control_id, status)
|
||||
show_progress(@control_id, @title, @full_description, @control_impact) if control_ended?(@control_id)
|
||||
end
|
||||
|
||||
def show_progress(control_id, title, full_description, control_impact)
|
||||
@bar ||= ProgressBar.new(controls_count, :bar, :counter, :percentage)
|
||||
sleep 0.1
|
||||
|
|
Loading…
Reference in a new issue