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
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mini_magick/shell.rb', line 28 def execute(command, = {}) stdout, stderr, status = log(command.join(" ")) do Timeout.timeout(MiniMagick.timeout) do send("execute_#{MiniMagick.shell_api.gsub("-", "_")}", command, ) end 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 24 25 26 |
# File 'lib/mini_magick/shell.rb', line 13 def run(command, = {}) stdout, stderr, status = execute(command, stdin: [:stdin]) case status when 1 fail MiniMagick::Error, "`#{command.join(" ")}` failed with error:\n#{stderr}" when 127 fail MiniMagick::Error, stderr end if .fetch(:whiny, MiniMagick.whiny) $stderr.print(stderr) unless [:stderr] == false [stdout, stderr, status] end |