Class: ImageOptim::Runner
- Inherits:
-
Object
- Object
- ImageOptim::Runner
- Defined in:
- lib/image_optim/runner.rb,
lib/image_optim/runner/glob_helpers.rb,
lib/image_optim/runner/option_parser.rb
Overview
Handling optimization using image_optim binary
Defined Under Namespace
Modules: GlobHelpers Classes: OptionParser, Results
Instance Method Summary collapse
-
#initialize(options) ⇒ Runner
constructor
A new instance of Runner.
- #run!(args) ⇒ Object
Constructor Details
#initialize(options) ⇒ Runner
Returns a new instance of Runner.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/image_optim/runner.rb', line 48 def initialize() = HashHelpers.deep_symbolise_keys() @recursive = .delete(:recursive) @progress = .delete(:show_progress) != false @exclude_dir_globs, @exclude_file_globs = %w[dir file].map do |type| glob = .delete(:"exclude_#{type}_glob") || '.*' GlobHelpers.(glob) end @image_optim = ImageOptim.new() end |
Instance Method Details
#run!(args) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/image_optim/runner.rb', line 59 def run!(args) to_optimize = find_to_optimize(args) unless to_optimize.empty? results = Results.new optimize_images!(to_optimize).each do |original, optimized| results.add(original, optimized) end results.print end !@warnings end |