Class: Skeptick::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/skeptick/command.rb

Defined Under Namespace

Modules: Executable

Instance Method Summary collapse

Constructor Details

#initialize(command_obj) ⇒ Command

Returns a new instance of Command.



19
20
21
# File 'lib/skeptick/command.rb', line 19

def initialize(command_obj)
  @command_obj = command_obj
end

Instance Method Details

#commandObject Also known as: to_s



23
24
25
# File 'lib/skeptick/command.rb', line 23

def command
  @command_obj.to_s.shellsplit.shelljoin
end

#run(spawn_options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/skeptick/command.rb', line 28

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: #{command}")
  end

  im_process = POSIX::Spawn::Child.new(command, opts)

  if !im_process.success?
    raise ImageMagickError,
      "ImageMagick error\nCommand: #{command}\nSTDERR:\n#{im_process.err}"
  end

  im_process.status
end