Skip to content

Commit fa2a935

Browse files
committed
Initial commit
0 parents  commit fa2a935

21 files changed

+914
-0
lines changed

.editorconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
[*]
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
indent_style = space
10+
indent_size = 2
11+
12+
[*.erl]
13+
max_line_length = 180
14+
15+
[*.py]
16+
indent_style = space
17+
indent_size = 4
18+
19+
[Makefile,*.mk]
20+
indent_style = tab
21+
22+
[*.md]
23+
trim_trailing_whitespace = false
24+

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
_build
2+
.DS_Store
3+
deps
4+
ebin
5+
log
6+
*.beam
7+
*.mnesia
8+
*.txt*
9+
*.swp*
10+
erl_crash.dump
11+
.eunit
12+
ext
13+
.rebar
14+
.erlang.mk
15+
kafe.d
16+
test/eunit/
17+
docker-compose.yml

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
HAS_ELIXIR=1
2+
3+
include bu.mk
4+

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
3+
# Erlang/Elixir module for fixer.io #
4+
5+
Copyright (c) 2016 Bots Unit
6+
7+
__Version:__ 0.0.1
8+
9+
__Authors:__ Gregoire Lejeune ([`[email protected]`](mailto:[email protected])).
10+
11+
12+
13+
## Licence ##
14+
15+
Copyright (c) 2016, Bots Unit<br />
16+
All rights reserved.
17+
18+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
19+
20+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
21+
1. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
22+
23+
24+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
26+
27+
## Modules ##
28+
29+
30+
<table width="100%" border="0" summary="list of modules">
31+
<tr><td><a href="https://gitlab.botsunit.com/msaas/idcheckio/tree/master/doc/fixer.md" class="module">fixer</a></td></tr></table>
32+

bu.mk

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
# Copyright (c) 2013-2015, Loïc Hoguin <[email protected]>
2+
# Copyright (c) 2016, Grégoire Lejeune
3+
#
4+
# Permission to use, copy, modify, and/or distribute this software for any
5+
# purpose with or without fee is hereby granted, provided that the above
6+
# copyright notice and this permission notice appear in all copies.
7+
#
8+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15+
16+
.PHONY: doc
17+
18+
all: compile-erl
19+
20+
# Verbosity.
21+
22+
V ?= 0
23+
24+
verbose_0 = @
25+
verbose_2 = set -x;
26+
verbose = $(verbose_$(V))
27+
28+
# Utils
29+
30+
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
31+
current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
32+
33+
# Common
34+
35+
CP = cp
36+
CP_R = cp -r
37+
RM = rm
38+
RM_RF = rm -rf
39+
RM_F = rm -f
40+
MKDIR_P = mkdir -p
41+
42+
# Config
43+
44+
NODE_HOST ?= 127.0.0.1
45+
ifneq ("$(wildcard config/$(current_dir).config)","")
46+
ERL_CONFIG="config/$(current_dir).config"
47+
endif
48+
49+
# Core functions.
50+
51+
empty :=
52+
space := $(empty) $(empty)
53+
tab := $(empty) $(empty)
54+
comma := ,
55+
56+
define newline
57+
58+
59+
endef
60+
61+
# Template
62+
63+
define render_template
64+
$(verbose) printf -- '$(subst $(newline),\n,$(subst %,%%,$(subst ','\'',$(subst $(tab),$(WS),$(call $(1))))))\n' > $(2)
65+
endef
66+
67+
# Erlang
68+
69+
ERL = erl +A0 -noinput -boot start_clean
70+
71+
define erlang
72+
$(ERL) -noshell -s init stop -eval "$(subst $(newline),,$(subst ",\",$(1)))"
73+
endef
74+
75+
define get_version.erl
76+
{ok, [{application, _, X}]} = file:consult("$(1)"),
77+
{vsn, VSN} = lists:keyfind(vsn, 1, X),
78+
io:format("~s", [VSN]).
79+
endef
80+
81+
define get_app_name.erl
82+
{ok, [{application, AppName, _}]} = file:consult("$(1)"),
83+
io:format("~s", [AppName]).
84+
endef
85+
86+
ifndef WS
87+
ifdef SP
88+
WS = $(subst a,,a $(wordlist 1,$(SP),a a a a a a a a a a a a a a a a a a a a))
89+
else
90+
WS = $(tab)
91+
endif
92+
endif
93+
94+
# rebar3
95+
96+
FIND_REBAR = \
97+
REBAR_BIN=; \
98+
for x in ./rebar3 rebar3; do \
99+
if type "$${x%% *}" >/dev/null 2>/dev/null; then REBAR_BIN=$$x; break; fi; \
100+
done; \
101+
if [ -z "$$REBAR_BIN" ]; then echo 1>&2 "Unable to find rebar3"; exit 2; fi
102+
REBAR = $(FIND_REBAR); $$REBAR_BIN
103+
104+
# Project
105+
106+
APP_SRC=$(shell find src -name "*.app.src")
107+
ifeq ($(APP_SRC),)
108+
else
109+
APP_VERSION=$(shell $(call erlang,$(call get_version.erl,${APP_SRC})))
110+
APP_NAME=$(shell $(call erlang,$(call get_app_name.erl,${APP_SRC})))
111+
endif
112+
113+
# mix
114+
115+
MIX = mix
116+
117+
# Default tasks
118+
ifeq ($(HAS_ELIXIR), 1)
119+
120+
compile-ex: elixir clean
121+
$(verbose) $(MIX) deps.get
122+
$(verbose) $(MIX) deps.compile
123+
$(verbose) $(MIX) compile
124+
125+
elixir: ## Generate Elixir bindings (mix.exs and libs)
126+
$(verbose) $(REBAR) elixir generate_mix
127+
$(verbose) $(REBAR) elixir generate_lib
128+
129+
distclean-ex: clean-ex
130+
$(verbose) $(RM_F) mix.lock
131+
132+
clean-ex:
133+
$(verbose) $(RM_RF) _build deps
134+
135+
dist-ex: clean compile-ex
136+
137+
COMPILE=compile-erl compile-ex
138+
CLEAN=clean-erl clean-ex
139+
DISTCLEAN=distclean-erl distclean-ex
140+
DIST=dist-erl dist-ex
141+
else
142+
COMPILE=compile-erl
143+
CLEAN=clean-erl
144+
DISTCLEAN=distclean-erl
145+
DIST=dist-erl
146+
endif
147+
148+
ifdef NO_LINT
149+
LINT=
150+
else
151+
lint:
152+
$(verbose) $(REBAR) lint
153+
154+
LINT=lint
155+
endif
156+
157+
compile-erl:
158+
$(verbose) $(REBAR) update
159+
$(verbose) $(REBAR) compile
160+
161+
tests: ## Run tests
162+
$(verbose) $(REBAR) eunit
163+
164+
doc:: ## Generate doc
165+
$(verbose) $(REBAR) as doc edoc
166+
167+
dist: $(DIST) ## Create a distribution
168+
169+
clean: $(CLEAN) ## Clean
170+
171+
distclean: $(DISTCLEAN) ## Clean the distribution
172+
173+
dev: compile-erl
174+
ifdef ERL_CONFIG
175+
$(verbose) echo "Start with configuration $(ERL_CONFIG)"
176+
$(verbose) erl -pa _build/default/lib/*/ebin _build/default/lib/*/include -config ${ERL_CONFIG} -name ${current_dir}@${NODE_HOST} -setcookie ${current_dir}
177+
else
178+
$(verbose) erl -pa _build/default/lib/*/ebin _build/default/lib/*/include -name ${current_dir}@${NODE_HOST} -setcookie ${current_dir}
179+
endif
180+
181+
dist-erl: clean compile-erl tests $(LINT) doc
182+
183+
clean-erl:
184+
$(verbose) $(RM_RF) _build test/eunit
185+
186+
distclean-erl: clean-erl
187+
$(verbose) $(RM_F) rebar.lock
188+
189+
info: ## Display application informations
190+
$(verbose) echo "App source file: $(APP_SRC)"
191+
$(verbose) echo "App name: $(APP_NAME)"
192+
$(verbose) echo "App version: $(APP_VERSION)"
193+
194+
tag: DO_TAG ?= $(shell read -p "tag version $(APP_VERSION) (y/n) [n]: " pwd; echo $$pwd)
195+
196+
tag: ## Create a git tag
197+
$(verbose) echo $(if $(findstring $(DO_TAG),y,Y,yes,Yes,YES),$(shell git tag $(APP_VERSION)),)
198+
199+
# Elixir
200+
201+
local.hex: ## Install hexfor Mix
202+
$(MIX) local.hex --force
203+
204+
local.rebar: ## Install rebar for Mix
205+
$(MIX) local.rebar --force
206+
207+
# Update
208+
209+
BU_MK_REPO ?= https://github.com/botsunit/bu.mk
210+
BU_MK_COMMIT ?=
211+
BU_MK_BUILD_DIR ?= .bu.mk.build
212+
213+
bu-mk: ## Update bu.mk
214+
git clone $(BU_MK_REPO) $(BU_MK_BUILD_DIR)
215+
ifdef BU_MK_COMMIT
216+
cd $(BU_MK_BUILD_DIR) && git checkout $(BU_MK_COMMIT)
217+
endif
218+
$(CP) $(BU_MK_BUILD_DIR)/bu.mk ./bu.mk
219+
$(RM_RF) $(BU_MK_BUILD_DIR)
220+
221+
# Help
222+
223+
help: ## Show this help.
224+
$(verbose) echo "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\033[33m\1\\033[m:\2/' | column -c2 -t -s :)"
225+

config/fixerio.config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{fixerio, [
3+
{base, <<"EUR">>},
4+
{preload, {<<"2016-11-01">>, today}},
5+
{url, <<"http://api.fixer.io/">>}
6+
]}
7+
].

doc/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
3+
# Erlang/Elixir module for fixer.io #
4+
5+
Copyright (c) 2016 Bots Unit
6+
7+
__Version:__ 0.0.1
8+
9+
__Authors:__ Gregoire Lejeune ([`[email protected]`](mailto:[email protected])).
10+
11+
12+
13+
## Licence ##
14+
15+
Copyright (c) 2016, Bots Unit<br />
16+
All rights reserved.
17+
18+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
19+
20+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
21+
1. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
22+
23+
24+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
26+
27+
## Modules ##
28+
29+
30+
<table width="100%" border="0" summary="list of modules">
31+
<tr><td><a href="fixer.md" class="module">fixer</a></td></tr></table>
32+

doc/edoc-info

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
%% encoding: UTF-8
2+
{application,fixer}.
3+
{modules,[fixer]}.

0 commit comments

Comments
 (0)