Class: Overcommit::Hook::PreCommit::ImageOptim
- Defined in:
- lib/overcommit/hook/pre_commit/image_optim.rb
Overview
Checks for images that can be optimized with ‘image_optim`.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#applicable_files, #description, #enabled?, #executable, #execute, #in_path?, #initialize, #name, #process_hook_return_value, #quiet?, #required?, #run?, #run_and_transform, #skip?
Constructor Details
This class inherits a constructor from Overcommit::Hook::Base
Instance Method Details
#run ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/overcommit/hook/pre_commit/image_optim.rb', line 4 def run begin require 'image_optim' rescue LoadError return :warn, 'image_optim not installed -- run `gem install image_optim`' end optimized_images = begin optimize_images(applicable_files) rescue ::ImageOptim::BinResolver::BinNotFound => e return :fail, "#{e.}. The image_optim gem is dependendent on this binary." end if optimized_images.any? return :fail, "The following images are optimizable:\n#{optimized_images.join("\n")}" \ "\n\nOptimize them by running:\n" \ " image_optim --skip-missing-workers #{optimized_images.join(' ')}" end :pass end |