Packages

Flasked injects application environment configuration at runtime based on given ENV variables and a mapping. This is pretty useful for applications following the 12factor app principle or which are deployed in containerization infrastructures like Docker.

Current section

3 Versions

Jump to

Compare versions

8 files changed
+56 additions
-23 deletions
  @@ -56,7 +56,7 @@ And `Code.eval_file("some/file.exs")` does the job just fine, really.
56 56 ```elixir
57 57 # mix.exs
58 58 def deps do
59 - [{:flasked, "~> 0.3"}]
59 + [{:flasked, "~> 0.4"}]
60 60 end
61 61 ```
62 62
  @@ -76,6 +76,14 @@ def application do
76 76 end
77 77 ```
78 78
79 + #### Standalone one-shot usage
80 +
81 + ```elixir
82 + # If you want to control it yourself or
83 + # need to repeatedly call it in your application:
84 + Flasked.bottle_it
85 + ```
86 +
79 87 ### Add mapping
80 88
81 89 Furthermore you need to set up the mapping file:
  @@ -177,42 +185,46 @@ a type and a default. If you want to give a default you always need to specify t
177 185
178 186 ```
179 187 MY_FLASKED_APP_VAR=a_string_val
180 - {:flasked, MY_FLASKED_APP_VAR}
188 + {:flasked, :MY_FLASKED_APP_VAR}
181 189 => "a_string_val"
182 190
183 191 MY_FLASKED_APP_VAR=true
184 - {:flasked, MY_FLASKED_APP_VAR, :boolean}
192 + {:flasked, :MY_FLASKED_APP_VAR, :boolean}
185 193 => true
186 194 - valid values: TRUE, true, FALSE, false
187 195 - any other value will always default to `false`
188 196
189 197 MY_FLASKED_APP_VAR=9
190 - {:flasked, MY_FLASKED_APP_VAR, :integer}
198 + {:flasked, :MY_FLASKED_APP_VAR, :integer}
191 199 => 9
192 200
193 201 MY_FLASKED_APP_VAR=3.1415
194 - {:flasked, MY_FLASKED_APP_VAR, :float}
202 + {:flasked, :MY_FLASKED_APP_VAR, :float}
195 203 => 3.1415
196 204
197 205 MY_FLASKED_APP_VAR=list,of,strings
198 - {:flasked, MY_FLASKED_APP_VAR, :list}
206 + {:flasked, :MY_FLASKED_APP_VAR, :list}
199 207 => ["list", "of", "strings"]
200 208
201 209 MY_FLASKED_APP_VAR=list,of,atoms
202 - {:flasked, MY_FLASKED_APP_VAR, :list_of_atoms}
210 + {:flasked, :MY_FLASKED_APP_VAR, :list_of_atoms}
203 211 => [:list, :of, :atoms]
204 212
205 213 MY_FLASKED_APP_VAR=1,2,3
206 - {:flasked, MY_FLASKED_APP_VAR, :list_of_integers}
214 + {:flasked, :MY_FLASKED_APP_VAR, :list_of_integers}
207 215 => [1, 2, 3]
208 216
209 217 MY_FLASKED_APP_VAR=4.44,5.555,6.789
210 - {:flasked, MY_FLASKED_APP_VAR, :list_of_floats}
218 + {:flasked, :MY_FLASKED_APP_VAR, :list_of_floats}
211 219 => [4.44, 5.555, 6.789]
212 220
213 221 MY_FLASKED_APP_VAR=this:is,a:dictionary
214 - {:flasked, MY_FLASKED_APP_VAR, :dict}
222 + {:flasked, :MY_FLASKED_APP_VAR, :dict}
215 223 => [this: "is", a: "dictionary"]
224 +
225 + MY_FLASKED_APP_VAR=one:1,two:2,three:3
226 + {:flasked, :MY_FLASKED_APP_VAR, :dict_of_integers}
227 + => [one: 1, two: 2, three: 3]
216 228 ```
217 229
218 230 More sophisticated types could be supported. You're welcome to contribute.
  @@ -2,5 +2,8 @@ use Mix.Config
2 2
3 3 config :flasked,
4 4 otp_app: :flasked,
5 - map_file: "priv/flasked.exs",
6 - info: "This is Flasked"
5 + map_file: "priv/flasked.exs"
6 +
7 + if Mix.env in ~w(docs)a do
8 + config :ex_doc, :markdown_processor, ExDoc.Markdown.Cmark
9 + end
  @@ -2,7 +2,7 @@
2 2 {<<"build_tools">>,[<<"mix">>]}.
3 3 {<<"description">>,
4 4 <<"Flasked injects application environment configuration at runtime based on given ENV variables and a mapping.\nThis is pretty useful for applications following the 12factor app principle or which are deployed in\ncontainerization infrastructures like Docker.">>}.
5 - {<<"elixir">>,<<"~> 1.1">>}.
5 + {<<"elixir">>,<<"~> 1.2">>}.
6 6 {<<"files">>,
7 7 [<<"lib/flasked.ex">>,<<"lib/flasked/blender.ex">>,
8 8 <<"lib/flasked/board.ex">>,<<"lib/flasked/bottler.ex">>,
  @@ -16,4 +16,4 @@
16 16 {<<"maintainers">>,[<<"Christoph Grabo">>]}.
17 17 {<<"name">>,<<"flasked">>}.
18 18 {<<"requirements">>,[]}.
19 - {<<"version">>,<<"0.3.0">>}.
19 + {<<"version">>,<<"0.4.0">>}.
  @@ -15,8 +15,13 @@ defmodule Flasked do
15 15
16 16 def start(_type, _args) do
17 17 import Supervisor.Spec, warn: false
18 - Config.check
19 - Bottler.run
18 + bottle_it
20 19 Supervisor.start_link([], [strategy: :one_for_one, name: Flasked.Supervisor])
21 20 end
21 +
22 + def bottle_it do
23 + Config.check
24 + Bottler.run
25 + :ok
26 + end
22 27 end
  @@ -13,7 +13,9 @@ defmodule Flasked.Blender do
13 13 defp is_collectable(collectable), do: is_map(collectable) || is_dict(collectable)
14 14
15 15 defp is_dict(list) when is_list(list) do
16 - Enum.all?(list, fn(elem) -> is_tuple(elem) && tuple_size(elem) == 2 end)
16 + Enum.all?(list, fn(element) ->
17 + is_tuple(element) && tuple_size(element) == 2
18 + end)
17 19 end
18 20 defp is_dict(_), do: false
Loading more files…