Sha256: 917a05baca690d578d4a6a33308ca2a086b8864a6af1fece90bc65b11d12d2c4

Contents?: true

Size: 976 Bytes

Versions: 12

Compression:

Stored size: 976 Bytes

Contents

require 'dotenv'
require 'pathname'

class Forger::Dotenv
  class << self
    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
      [
        root.join(".env.#{Forger.env}.local"),
        (root.join(".env.local") unless Forger.env == "test"),
        root.join(".env.#{Forger.env}"),
        root.join(".env")
      ].compact
    end

    def root
      Forger.root || Pathname.new(ENV["FORGER_ROOT"] || Dir.pwd)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
forger-3.0.2 lib/forger/dotenv.rb
forger-3.0.1 lib/forger/dotenv.rb
forger-3.0.0 lib/forger/dotenv.rb
forger-2.0.5 lib/forger/dotenv.rb
forger-2.0.4 lib/forger/dotenv.rb
forger-2.0.3 lib/forger/dotenv.rb
forger-2.0.2 lib/forger/dotenv.rb
forger-2.0.1 lib/forger/dotenv.rb
forger-2.0.0 lib/forger/dotenv.rb
forger-1.6.0 lib/forger/dotenv.rb
forger-1.5.4 lib/forger/dotenv.rb
forger-1.5.3 lib/forger/dotenv.rb