-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consolidate all config concerns in
Stow.Config
- Loading branch information
Showing
6 changed files
with
33 additions
and
28 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
defmodule Stow.Config do | ||
@moduledoc false | ||
alias Stow.Http.Client | ||
|
||
@default_base_dir "./stow_data" | ||
@base_dir Application.compile_env(:stow, :base_dir) | ||
@file_io Application.compile_env(:stow, :file_io, Elixir.File) | ||
|
||
def base_dir(opts \\ []) do | ||
Keyword.get(opts, :base_dir, @base_dir) || | ||
System.get_env("LB_STOW_BASE_DIR") || | ||
default_base_dir() | ||
end | ||
|
||
def default_base_dir, do: @default_base_dir | ||
|
||
def file_io, do: @file_io | ||
|
||
def http_client(client \\ "httpc") do | ||
Application.get_env(:stow, :http_client, runtime_client(client)) | ||
end | ||
|
||
defp runtime_client(client), do: client |> Macro.camelize() |> then(&Module.concat(Client, &1)) | ||
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
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
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
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
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