Class: Bridgetown::ImagePipeline::Config

Inherits:
Struct
  • Object
show all
Defined in:
lib/bridgetown/image_pipeline/config.rb

Constant Summary collapse

DEFAULTS =
{
  source_globs: ["src/images/**/*.{jpg,jpeg,png}"],
  exclude: [],
  widths: [400, 600, 800, 1200, 1600],
  formats: %i[avif webp],
  output_dir: "_bridgetown/image_pipeline",
  quality: { avif: 65, webp: 88, jpeg: 88 },
  auto_rewrite: false,
  fail_on_missing: false,
  breakpoints: { 640 => 400, 768 => 600, 1024 => 800, 1280 => 1200 },
  default_width: 1600
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#auto_rewriteObject

Returns the value of attribute auto_rewrite

Returns:

  • (Object)

    the current value of auto_rewrite



5
6
7
# File 'lib/bridgetown/image_pipeline/config.rb', line 5

def auto_rewrite
  @auto_rewrite
end

#breakpointsObject

Returns the value of attribute breakpoints

Returns:

  • (Object)

    the current value of breakpoints



5
6
7
# File 'lib/bridgetown/image_pipeline/config.rb', line 5

def breakpoints
  @breakpoints
end

#default_widthObject

Returns the value of attribute default_width

Returns:

  • (Object)

    the current value of default_width



5
6
7
# File 'lib/bridgetown/image_pipeline/config.rb', line 5

def default_width
  @default_width
end

#excludeObject

Returns the value of attribute exclude

Returns:

  • (Object)

    the current value of exclude



5
6
7
# File 'lib/bridgetown/image_pipeline/config.rb', line 5

def exclude
  @exclude
end

#fail_on_missingObject

Returns the value of attribute fail_on_missing

Returns:

  • (Object)

    the current value of fail_on_missing



5
6
7
# File 'lib/bridgetown/image_pipeline/config.rb', line 5

def fail_on_missing
  @fail_on_missing
end

#formatsObject

Returns the value of attribute formats

Returns:

  • (Object)

    the current value of formats



5
6
7
# File 'lib/bridgetown/image_pipeline/config.rb', line 5

def formats
  @formats
end

#output_dirObject

Returns the value of attribute output_dir

Returns:

  • (Object)

    the current value of output_dir



5
6
7
# File 'lib/bridgetown/image_pipeline/config.rb', line 5

def output_dir
  @output_dir
end

#qualityObject

Returns the value of attribute quality

Returns:

  • (Object)

    the current value of quality



5
6
7
# File 'lib/bridgetown/image_pipeline/config.rb', line 5

def quality
  @quality
end

#source_globsObject

Returns the value of attribute source_globs

Returns:

  • (Object)

    the current value of source_globs



5
6
7
# File 'lib/bridgetown/image_pipeline/config.rb', line 5

def source_globs
  @source_globs
end

#widthsObject

Returns the value of attribute widths

Returns:

  • (Object)

    the current value of widths



5
6
7
# File 'lib/bridgetown/image_pipeline/config.rb', line 5

def widths
  @widths
end

Class Method Details

.from(**overrides) ⇒ Object

Build a Config from initializer kwargs. Unknown keys raise.



24
25
26
27
28
29
# File 'lib/bridgetown/image_pipeline/config.rb', line 24

def self.from(**overrides)
  merged = DEFAULTS.merge(overrides)
  merged[:formats] = Array(merged[:formats]).map(&:to_sym)
  merged[:quality] = DEFAULTS[:quality].merge(merged[:quality] || {})
  new(**merged)
end