Atmo - Environment Configuration for Elixir

Build StatusHex.pm

A single, flexible interface for reading configuration from environment variables or Mix.Config with parsing and defaults.

Installation

defp deps do
  [{:atmo, "~> 0.1.0"}]
end

Usage

Full Documentation

The Atmo module provides a single interface for retrieving configuration from multiple sources. This is most useful for development of applications where config files are useful in testing and development but must be overridden by environment variables in production.

Basic Usage

Mix.Config.config(:some_app, app_conf: "bar")
System.put_env("ENV_VAR", "foo")

Atmo.get("ENV_VAR") # => "foo"
Atmo.get(:app_conf) #=> "bar"

Atmo.get("MISSING_VARIABLE") # => nil
Atmo.get("MISSING_VARIABLE", "whatever") # => "whatever"

Atmo.get("env_var") # => "foo"
Atmo.get("env_VAR") # => "foo"
Atmo.get(:env_var) # => "foo"
Atmo.get(:ENV_VAR) # => "foo"

Type Parsing

System.put_env("SOME_FLOAT", "1.234")
System.put_env("SOME_INT", "42")

Atmo.get("SOME_INT") #=> "42"
Atmo.get_integer("SOME_INT") #=> 42
Atmo.get_float("SOME_FLOAT") #=> 1.234

Tests

> mix test