Giter Site home page Giter Site logo

exconfig's Introduction

ExConfig

A simplistic configuration library for Elixir.

It allows you to define configurations as modules:

defmodule MyConfig do
  use ExConfig.Object
  defproperty http_port
  defproperty https_port, default: 8081
end

And then use them to define actual configurations:

MyConfig.config do
   config.http_port 8080
end

The value returned by the above code will be a MyConfig record with http_port and https_port configured.

ExConfig can be used to read config files as well:

config = MyConfig.file! "config.exs"

exconfig's People

Contributors

yrashk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

exconfig's Issues

Tests fail with 11.3-dev

➜  exconfig git:(master) ✗ mix test
** (SyntaxError) nofile:1: invalid syntax in def :some.(value, server)
    src/elixir_def.erl:61: :elixir_def.store_definition/5
    test/exconfig_test.exs:3: ExConfig.Object.__before_compile__/1

➜  exconfig git:(master) ✗ iex
Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Interactive Elixir (0.11.3-dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 

Informative error message about wrong module used in config.exs

When we use exconfig in the following manner:

ERL_LIBS=.:deps elixir -e "config = MyModule.Config.file!(%b{config.exs}); config.sys_config!(%b{sys.config})"

with the following config.exs:

NonExistentModule.Config.config do
  config.some_property 42
end

We get the following error:

** (UndefinedFunctionError) undefined function: :erl_eval.config/0
    :erl_eval.config/0
    :erl_eval.expr/3

Instead, we should get an informative message that there is no module 'Elixir-NonExistentModule-Config'.

Genx dependency won't compile on 0.12.5-dev

♪  spoonbot git:(master) ✗ mix deps.compile
* Compiling genx
Compiled lib/gen.ex
Compiled lib/application.ex
Compiled lib/gen_event.ex
Compiled lib/gen_fsm.ex
Compiled lib/ct.ex
Compiled lib/gen_server.ex
lib/supervisor.ex:146: using // for default arguments is deprecated, please use \\ instead
Compiled lib/supervisor.ex
could not compile dependency genx, mix compile failed. You can recompile this dependency with `mix deps.compile genx` or update it with `mix deps.update genx`
** (Mix) Expected :version to be a SemVer version

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.