Class: EnvStyle::Configuration
- Inherits:
-
Object
- Object
- EnvStyle::Configuration
- 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
-
#colors ⇒ Object
Environment name => tint color (any CSS color string).
-
#default_color ⇒ Object
Tint color for non-production environments not listed in #colors.
-
#enabled ⇒ Object
Master switch.
-
#environment ⇒ Object
Explicit environment override, highest precedence in resolution.
-
#exclude_colors ⇒ Object
Colors preserved as-is when tinting raster icons (e.g. white backgrounds).
-
#exclude_tolerance ⇒ Object
Per-channel sRGB tolerance (0..255) for #exclude_colors matching.
-
#logger ⇒ Object
Logger for EnvStyle warnings; defaults to Rails.logger at runtime.
-
#rasterize_size ⇒ Object
Edge length in pixels of the rasterized PNG when #rasterize_svg is true.
-
#rasterize_svg ⇒ Object
When true, SVG sources are rasterized to PNG via libvips instead of served as tinted SVG.
-
#source ⇒ Object
Source icon path (String/Pathname, Rails.root-relative) or a per-env Hash.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
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
#colors ⇒ Object
Environment name => tint color (any CSS color string).
28 29 30 |
# File 'lib/env_style/configuration.rb', line 28 def colors @colors end |
#default_color ⇒ Object
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 |
#enabled ⇒ Object
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 |
#environment ⇒ Object
Explicit environment override, highest precedence in resolution.
42 43 44 |
# File 'lib/env_style/configuration.rb', line 42 def environment @environment end |
#exclude_colors ⇒ Object
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_tolerance ⇒ Object
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 |
#logger ⇒ Object
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_size ⇒ Object
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_svg ⇒ Object
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 |
#source ⇒ Object
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 |