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(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_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.



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

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.compact
end

#load!Object



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

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

#rootObject



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

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