Code Monkey home page Code Monkey logo

stillir's Introduction

Stillir

A library to cache Environmental variables for your Erlang application, useful when you pass configuration details to your application using the environment.

Reason: http://www.12factor.net/config

Build Status

The name

Stillir is icelandic for "the one who configures", it can also be used as a verb:

Hann stillir kaffikönnuna

Translates to

He configures the coffee machine.

Tests

$ rebar compile ct

Erlang API

Types

-type app_name() :: atom().
-type app_key() :: atom().
-type env_key() :: string().
-type env_var_value() :: string().
-type app_key_value() :: any().
-type default_value() :: app_key_value().
-type transform_fun() :: fun(((env_var_value())) -> app_key_value()).
-type default_fun() :: fun(() -> default_value()).
-type transform() :: integer|float|binary|atom|boolean|transform_fun().
-type opt() :: {default, any()|default_fun()}|{transform, transform()}|required.
-type opts() :: [opt()]|[].
-type config_spec() :: {app_key(), env_key()}|
                       {app_key(), env_key(), opts()}.
-type config_specs() :: [config_spec()].

boolean transform converts the following strings to booleans

true: true, yes, 1 false: false, no, 0

and throws an error otherwise

Functions

-spec set_config(app_name(), config_specs()|[]) -> ok|no_return().
-spec set_config(app_name(), app_key(), env_key()) -> ok|no_return().
-spec get_config(app_name(), app_key()) -> app_key_value()|no_return().
-spec get_config(app_name(), app_key(), default_value()) -> app_key_value().
-spec update_env(app_name(), file:filename_all(), config_specs()|[]) -> ok|no_return().

The transform_fun/0 is only run if the input is a list.

stillir's People

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.