aboutsummaryrefslogtreecommitdiffstats
path: root/src/rlx_util.erl
diff options
context:
space:
mode:
authorEric <[email protected]>2013-06-11 23:52:51 +0200
committerEric <[email protected]>2013-06-11 23:52:51 +0200
commit96367559f0495919831e0694a46cad3874c52ac4 (patch)
tree00966a38b66b5c5ac304a43e672d9933b542e5ce /src/rlx_util.erl
parent834fc00544e4222e5fe1713c33d16e5192de33fe (diff)
downloadrelx-96367559f0495919831e0694a46cad3874c52ac4.tar.gz
relx-96367559f0495919831e0694a46cad3874c52ac4.tar.bz2
relx-96367559f0495919831e0694a46cad3874c52ac4.zip
numerous small bugfixes
Diffstat (limited to 'src/rlx_util.erl')
-rw-r--r--src/rlx_util.erl13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/rlx_util.erl b/src/rlx_util.erl
index c2b2081..ac6af5c 100644
--- a/src/rlx_util.erl
+++ b/src/rlx_util.erl
@@ -24,6 +24,7 @@
-export([mkdir_p/1,
to_binary/1,
to_string/1,
+ to_atom/1,
is_error/1,
error_reason/1,
indent/1,
@@ -59,6 +60,7 @@ to_binary(String) when erlang:is_list(String) ->
to_binary(Bin) when erlang:is_binary(Bin) ->
Bin.
+-spec to_string(binary() | string() | atom()) -> string().
to_string(Binary) when erlang:is_binary(Binary) ->
erlang:binary_to_list(Binary);
to_string(Atom) when erlang:is_atom(Atom) ->
@@ -66,6 +68,17 @@ to_string(Atom) when erlang:is_atom(Atom) ->
to_string(Else) when erlang:is_list(Else) ->
Else.
+-spec to_atom(atom() | string() | binary()) -> atom().
+to_atom(Binary)
+ when erlang:is_binary(Binary) ->
+ erlang:list_to_atom(to_string(Binary));
+to_atom(String)
+ when erlang:is_list(String) ->
+ erlang:list_to_atom(String);
+to_atom(Atom)
+ when erlang:is_atom(Atom) ->
+ Atom.
+
%% @doc get the reason for a particular relx error
-spec error_reason(relx:error()) -> any().
error_reason({error, {_, Reason}}) ->