Module: EnvStyle
- Defined in:
- lib/env_style.rb,
lib/env_style/engine.rb,
lib/env_style/source.rb,
lib/env_style/favicon.rb,
lib/env_style/version.rb,
lib/env_style/svg_tinter.rb,
lib/env_style/environment.rb,
lib/env_style/configuration.rb,
lib/env_style/raster_tinter.rb,
app/helpers/env_style/favicon_helper.rb,
app/controllers/env_style/favicons_controller.rb,
app/controllers/env_style/application_controller.rb
Overview
EnvStyle tints an application's favicon a distinct color per environment, so side-by-side browser tabs are visually distinguishable. Production is left untouched, and setting Configuration#enabled to false stops the helper from adding the favicon link.
Defined Under Namespace
Modules: FaviconHelper Classes: ApplicationController, Configuration, ConfigurationError, Engine, Environment, Error, Favicon, FaviconsController, RasterTinter, Source, SvgTinter
Constant Summary collapse
- VERSION =
"0.1.0"- DEFAULT_COLORS =
Built-in per-environment tint colors. Production is intentionally absent so it is never tinted; unknown non-production environments fall back to Configuration#default_color.
{ "development" => "#3b82f6", "staging" => "#f59e0b", "preview" => "#f59e0b" }.freeze
- DEFAULT_COLOR =
Neutral gray used for non-production environments with no explicit color.
"#6b7280"
Class Method Summary collapse
-
.configuration ⇒ Object
(also: config)
The process-wide configuration.
-
.configure {|configuration| ... } ⇒ Object
Yields the configuration for block-style setup.
-
.logger ⇒ Object
The logger EnvStyle writes warnings to: the configured logger, else Rails' logger when Rails is loaded, else a plain STDOUT logger.
-
.reset_configuration! ⇒ Object
Rebuilds the configuration from defaults.
Class Method Details
.configuration ⇒ Object Also known as: config
The process-wide configuration. Memoized; reset with reset_configuration!.
26 27 28 |
# File 'lib/env_style.rb', line 26 def configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
Yields the configuration for block-style setup.
EnvStyle.configure do |c|
c.colors = { "staging" => "#f59e0b" }
end
36 37 38 |
# File 'lib/env_style.rb', line 36 def configure yield(configuration) end |
.logger ⇒ Object
The logger EnvStyle writes warnings to: the configured logger, else Rails' logger when Rails is loaded, else a plain STDOUT logger.
47 48 49 50 |
# File 'lib/env_style.rb', line 47 def logger configuration.logger || (Rails.logger if defined?(Rails) && Rails.respond_to?(:logger)) || Logger.new($stdout) end |
.reset_configuration! ⇒ Object
Rebuilds the configuration from defaults. Primarily used by tests.
41 42 43 |
# File 'lib/env_style.rb', line 41 def reset_configuration! @configuration = Configuration.new end |