Sha256: 0a20becefe2d2d11d4d2defc89b04bbe7198eb419403e791fbfee5530234a9ca

Contents?: true

Size: 1.11 KB

Versions: 81

Compression:

Stored size: 1.11 KB

Contents

require 'dotenv'

class Jets::Dotenv
  def self.load!(remote=false)
    new(remote).load!
  end

  def initialize(remote=false)
    @remote = remote
    @remote = ENV['JETS_ENV_REMOTE'] if ENV['JETS_ENV_REMOTE']
  end

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

  # dotenv files will load the following files, starting from the bottom. The first value set (or those already defined in the environment) take precedence:

  # - `.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.
  #
  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

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

Version data entries

81 entries across 81 versions & 1 rubygems

Version Path
jets-1.6.3 lib/jets/dotenv.rb
jets-1.6.2 lib/jets/dotenv.rb
jets-1.6.1 lib/jets/dotenv.rb
jets-1.6.0 lib/jets/dotenv.rb
jets-1.5.10 lib/jets/dotenv.rb
jets-1.5.9 lib/jets/dotenv.rb
jets-1.5.8 lib/jets/dotenv.rb
jets-1.5.7 lib/jets/dotenv.rb
jets-1.5.6 lib/jets/dotenv.rb
jets-1.5.5 lib/jets/dotenv.rb
jets-1.5.4 lib/jets/dotenv.rb
jets-1.5.3 lib/jets/dotenv.rb
jets-1.5.2 lib/jets/dotenv.rb
jets-1.5.1 lib/jets/dotenv.rb
jets-1.5.0 lib/jets/dotenv.rb
jets-1.4.11 lib/jets/dotenv.rb
jets-1.4.10 lib/jets/dotenv.rb
jets-1.4.9 lib/jets/dotenv.rb
jets-1.4.8 lib/jets/dotenv.rb
jets-1.4.7 lib/jets/dotenv.rb