Class: Reviewer::Runner::Strategies::Captured
- Inherits:
-
Object
- Object
- Reviewer::Runner::Strategies::Captured
- Defined in:
- lib/reviewer/runner/strategies/captured.rb
Overview
Execution strategy for a runner to run a command quietly by capturing the output and only
displaying it if there's a failure that justifies it
Instance Attribute Summary collapse
-
#runner ⇒ Runner
readonly
the instance of the runner that will be executed with this strategy.
-
#start_time ⇒ Time
readonly
the start time for the strategy_for timing purposes.
Instance Method Summary collapse
-
#initialize(runner) ⇒ self
constructor
Create an instance of the captured strategy for a command runner so that any output is fully suppressed so as to not create too much noise when running multiple commands.
-
#prepare ⇒ void
The prepare command strategy when running a command and capturing the results.
-
#run ⇒ void
The run command strategy when running a command and capturing the results.
Constructor Details
#initialize(runner) ⇒ self
Create an instance of the captured strategy for a command runner so that any output is
fully suppressed so as to not create too much noise when running multiple commands.
18 19 20 21 |
# File 'lib/reviewer/runner/strategies/captured.rb', line 18 def initialize(runner) @runner = runner @start_time = Time.now end |
Instance Attribute Details
#runner ⇒ Runner (readonly)
the instance of the runner that will be executed with this strategy
10 11 12 |
# File 'lib/reviewer/runner/strategies/captured.rb', line 10 def runner @runner end |
#start_time ⇒ Time (readonly)
the start time for the strategy_for timing purposes
10 11 12 |
# File 'lib/reviewer/runner/strategies/captured.rb', line 10 def start_time @start_time end |
Instance Method Details
#prepare ⇒ void
This method returns an undefined value.
The prepare command strategy when running a command and capturing the results
26 27 28 29 30 31 32 33 |
# File 'lib/reviewer/runner/strategies/captured.rb', line 26 def prepare command = runner.prepare_command display_progress(command) { runner.shell.capture_prep(command) } # Running the prepare command, so make sure the timestamp is updated runner.update_last_prepared_at end |
#run ⇒ void
This method returns an undefined value.
The run command strategy when running a command and capturing the results
38 39 40 41 42 43 44 45 46 |
# File 'lib/reviewer/runner/strategies/captured.rb', line 38 def run command = runner.command display_progress(command) { runner.shell.capture_main(command) } # If it's successful, show that it was a success and how long it took to run, otherwise, # it wasn't successful and we got some explaining to do... runner.success? ? show_timing_result : show_command_output end |