dotenv 0.0.4

A port of dotenv to Elixir

Platform: Hex

Language: Elixir

License: MIT

Repository: https://github.com/avdi/dotenv_elixir

View on registry: https://hex.pm/packages/dotenv/

Documentation: http://hexdocs.pm/dotenv/0.0.4


Dotenv for Elixir

This is a port of @bkeepers' dotenv project to Elixir. You can read more about dotenv on that project's page. The short version is that it simplifies developing projects where configuration is stored in environment variables (e.g. projects intended to be deployed to Heroku).

Quick Start

The simplest way to use Dotenv is with the included OTP application. This will automatically load variables from a .env file in the root of your project directory into the process environment when started.

First add dotenv to your dependencies.

For the latest release:

{:dotenv, "~> 0.0.4"}

For master:

{:dotenv, github: "avdi/dotenv_elixir"}

Fetch your dependencies with mix deps.get.

Now, add the :dotenv application to your applications list when running in the :dev environment:

# Configuration for the OTP application
def application do
 [
 mod: { YourApp, [] },
 applications: app_list(Mix.env)
 ]
end
defp app_list(:dev), do: [:dotenv | app_list]
defp app_list(_), do: app_list
defp app_list, do: [...]

Now, when you load your app in a console with iex -S mix, your environment variables will be set automatically.

Reloading the .env file

The Dotenv.reload!/0 function will reload the variables defined in the .env file.

More examples of the server API usage can be found in dotenv_app_test.exs.

Serverless API

If you would like finer-grained control over when variables are loaded, or would like to inspect them, Dotenv also provides a serverless API for interacting with .env files.

The load!/1 function loads variables into the process environment, and can be passed a path or list of paths to read from.

Alternately, load/1 will return a data structure of the variables read from the .env file:

iex(1)> Dotenv.load
%Dotenv.Env{paths: ["/elixir/dotenv_elixir/.env"],
 values: #HashDict<[{"APP_TEST_VAR", "HELLO"}]>}

For further details, see the inline documentation. Usage examples can be found in dotenv_test.exs.

веселые картинки развлекательные гифки интресные факты смешные видео смешные истории из соцсетей

GitHub Repository

avdi/dotenv_elixir avdi/dotenv_elixir

A port of dotenv to Elixir

Language: Elixir

Created: December 03, 2013 17:38

Last updated: March 28, 2015 02:03

Last pushed: March 27, 2015 20:09

Size: 305 KB

Stars: 35

Forks: 12

Watchers: 2

Open issues: 3

Top Contributors

Jared Norman Avdi Grimm Louis Simoneau David Rouchy Paul Smith Alexander Quine Claudio Ortolina Mauro George

Releases

  • 0.0.4 - December 23, 2014 01:49
  • 0.0.3 - August 16, 2014 22:59
  • 0.0.2 - August 15, 2014 06:37

Related Projects

cure 0.4.0
Interfaces Elixir with C/C++ code in a user-friendly way! Based on Erlang-ports. Provides a few M...
Hex - Elixir - MIT - Updated 3 months ago - 13 stars
dotenv_elixir 0.0.2
A port of dotenv to Elixir
Hex - Elixir - MIT - Published 8 months ago - 35 stars
ex_csv 0.1.3
CSV for Elixir
Hex - Elixir - MIT - Updated 6 months ago - 3 stars
exjsx 3.1.0
json for elixir
Hex - Elixir - MIT - Updated 4 months ago - 95 stars
jsex 2.0.0
json for elixir
Hex - Elixir - MIT - Published 11 months ago - 95 stars
веселые картинки развлекательные гифки интресные факты смешные видео смешные истории из соцсетей