Class: Jets::Dotenv

Inherits:
Object
  • Object
show all
Defined in:
lib/jets/dotenv.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deploy = false) ⇒ Dotenv

Returns a new instance of Dotenv.



8
9
10
# File 'lib/jets/dotenv.rb', line 8

def initialize(deploy=false)
  @deploy = deploy
end

Class Method Details

.load!(deploy = false) ⇒ Object



4
5
6
# File 'lib/jets/dotenv.rb', line 4

def self.load!(deploy=false)
  new(deploy).load!
end

Instance Method Details

#dotenv_filesObject

  • ‘.env` - The Original®

  • ‘.env.development`, `.env.test`, `.env.production` - Environment-specific settings.

  • ‘.env.local` - Local overrides. This file is loaded for all environments except `test`.

  • ‘.env.development.local`, `.env.test.local`, `.env.production.local` - Local overrides of environment-specific settings.



23
24
25
26
27
28
29
30
31
32
# File 'lib/jets/dotenv.rb', line 23

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 @deploy
  files.compact
end

#load!Object



12
13
14
# File 'lib/jets/dotenv.rb', line 12

def load!
  ::Dotenv.load(*dotenv_files)
end

#rootObject



34
35
36
# File 'lib/jets/dotenv.rb', line 34

def root
  Jets.root || Pathname.new(ENV["JETS_ROOT"] || Dir.pwd)
end