Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/trestrantham/ex_figaro
Figaro for Elixir
https://github.com/trestrantham/ex_figaro
Last synced: 2 months ago
JSON representation
Figaro for Elixir
- Host: GitHub
- URL: https://github.com/trestrantham/ex_figaro
- Owner: trestrantham
- Created: 2014-06-28T04:47:24.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-11T14:45:29.000Z (almost 9 years ago)
- Last Synced: 2024-10-06T16:06:00.257Z (3 months ago)
- Language: Elixir
- Size: 18.6 KB
- Stars: 9
- Watchers: 3
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Simple Elixir project configuration. (Configuration)
- fucking-awesome-elixir - figaro - Simple Elixir project configuration. (Configuration)
- awesome-elixir - figaro - Simple Elixir project configuration. (Configuration)
README
Figaro
======
[![Build Status](http://img.shields.io/travis/trestrantham/ex_figaro.svg?style=flat "Build Status")](http://travis-ci.org/trestrantham/ex_figaro)
[![Coverage Status](http://img.shields.io/coveralls/trestrantham/ex_figaro.svg?style=flat)](https://coveralls.io/r/trestrantham/ex_figaro?branch=master)Port of [@laserlemon](http://github.com/laserlemon)'s [Figaro](http://github.com/laserlemon/figaro)
gem to Elixir. Please see original project for additional details and history.
Documentation is lifted from [@laserlemon](http://github.com/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.
```elixir
defp deps do
[{ :figaro, ">= 0.0.0" }]
end
```You should also update your applications list to include Figaro:
```elixir
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:
```yaml
# config/application.ymlfoo: bar
baz: qux
```You will have access to configuration values via `Figaro.env`:
```elixir
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`:
```elixir
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:```yaml
# config/application.ymlfoo: foo
bar: bartest:
foo: sekret
bar: noway
```You can also nullify configuration values for a specific environment:
```yaml
# config/application.ymlfoo: foo
bar: bartest:
foo: ~
```Assuming you are running from the test environment:
```elixir
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.