Class: Reviewer::Shell
- Inherits:
-
Object
- Object
- Reviewer::Shell
- Extended by:
- Forwardable
- Defined in:
- lib/reviewer/shell.rb,
lib/reviewer/shell/timer.rb,
lib/reviewer/shell/result.rb
Overview
Handles running, timing, and capturing results for a command
Defined Under Namespace
Instance Attribute Summary collapse
-
#captured_results ⇒ Object
readonly
Returns the value of attribute captured_results.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#timer ⇒ Object
readonly
Returns the value of attribute timer.
Instance Method Summary collapse
- #capture_main(command) ⇒ Object
- #capture_prep(command) ⇒ Object
-
#direct(command) ⇒ Integer
Run a command without capturing the output.
-
#initialize ⇒ Shell
constructor
Initializes a Reviewer shell for running and benchmarking commands, and capturing output.
Constructor Details
Instance Attribute Details
#captured_results ⇒ Object (readonly)
Returns the value of attribute captured_results.
13 14 15 |
# File 'lib/reviewer/shell.rb', line 13 def captured_results @captured_results end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
13 14 15 |
# File 'lib/reviewer/shell.rb', line 13 def result @result end |
#timer ⇒ Object (readonly)
Returns the value of attribute timer.
13 14 15 |
# File 'lib/reviewer/shell.rb', line 13 def timer @timer end |
Instance Method Details
#capture_main(command) ⇒ Object
41 42 43 |
# File 'lib/reviewer/shell.rb', line 41 def capture_main(command) timer.record_main { capture_results(command) } end |
#capture_prep(command) ⇒ Object
37 38 39 |
# File 'lib/reviewer/shell.rb', line 37 def capture_prep(command) timer.record_prep { capture_results(command) } end |
#direct(command) ⇒ Integer
Run a command without capturing the output. This ensures the results are displayed realtime if the command was run directly in the shell. So it keeps any color or other formatting that would be stripped out by capturing $stdout as a basic string.
31 32 33 34 35 |
# File 'lib/reviewer/shell.rb', line 31 def direct(command) command = String(command) result.exit_status = system(command) ? 0 : 1 end |