class

Poncho::Loader

Inherits Reference < Object

Poncho::Loader is a .env file loader

Poncho loads the environment file is easy to use. It accepts both single file (or path) and multiple files.

Orders

Poncho loads single file supports the following order with environment name (default is development):

  • .env - The Original®
  • .env.development - Environment-specific settings.
  • .env.local - Local overrides. This file is loaded for all environments except test.
  • .env.development.local - Local overrides of environment-specific settings.

NO effect with multiple files, it only loads the given files.

Overrides

By default, Poncho won't overwrite existing environment variables as dotenv assumes the deployment environment has more knowledge about configuration than the application does.

Load single file

loader = Poncho::Loader.new env: "development"
loader.load ".env"

Load multiple files

loader = Poncho::Loader.new
loader.load ".env", ".env.local"

Constants

DEFAULT_ENV_NAME = "development"

Constructors

new(env : String | Nil = nil)
Source

Instance methods

load(*paths, overwrite = false)

Load environment variables

Source
load!(*paths)

Load environment variables and overwrite existing ones.

Same as #load(*files, overwrite: true)

Source