Sha256: 4c4ea2713d8c173e433da99e32903bfa19c6a1ab6e312c6b276beeafb2fc8190
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
class ImageOptimizer class ImageOptimizerBase include Shell attr_reader :path, :options def initialize(path, options = {}) @path = path @options = options end def optimize return if ignore? return unless correct_format? if optimizer_bin? perform_optimizations else warn "Attempting to optimize a #{type} without #{bin_name} installed. Skipping..." end end private def correct_format? extensions.include?(options[:identified_format] || extension(path)) end def extension(path) path.split('.').last.downcase end def perform_optimizations system(optimizer_bin, *command_options) end def optimizer_bin? !!optimizer_bin end def optimizer_bin ENV["#{bin_name.upcase}_BIN"] || which(bin_name) end def quiet? options[:quiet] || ImageOptimizer.quiet end def ignore? ignore.include? bin_name end def ignore options[:ignore] ? [options[:ignore]].flatten.map(&:to_s) : [] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
image_optimizer-1.9.0 | lib/image_optimizer/image_optimizer_base.rb |