Module: Envalit
- Defined in:
- lib/envalit.rb,
lib/envalit/loader.rb,
lib/envalit/railtie.rb,
lib/envalit/version.rb,
lib/envalit/generators/install_generator.rb
Overview
Envalit is a Ruby gem for managing and validating environment variables.
It provides a simple and flexible way to:
-
Register environment variables with validation rules
-
Set default values for optional variables
-
Validate variable types (string, integer, boolean, float)
-
Control validation behavior (warnings vs. strict errors)
-
Load variables from .env files
Defined Under Namespace
Modules: Generators Classes: Loader, Railtie, ValidationError
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
-
.configure {|self| ... } ⇒ void
Configures Envalit with the given block.
-
.register(key, options = {}) ⇒ void
Registers an environment variable with validation options.
-
.validate ⇒ void
Validates all registered environment variables.
-
.validate! ⇒ void
Validates all registered environment variables in strict mode.
Class Method Details
.configure {|self| ... } ⇒ void
This method returns an undefined value.
Configures Envalit with the given block.
47 48 49 50 |
# File 'lib/envalit.rb', line 47 def configure @loader ||= Loader.new(Dir.pwd) yield(self) end |
.register(key, options = {}) ⇒ void
This method returns an undefined value.
Registers an environment variable with validation options.
62 63 64 |
# File 'lib/envalit.rb', line 62 def register(key, = {}) @loader.register(key, ) end |
.validate ⇒ void
This method returns an undefined value.
Validates all registered environment variables. Missing required variables will trigger warnings unless they are marked as strict.
71 72 73 |
# File 'lib/envalit.rb', line 71 def validate @loader.validate end |
.validate! ⇒ void
This method returns an undefined value.
Validates all registered environment variables in strict mode. All missing required variables will raise an error, regardless of their strict setting.
80 81 82 |
# File 'lib/envalit.rb', line 80 def validate! @loader.validate! end |