Last active
April 15, 2024 11:33
-
-
Save hiway/d3981fd49175e50ef3d67c2d995684cc to your computer and use it in GitHub Desktop.
Elixir snippets for writing libraries
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
defmodule ConfigValidate do | |
def ensure_value_is_not_nil(key, value, suggestion) do | |
if value == nil do | |
raise """ | |
Please set #{key} under mix.exs project configuration. | |
def project do | |
[ | |
... | |
#{suggestion} | |
... | |
] | |
end | |
""" | |
end | |
end | |
end |
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
defmodule GitInfo do | |
@spec author_email() :: binary() | |
def author_email() do | |
case System.cmd("git", ["config", "--get", "user.email"]) do | |
{email, 0} -> email |> String.trim() | |
_ -> "[email protected]" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment