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 Method Summary collapse
Methods inherited from Base
#applicable_files, #description, #enabled?, #execute, #in_path?, #initialize, #name, #quiet?, #required?, #run?, #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::BinNotFoundError => e return :bad, "#{e.}. The image_optim gem is dependendent on this binary." end if optimized_images.any? return :bad, "The following images were optimized:\n" << optimized_images.join("\n") << "\nPlease add them to your commit." end :good end |