Class: Middleman::Imageoptim::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman-imageoptim/options.rb

Overview

An options store that handles default options will accept user defined overrides

Constant Summary collapse

EXTENSION_OPTIONS =

Mapping of valid option names to default values

[
  :image_extensions,
  :manifest
].freeze
OPTIONS =
{
  advpng: { level: 4 },
  allow_lossy: false,
  gifsicle: { interlace: false },
  image_extensions: %w(.png .jpg .jpeg .gif .svg),
  jpegoptim: { strip: ['all'], max_quality: 100 },
  jpegtran: { copy_chunks: false, progressive: true, jpegrescan: true },
  nice: true,
  manifest: true,
  optipng: { level: 6, interlace: false },
  pack: true,
  pngcrush: { chunks: ['alla'], fix: false, brute: false },
  pngout: { copy_chunks: false, strategy: 0 },
  skip_missing_workers: true,
  svgo: {},
  threads: true,
  verbose: false
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(user_options = {}) ⇒ Options

Returns a new instance of Options.



32
33
34
# File 'lib/middleman-imageoptim/options.rb', line 32

def initialize(user_options = {})
  set_options(user_options)
end

Instance Method Details

#imageoptim_optionsObject



36
37
38
39
40
# File 'lib/middleman-imageoptim/options.rb', line 36

def imageoptim_options
  Hash[instance_variables.map do |name|
    [symbolize_key(name), instance_variable_get(name)]
  end].reject { |key| EXTENSION_OPTIONS.include?(key) }
end