Skip to content

Commit

Permalink
Check otp_app on compile time in Avrora.Client (#129)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Sergey Fedorov <oni.strech@gmail.com>
  • Loading branch information
rockneurotiko and Strech authored Jan 14, 2025
1 parent 71be139 commit d23010e
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions lib/avrora/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,6 @@ defmodule Avrora.Client do
@opts unquote(opts)
@otp_app Keyword.get(@opts, :otp_app)

def schemas_path do
path = get(@opts, :schemas_path, "./priv/schemas")

if is_nil(@otp_app), do: Path.expand(path), else: Application.app_dir(@otp_app, path)
end

def registry_ssl_cacert_path do
path = get(@opts, :registry_ssl_cacert_path, nil)

if is_nil(path), do: nil, else: Path.expand(path)
end

def registry_url, do: get(@opts, :registry_url, nil)
def registry_auth, do: get(@opts, :registry_auth, nil)
def registry_user_agent, do: get(@opts, :registry_user_agent, "Avrora/#{version()} Elixir")
Expand All @@ -134,10 +122,14 @@ defmodule Avrora.Client do

if is_nil(@otp_app) do
def self, do: __MODULE__
def schemas_path, do: Path.expand(get(@opts, :schemas_path, "./priv/schemas"))
def registry_ssl_cacert_path, do: nil

defp get(opts, key, default), do: Keyword.get(opts, key, default)
else
def self, do: get(@opts, :config, __MODULE__)
def schemas_path, do: Application.app_dir(@otp_app, get(@opts, :schemas_path, "./priv/schemas"))
def registry_ssl_cacert_path, do: Path.expand(get(@opts, :registry_ssl_cacert_path, nil))

defp get(opts, key, default) do
app_opts = Application.get_env(@otp_app, unquote(:"Elixir.#{module}"), [])
Expand Down

0 comments on commit d23010e

Please sign in to comment.