Class: Goliath::EnvironmentParser
- Inherits:
-
Object
- Object
- Goliath::EnvironmentParser
- Defined in:
- lib/goliath/runner.rb
Overview
The environment for a Goliath app can come from a variety of different sources. Due to the loading order of middleware, we must parse this out at load-time rather than run time.
Note that, as implemented, you cannot pass -e as part of a compound flag (e.g. ‘-sve production`) as it won’t be picked up. The example given would have to be provided as ‘-sv -e production`.
For more detail, see: github.com/postrank-labs/goliath/issues/18
Class Method Summary collapse
-
.parse(argv = []) ⇒ Symbol
Work out the current runtime environment.
Class Method Details
.parse(argv = []) ⇒ Symbol
Work out the current runtime environment.
The sources of environment, in increasing precedence, are:
1. Default (see Goliath::DEFAULT_ENV)
2. RACK_ENV
3. -e/--environment command line options
4. Hard-coded call to Goliath#env=
34 35 36 37 38 39 40 |
# File 'lib/goliath/runner.rb', line 34 def self.parse(argv = []) env = ENV["RACK_ENV"] || Goliath::DEFAULT_ENV if (i = argv.index('-e')) || (i = argv.index('--environment')) env = argv[i + 1] end env.to_sym end |