forked from zhangsoledad/alchemic_avatar
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.ex
60 lines (52 loc) · 1.19 KB
/
config.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
defmodule AlchemicAvatar.Config do
@moduledoc """
This module provides configuration.
The following are valid configuration items.
| name | type | default |
| :----------------- | :------ | -------: |
| cache_base_path | binary | "static" |
| colors_palette | atom | :google or :iwanthue |
| weight | int | 300 |
| annotate_position | binary | "-0+5" |
| app_name | atom | N/A |
"""
defp config do
Application.get_all_env(:alchemic_avatar)
end
@doc """
cache_base_path
"""
def cache_base_path do
Keyword.get(config, :cache_base_path, "static")
end
@doc """
app_name
"""
def app_name do
case Keyword.fetch(config, :app_name) do
{:ok, name} -> name
_ ->
raise ArgumentError, message: """
you need set app_name in your config
"""
end
end
@doc """
colors_palette
"""
def colors_palette do
Keyword.get(config, :colors_palette, :google)
end
@doc """
weight
"""
def weight do
Keyword.get(config, :weight, 300)
end
@doc """
annotate_position
"""
def annotate_position do
Keyword.get(config, :annotate_position, "-0+5")
end
end