Sha256: cd415427d78d9e96a9f4b2caf807b9638c7ca7771fb4fb3230b924b93cacadee

Contents?: true

Size: 1.05 KB

Versions: 27

Compression:

Stored size: 1.05 KB

Contents

require 'dotenv'

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

  def initialize(deploy=false)
    @deploy = deploy
  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 @deploy
    files.compact
  end

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

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
jets-0.8.6 lib/jets/dotenv.rb
jets-0.8.5 lib/jets/dotenv.rb
jets-0.8.4 lib/jets/dotenv.rb
jets-0.8.3 lib/jets/dotenv.rb
jets-0.8.2 lib/jets/dotenv.rb
jets-0.8.1 lib/jets/dotenv.rb
jets-0.8.0 lib/jets/dotenv.rb
jets-0.7.1 lib/jets/dotenv.rb
jets-0.7.0 lib/jets/dotenv.rb
jets-0.6.9 lib/jets/dotenv.rb
jets-0.6.8 lib/jets/dotenv.rb
jets-0.6.7 lib/jets/dotenv.rb
jets-0.6.6 lib/jets/dotenv.rb
jets-0.6.5 lib/jets/dotenv.rb
jets-0.6.4 lib/jets/dotenv.rb
jets-0.6.3 lib/jets/dotenv.rb
jets-0.6.2 lib/jets/dotenv.rb
jets-0.6.1 lib/jets/dotenv.rb
jets-0.6.0 lib/jets/dotenv.rb
jets-0.5.8 lib/jets/dotenv.rb