Class: ImageGenie::Verify

Inherits:
Command
  • Object
show all
Defined in:
lib/image_genie/verify.rb

Class Method Summary collapse

Methods inherited from Command

handle_errors

Class Method Details

.run(filename, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/image_genie/verify.rb', line 7

def self.run(filename, options={})
  raise(UnableToLocateBinaryError, 'identify') if path_for(:identify).blank?

  begin
    raise Errno::ENOENT,"#{filename}" unless File.exists?(filename)
  rescue Errno::ENOENT => e
    logger.error("#{self.name} #{e.message}")
    raise
  end      

  command = "#{path_for(:identify)} #{filename}"
  # We test for STDERR content        
  execute(command) do |pid,stdin,stdout,stderr|
    ignored, status = Process::waitpid2 pid    
    handle_errors(stderr,status,VerifyError)
  end
  
  return true
end