Class: Shred::Commands::ShellCommandRunner
- Inherits:
-
Object
- Object
- Shred::Commands::ShellCommandRunner
- Defined in:
- lib/shred/commands/base.rb
Instance Attribute Summary collapse
-
#console ⇒ Object
readonly
Returns the value of attribute console.
Instance Method Summary collapse
-
#initialize(console: console) ⇒ ShellCommandRunner
constructor
A new instance of ShellCommandRunner.
- #run(shell_command) ⇒ Object
Constructor Details
#initialize(console: console) ⇒ ShellCommandRunner
Returns a new instance of ShellCommandRunner.
90 91 92 |
# File 'lib/shred/commands/base.rb', line 90 def initialize(console: console) @console = console end |
Instance Attribute Details
#console ⇒ Object (readonly)
Returns the value of attribute console.
88 89 90 |
# File 'lib/shred/commands/base.rb', line 88 def console @console end |
Instance Method Details
#run(shell_command) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/shred/commands/base.rb', line 94 def run(shell_command) exit_status = shell_command.run do |command_line| console.say_trace(command_line) command_line.run end if exit_status.success? if shell_command.success_msg console.say_ok(shell_command.success_msg) end elsif if shell_command.error_msg console.say_err("#{shell_command.error_msg}: #{exit_status}") else console.say_err(exit_status) end end end |