Module: Bookbinder::ShellOut
- Included in:
- GitHubRepository
- Defined in:
- lib/bookbinder/shell_out.rb
Instance Method Summary collapse
- #announce_failure(failure_okay, stderr, stdout) ⇒ Object
- #shell_out(command, failure_okay = false) ⇒ Object
Instance Method Details
#announce_failure(failure_okay, stderr, stdout) ⇒ Object
13 14 15 16 17 |
# File 'lib/bookbinder/shell_out.rb', line 13 def announce_failure(failure_okay, stderr, stdout) contents_of_stderr = stderr.read = contents_of_stderr.empty? ? stdout.read : contents_of_stderr raise "\n#{error_message}" unless failure_okay end |
#shell_out(command, failure_okay = false) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/bookbinder/shell_out.rb', line 5 def shell_out(command, failure_okay = false) Open3.popen3(command) do |input, stdout, stderr, wait_thr| command_failed = (wait_thr.value != 0) announce_failure(failure_okay, stderr, stdout) if command_failed stdout.read end end |