Class: MiniMagick::Shell
- Inherits:
-
Object
- Object
- MiniMagick::Shell
- Defined in:
- lib/mini_magick/shell.rb
Overview
Sends commands to the shell (more precisely, it sends commands directly to the operating system).
Instance Method Summary collapse
Instance Method Details
#execute(command, options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mini_magick/shell.rb', line 25 def execute(command, = {}) stdout, stderr, status = log(command.join(" ")) do send("execute_#{MiniMagick.shell_api.tr("-", "_")}", command, ) end [stdout, stderr, status.exitstatus] rescue Errno::ENOENT, IOError ["", "executable not found: \"#{command.first}\"", 127] end |
#run(command, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mini_magick/shell.rb', line 13 def run(command, = {}) stdout, stderr, status = execute(command, stdin: [:stdin]) if status != 0 && .fetch(:whiny, MiniMagick.whiny) fail MiniMagick::Error, "`#{command.join(" ")}` failed with status: #{status} and error:\n#{stderr}" end $stderr.print(stderr) unless [:stderr] == false [stdout, stderr, status] end |