Small, dependency-free helpers used across MishkaInstaller.
It covers unix timestamps, random strings, and two helpers that build Erlang
match specifications used by the
Mnesia query layer (MishkaInstaller.Helper.MnesiaAssistant).
Summary
Functions
Builds the head tuple of an Erlang match specification.
Translates a result selector into the Erlang match-spec result body.
Returns the current time as a unix timestamp in seconds.
Returns an uppercase random string of count characters.
Functions
@spec erlang_fields(tuple(), [atom()], [atom()], pos_integer()) :: tuple()
Builds the head tuple of an Erlang match specification.
Walks the record keys and, for each field present in fields, places a numbered match
variable (:"$1", :"$2", ...); every other field becomes the wildcard :_.
Examples
iex> MishkaInstaller.Helper.Extra.erlang_fields({Person}, [:id, :name], [:name], 1)
{Person, :_, :"$1"}
Translates a result selector into the Erlang match-spec result body.
:all->[:"$_"](whole record):selected->[:"$$"](selected fields)- any other term is returned unchanged.
@spec get_unix_time() :: integer()
Returns the current time as a unix timestamp in seconds.
Examples
iex> is_integer(MishkaInstaller.Helper.Extra.get_unix_time())
true
@spec randstring(non_neg_integer()) :: String.t()
Returns an uppercase random string of count characters.
Not suitable for security-sensitive values.
Examples
iex> String.length(MishkaInstaller.Helper.Extra.randstring(8))
8