Last active
November 9, 2015 13:47
-
-
Save maxim/63b0b51b661e833ce360 to your computer and use it in GitHub Desktop.
If ruby was in Russian
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| затребовать 'shellwords' | |
| затребовать 'posix/spawn' | |
| затребовать 'skeptick/error' | |
| модуль Skeptick | |
| класс Command | |
| атр_читатель :shellwords | |
| опр инициализировать(shellwords) | |
| @shellwords = shellwords | |
| конец | |
| опр в_с | |
| shellwords.соединить(' ') | |
| конец | |
| опр run(spawn_options = {}) | |
| opts = {} | |
| opts[:chdir] = Skeptick.cd_path.в_с если Skeptick.cd_path | |
| opts[:timeout] = Skeptick.timeout если Skeptick.timeout | |
| opts.слиться(spawn_options) | |
| если Skeptick.debug_mode? | |
| Skeptick.log("Skeptick Command: #{в_с}") | |
| конец | |
| im_process = POSIX::Spawn::Child.new(*shellwords, opts) | |
| если !im_process.success? | |
| вызвать ImageMagickError, | |
| "ImageMagick error\nCommand: #{в_с}\nSTDERR:\n#{im_process.err}" | |
| конец | |
| im_process.status | |
| конец | |
| конец | |
| конец |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'shellwords' | |
| require 'posix/spawn' | |
| require 'skeptick/error' | |
| module Skeptick | |
| class Command | |
| attr_reader :shellwords | |
| def initialize(shellwords) | |
| @shellwords = shellwords | |
| end | |
| def to_s | |
| shellwords.join(' ') | |
| end | |
| def run(spawn_options = {}) | |
| opts = {} | |
| opts[:chdir] = Skeptick.cd_path.to_s if Skeptick.cd_path | |
| opts[:timeout] = Skeptick.timeout if Skeptick.timeout | |
| opts.merge(spawn_options) | |
| if Skeptick.debug_mode? | |
| Skeptick.log("Skeptick Command: #{to_s}") | |
| end | |
| im_process = POSIX::Spawn::Child.new(*shellwords, opts) | |
| if !im_process.success? | |
| raise ImageMagickError, | |
| "ImageMagick error\nCommand: #{to_s}\nSTDERR:\n#{im_process.err}" | |
| end | |
| im_process.status | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Имена переменных и методов тоже нужно перевести.