Class: Jets::Dotenv
- Inherits:
-
Object
- Object
- Jets::Dotenv
- Defined in:
- lib/jets/dotenv.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#dotenv_files ⇒ Object
dotenv files with the following precedence:.
-
#initialize(remote = false) ⇒ Dotenv
constructor
A new instance of Dotenv.
- #load! ⇒ Object
- #root ⇒ Object
Constructor Details
#initialize(remote = false) ⇒ Dotenv
Returns a new instance of Dotenv.
8 9 10 11 |
# File 'lib/jets/dotenv.rb', line 8 def initialize(remote=false) @remote = remote @remote = ENV['JETS_ENV_REMOTE'] if ENV['JETS_ENV_REMOTE'] end |
Class Method Details
.load!(remote = false) ⇒ Object
4 5 6 |
# File 'lib/jets/dotenv.rb', line 4 def self.load!(remote=false) new(remote).load! end |
Instance Method Details
#dotenv_files ⇒ Object
dotenv files with the following precedence:
-
.env.development.remote (highest)
-
.env.development.local
-
.env.development
-
.env.local - This file is loaded for all environments except ‘test`.
-
.env` - The original (lowest)
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/jets/dotenv.rb', line 25 def dotenv_files files = [ root.join(".env"), (root.join(".env.local") unless Jets.env.test?), root.join(".env.#{Jets.env}"), root.join(".env.#{Jets.env}.local"), ] files << root.join(".env.#{Jets.env}.remote") if @remote files.reverse.compact # reverse so the precedence is right end |
#load! ⇒ Object
13 14 15 |
# File 'lib/jets/dotenv.rb', line 13 def load! ::Dotenv.load(*dotenv_files) end |
#root ⇒ Object
36 37 38 |
# File 'lib/jets/dotenv.rb', line 36 def root Jets.root || Pathname.new(ENV["JETS_ROOT"] || Dir.pwd) end |