Code Monkey home page Code Monkey logo

ex_figaro's Introduction

Figaro

Build Status Coverage Status

Port of @laserlemon's Figaro gem to Elixir. Please see original project for additional details and history. Documentation is lifted from @laserlemon's gem verbatim (where applicable) in an effort to provide full feature parity.

Getting Started

Add Figaro as a dependency in your mix.exs file.

defp deps do
  [{ :figaro, ">= 0.0.0" }]
end

You should also update your applications list to include Figaro:

def application do
  [applications: [:figaro]]
end

After you are done, run mix deps.get in your shell to fetch the dependencies.

Usage

Given the following configuration file:

# config/application.yml

foo: bar
baz: qux

You will have access to configuration values via Figaro.env:

iex> Figaro.env.foo
"bar"
iex> Figaro.env.baz
"qux"
iex> Figaro.env
%{foo: "bar", baz: "qux"}

Figaro also sets ENV with values defined in application.yml:

iex> System.get_env("FOO")
"bar"
iex> System.get_env("BAZ")
"qux"

Please note: ENV is a simple key/value store. All values will be converted to strings. Deeply nested configuration structures are not possible.

Environment-Specific Configuration

Oftentimes, local configuration values change depending on your environment. In such cases, you can add environment-specific values to your configuration file:

# config/application.yml

foo: foo
bar: bar

test:
  foo: sekret
  bar: noway

You can also nullify configuration values for a specific environment:

# config/application.yml

foo: foo
bar: bar

test:
  foo: ~

Assuming you are running from the test environment:

iex> System.get_env("FOO")
nil
iex> System.get_env("BAR")
"bar"

Please note: The environment names (test above) are derived from Mix.env. Any other keys defining nested configuration values will be ignored.

ex_figaro's People

Contributors

trestrantham avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.