Module: Ghostbuster::Shell
- Included in:
- Ghostbuster
- Defined in:
- lib/ghostbuster/shell.rb
Instance Method Summary collapse
Instance Method Details
#sh(cmd, &block) ⇒ Object
3 4 5 6 |
# File 'lib/ghostbuster/shell.rb', line 3 def sh(cmd, &block) out, code = sh_with_code(cmd, &block) code == 0 ? out : raise(out.empty? ? "Running `#{cmd}' failed. Run this command directly for more detailed output." : out) end |
#sh_with_code(cmd, &block) ⇒ Object
8 9 10 11 12 |
# File 'lib/ghostbuster/shell.rb', line 8 def sh_with_code(cmd, &block) outbuf = `#{cmd}` block.call(outbuf) if block && $? == 0 [outbuf, $?] end |