Module: ImageSqueeze::Utils

Defined in:
lib/image_squeeze/utils.rb

Class Method Summary collapse

Class Method Details

.image_utility_available?(bin, extension, raise_when_missing = false) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
11
12
# File 'lib/image_squeeze/utils.rb', line 3

def self.image_utility_available?(bin, extension, raise_when_missing = false)
  return true if system("which #{bin} > /dev/null")
  if raise_when_missing
    ImageSqueeze.logger.error("#{bin} utility is required for running ImageSqueeze, get it installed already")
    raise StandardError, "#{bin} utility is required for running ImageSqueeze, get it installed already"
  else
    ImageSqueeze.logger.warn("#{bin} utility could not be found, your #{extension} files won't be squeezed")
  end
  false
end