-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from esl/configurable-env-parser
Configurable env parser
- Loading branch information
Showing
19 changed files
with
455 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[{elvis, [ | ||
{config, [ | ||
#{dirs => ["src", "src/*", "scenarios"], | ||
filter => "*.erl", | ||
ruleset => erl_files, | ||
rules => [ | ||
{elvis_style, invalid_dynamic_call, #{ignore => [amoc_user]}}, | ||
{elvis_style, export_used_types, disable}, | ||
{elvis_style, no_throw, #{ignore => [{amoc_config, get, 2}] }}, | ||
{elvis_text_style, line_length, #{skip_comments => whole_line }}, | ||
{elvis_style, no_block_expressions, disable} | ||
]}, | ||
#{dirs => ["test"], | ||
filter => "*.erl", | ||
ruleset => erl_files, | ||
rules => [ | ||
{elvis_style, function_naming_convention, #{regex => "^[a-z]([a-z0-9]*_?)*$"}}, | ||
{elvis_style, atom_naming_convention, #{regex => "^[a-z]([a-z0-9]*_?)*(_SUITE)?$"}}, | ||
{elvis_style, dont_repeat_yourself, #{min_complexity => 50}}, | ||
{elvis_style, no_debug_call, disable}, | ||
{elvis_style, no_throw, disable}, | ||
{elvis_style, no_import, disable} | ||
]}, | ||
#{dirs => ["."], | ||
filter => "rebar.config", | ||
ruleset => rebar_config} | ||
]} | ||
]}]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
%%============================================================================== | ||
%% Copyright 2023 Erlang Solutions Ltd. | ||
%% Licensed under the Apache License, Version 2.0 (see LICENSE file) | ||
%%============================================================================== | ||
%% This module implements the default parser for the amoc_config_env module | ||
%%============================================================================== | ||
-module(amoc_config_parser). | ||
-behaviour(amoc_config_env). | ||
|
||
-export([parse_value/1]). | ||
|
||
-ifdef(TEST). | ||
%% exported for testing only | ||
-export([format/2]). | ||
-else. | ||
-ignore_xref([format/2]). | ||
-dialyzer({nowarn_function, [format/2]}). | ||
-endif. | ||
|
||
%% ------------------------------------------------------------------ | ||
%% API | ||
%% ------------------------------------------------------------------ | ||
|
||
-spec parse_value(string() | binary()) -> {ok, amoc_config:value()} | {error, any()}. | ||
parse_value(Binary) when is_binary(Binary) -> | ||
parse_value(binary_to_list(Binary)); | ||
parse_value(String) when is_list(String) -> | ||
try | ||
{ok, Tokens, _} = erl_scan:string(String ++ "."), | ||
{ok, _} = erl_parse:parse_term(Tokens) | ||
catch | ||
_:E -> {error, E} | ||
end. | ||
|
||
-spec format(any(), binary) -> binary(); | ||
(any(), string) -> string(). | ||
format(Value, binary) -> | ||
list_to_binary(format(Value, string)); | ||
format(Value, string) -> | ||
lists:flatten(io_lib:format("~tp", [Value])). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.