Class: EnvStyle::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/env_style/configuration.rb

Overview

Holds every knob EnvStyle exposes. Defaults make the gem work with no initializer at all; a host app overrides what it needs.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/env_style/configuration.rb', line 55

def initialize
  @enabled = true
  @source = nil
  @colors = DEFAULT_COLORS.dup
  @default_color = DEFAULT_COLOR
  @exclude_colors = []
  @exclude_tolerance = 0
  @environment = nil
  @rasterize_svg = false
  @rasterize_size = 32
  @logger = nil
end

Instance Attribute Details

#colorsObject

Environment name => tint color (any CSS color string).



28
29
30
# File 'lib/env_style/configuration.rb', line 28

def colors
  @colors
end

#default_colorObject

Tint color for non-production environments not listed in #colors.



31
32
33
# File 'lib/env_style/configuration.rb', line 31

def default_color
  @default_color
end

#enabledObject

Master switch. When false, the helper emits no favicon link (the route still serves the source untouched if requested directly).



21
22
23
# File 'lib/env_style/configuration.rb', line 21

def enabled
  @enabled
end

#environmentObject

Explicit environment override, highest precedence in resolution.



42
43
44
# File 'lib/env_style/configuration.rb', line 42

def environment
  @environment
end

#exclude_colorsObject

Colors preserved as-is when tinting raster icons (e.g. white backgrounds).



34
35
36
# File 'lib/env_style/configuration.rb', line 34

def exclude_colors
  @exclude_colors
end

#exclude_toleranceObject

Per-channel sRGB tolerance (0..255) for #exclude_colors matching. 0 keeps only exact matches; a higher value also preserves the anti-aliased halo of near-matching pixels around an excluded region.



39
40
41
# File 'lib/env_style/configuration.rb', line 39

def exclude_tolerance
  @exclude_tolerance
end

#loggerObject

Logger for EnvStyle warnings; defaults to Rails.logger at runtime.



53
54
55
# File 'lib/env_style/configuration.rb', line 53

def logger
  @logger
end

#rasterize_sizeObject

Edge length in pixels of the rasterized PNG when #rasterize_svg is true. Larger values render crisper favicons on hi-dpi tabs.



50
51
52
# File 'lib/env_style/configuration.rb', line 50

def rasterize_size
  @rasterize_size
end

#rasterize_svgObject

When true, SVG sources are rasterized to PNG via libvips instead of served as tinted SVG.



46
47
48
# File 'lib/env_style/configuration.rb', line 46

def rasterize_svg
  @rasterize_svg
end

#sourceObject

Source icon path (String/Pathname, Rails.root-relative) or a per-env Hash. nil means auto-discover (see EnvStyle::Source).



25
26
27
# File 'lib/env_style/configuration.rb', line 25

def source
  @source
end