Current section
Files
Jump to
Current section
Files
lib/fixme.ex
defmodule FIXME do
defmacro fixme(
{:-, _, [{:-, _, [year, month]}, day]},
message,
opts \\ []
) do
{opts, _} = Code.eval_quoted(opts)
# Injectable "today" for tests.
current_date = opts[:today] || (:calendar.local_time |> elem(0))
warn = case opts[:warn] do
nil -> Application.get_env(:fixme, :warn, false)
warn -> warn
end
fixme_date = {year, month, day}
message = "Fix by #{year}-#{zeropad month}-#{zeropad day}: #{message}"
if current_date >= fixme_date do
raise message
end
if warn do
%{file: file, line: line} = __CALLER__
:elixir_errors.warn line, file, message
end
end
defp zeropad(number) do
number |> Integer.to_string |> String.rjust(2, ?0)
end
end