diff options
author | Tristan Sloughter <[email protected]> | 2013-06-11 15:41:12 -0700 |
---|---|---|
committer | Tristan Sloughter <[email protected]> | 2013-06-11 15:41:12 -0700 |
commit | f0c5d882d5516d8a7c6a405721c6990317bee9ec (patch) | |
tree | 00966a38b66b5c5ac304a43e672d9933b542e5ce /src/rlx_util.erl | |
parent | 834fc00544e4222e5fe1713c33d16e5192de33fe (diff) | |
parent | 96367559f0495919831e0694a46cad3874c52ac4 (diff) | |
download | relx-f0c5d882d5516d8a7c6a405721c6990317bee9ec.tar.gz relx-f0c5d882d5516d8a7c6a405721c6990317bee9ec.tar.bz2 relx-f0c5d882d5516d8a7c6a405721c6990317bee9ec.zip |
Merge pull request #8 from ericbmerritt/master
bug fixes and cleanup to the vagrant file.
Diffstat (limited to 'src/rlx_util.erl')
-rw-r--r-- | src/rlx_util.erl | 13 |
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}}) -> |