Module: Denv
- Defined in:
- lib/denv.rb,
lib/denv/rails.rb,
lib/denv/version.rb
Defined Under Namespace
Classes: Error, InvalidFormatError, InvalidKeyNameError, NoSuchFileError, Parser, Railtie
Constant Summary collapse
- DEFAULT_ENV_FILENAME =
'.env'.freeze
- SPECIAL_KEY =
'__denv_previous_keys__'.freeze
- DELIMITER =
'='.freeze
- VERSION =
'0.2.2'
Class Attribute Summary collapse
-
.callback ⇒ Object
Returns the value of attribute callback.
Class Method Summary collapse
-
.build_env(filename) ⇒ Hash
Read from .env file and build env Hash.
-
.load(filename = DEFAULT_ENV_FILENAME) ⇒ Hash
Read from .env file and load vars into ‘ENV`.
Class Attribute Details
.callback ⇒ Object
Returns the value of attribute callback.
30 31 32 |
# File 'lib/denv.rb', line 30 def callback @callback end |
Class Method Details
.build_env(filename) ⇒ Hash
Read from .env file and build env Hash.
49 50 51 |
# File 'lib/denv.rb', line 49 def build_env(filename) open_file(filename) {|f| Parser.new(f, filename).parse } end |
.load(filename = DEFAULT_ENV_FILENAME) ⇒ Hash
Read from .env file and load vars into ‘ENV`. Default is over-write.
36 37 38 39 40 41 42 43 44 |
# File 'lib/denv.rb', line 36 def load(filename = DEFAULT_ENV_FILENAME) filename = File.(filename.to_s) run_callback(filename) do remove_previous_denv_envs env = build_env(filename) ENV.update(env) ENV[SPECIAL_KEY] = env.keys.join(DELIMITER) end end |