Module: Early
- Defined in:
- lib/early.rb,
lib/early/travis.rb
Overview
Early checks for environment variables availability, so you don’t have to.
Hook it early in your program and work with ‘ENV` like you normally would. This time, however, the errors would be thrown early and not when a critical piece of code is hit, which may happen late in the program runtime an be easy to miss.
Defined Under Namespace
Classes: Configuration, DefaultVariable, Error, RequiredVariable, Travis
Constant Summary collapse
- VERSION =
'0.3.0'
Class Method Summary collapse
-
.apply(config) ⇒ Object
Applies a configuration, which means every variable is either defaulted or checked for existence.
-
.const_missing(name) ⇒ Object
Accessing environment variables as constants.
-
.env ⇒ Object
Env returns the early environment.
Class Method Details
.apply(config) ⇒ Object
Applies a configuration, which means every variable is either defaulted or checked for existence.
85 86 87 |
# File 'lib/early.rb', line 85 def self.apply(config) config.variables.each(&:apply) end |
.const_missing(name) ⇒ Object
Accessing environment variables as constants. Raises Early::Error if missing.
91 92 93 |
# File 'lib/early.rb', line 91 def self.const_missing(name) RequiredVariable.new(name).apply end |
.env ⇒ Object
Env returns the early environment. This is either the value of RAILS_ENV, RACK_ENV (in that order) or the string 'development'
if neither of the aforementioned environment variables are present.
79 80 81 |
# File 'lib/early.rb', line 79 def self.env ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development' end |