Current section

Files

Jump to
blah src blah@other.erl
Raw

src/blah@other.erl

-module(blah@other).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([currency/0, latitude/0, longitude/0, semver/0, mongo_object_id/0, uuid/0, language_code/0]).
-spec currency() -> {binary(), binary(), binary()}.
currency() ->
blah@en@other:currency().
-spec latitude() -> float().
latitude() ->
_assert_subject = gleam@int:power(
10,
gleam@int:to_float(blah@utils:get_random_int(3, 6))
),
{ok, Nonce} = case _assert_subject of
{ok, _} -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Assertion pattern match failed"/utf8>>,
value => _assert_fail,
module => <<"blah/other"/utf8>>,
function => <<"latitude"/utf8>>,
line => 14})
end,
case Nonce of
+0.0 -> +0.0;
-0.0 -> -0.0;
Gleam@denominator -> gleam@float:ceiling(
(((rand:uniform() * 180.0) - 90.0) * Nonce)
)
/ Gleam@denominator
end.
-spec longitude() -> float().
longitude() ->
_assert_subject = gleam@int:power(
10,
gleam@int:to_float(blah@utils:get_random_int(3, 6))
),
{ok, Nonce} = case _assert_subject of
{ok, _} -> _assert_subject;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Assertion pattern match failed"/utf8>>,
value => _assert_fail,
module => <<"blah/other"/utf8>>,
function => <<"longitude"/utf8>>,
line => 19})
end,
case Nonce of
+0.0 -> +0.0;
-0.0 -> -0.0;
Gleam@denominator -> gleam@float:ceiling(
((rand:uniform() * 360.0) - 180.0) * Nonce
)
/ Gleam@denominator
end.
-spec semver() -> binary().
semver() ->
_pipe = gleam@list:repeat(<<""/utf8>>, blah@utils:get_random_int(2, 4)),
_pipe@1 = gleam@list:map(_pipe, fun(_) -> gleam@int:random(32) end),
_pipe@2 = gleam@list:map(_pipe@1, fun gleam@int:to_string/1),
gleam@string:join(_pipe@2, <<"."/utf8>>).
-spec mongo_object_id() -> binary().
mongo_object_id() ->
_pipe = gleam@list:repeat(<<""/utf8>>, 24),
_pipe@1 = gleam@list:map(_pipe, fun(_) -> gleam@int:random(16) end),
_pipe@4 = gleam@list:map(_pipe@1, fun(Digit) -> _pipe@2 = Digit,
_pipe@3 = gleam@int:to_base16(_pipe@2),
gleam@string:lowercase(_pipe@3) end),
gleam@string:join(_pipe@4, <<""/utf8>>).
-spec uuid() -> binary().
uuid() ->
_pipe = gleam@list:repeat(<<""/utf8>>, 32),
_pipe@1 = gleam@list:map(_pipe, fun(_) -> gleam@int:random(16) end),
_pipe@4 = gleam@list:map(_pipe@1, fun(Digit) -> _pipe@2 = Digit,
_pipe@3 = gleam@int:to_base16(_pipe@2),
gleam@string:lowercase(_pipe@3) end),
gleam@list:fold(
_pipe@4,
<<""/utf8>>,
fun(Uuid, Char) ->
Uuid@1 = gleam@string:append(Uuid, Char),
case gleam@string:length(Uuid@1) of
8 ->
gleam@string:append(Uuid@1, <<"-"/utf8>>);
13 ->
gleam@string:append(Uuid@1, <<"-"/utf8>>);
18 ->
gleam@string:append(Uuid@1, <<"-"/utf8>>);
23 ->
gleam@string:append(Uuid@1, <<"-"/utf8>>);
_ ->
Uuid@1
end
end
).
-spec language_code() -> binary().
language_code() ->
blah@utils:get_random_item(
[<<"aa"/utf8>>,
<<"ab"/utf8>>,
<<"ae"/utf8>>,
<<"af"/utf8>>,
<<"ak"/utf8>>,
<<"am"/utf8>>,
<<"an"/utf8>>,
<<"ar"/utf8>>,
<<"as"/utf8>>,
<<"av"/utf8>>,
<<"ay"/utf8>>,
<<"az"/utf8>>,
<<"ba"/utf8>>,
<<"be"/utf8>>,
<<"bg"/utf8>>,
<<"bh"/utf8>>,
<<"bi"/utf8>>,
<<"bm"/utf8>>,
<<"bn"/utf8>>,
<<"bo"/utf8>>,
<<"br"/utf8>>,
<<"bs"/utf8>>,
<<"ca"/utf8>>,
<<"ce"/utf8>>,
<<"ch"/utf8>>,
<<"co"/utf8>>,
<<"cr"/utf8>>,
<<"cs"/utf8>>,
<<"cu"/utf8>>,
<<"cv"/utf8>>,
<<"c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