Remove application configuration
This commit is contained in:
parent
529014c8f4
commit
76cfb574a3
2 changed files with 6 additions and 48 deletions
|
@ -1,30 +0,0 @@
|
|||
# This file is responsible for configuring your application
|
||||
# and its dependencies with the aid of the Mix.Config module.
|
||||
use Mix.Config
|
||||
|
||||
# This configuration is loaded before any dependency and is restricted
|
||||
# to this project. If another project depends on this project, this
|
||||
# file won't be loaded nor affect the parent project. For this reason,
|
||||
# if you want to provide default values for your application for
|
||||
# 3rd-party users, it should be done in your "mix.exs" file.
|
||||
|
||||
# You can configure for your application as:
|
||||
#
|
||||
# config :auto_linker, key: :value
|
||||
#
|
||||
# And access this configuration in your application as:
|
||||
#
|
||||
# Application.get_env(:auto_linker, :key)
|
||||
#
|
||||
# Or configure a 3rd-party app:
|
||||
#
|
||||
# config :logger, level: :info
|
||||
#
|
||||
|
||||
# It is also possible to import configuration files, relative to this
|
||||
# directory. For example, you can emulate configuration per environment
|
||||
# by uncommenting the line below and defining dev.exs, test.exs and such.
|
||||
# Configuration from the imported file will override the ones defined
|
||||
# here (which is why it is important to import them last).
|
||||
#
|
||||
# import_config "#{Mix.env}.exs"
|
|
@ -38,7 +38,10 @@ defmodule AutoLinker.Parser do
|
|||
|
||||
@tlds "./priv/tlds.txt" |> File.read!() |> String.split("\n", trim: true) |> MapSet.new()
|
||||
|
||||
@default_opts ~w(url validate_tld)a
|
||||
@default_opts %{
|
||||
url: true,
|
||||
validate_tld: true
|
||||
}
|
||||
|
||||
@doc """
|
||||
Parse the given string, identifying items to link.
|
||||
|
@ -52,27 +55,12 @@ defmodule AutoLinker.Parser do
|
|||
"""
|
||||
|
||||
def parse(input, opts \\ %{})
|
||||
def parse(input, opts) when is_binary(input), do: {input, nil} |> parse(opts) |> elem(0)
|
||||
def parse(input, opts) when is_binary(input), do: {input, %{}} |> parse(opts) |> elem(0)
|
||||
def parse(input, list) when is_list(list), do: parse(input, Enum.into(list, %{}))
|
||||
|
||||
def parse(input, opts) do
|
||||
config =
|
||||
:auto_linker
|
||||
|> Application.get_env(:opts, [])
|
||||
|> Enum.into(%{})
|
||||
|> Map.put(
|
||||
:attributes,
|
||||
Application.get_env(:auto_linker, :attributes, [])
|
||||
)
|
||||
opts = Map.merge(@default_opts, opts)
|
||||
|
||||
opts =
|
||||
Enum.reduce(@default_opts, opts, fn opt, acc ->
|
||||
if is_nil(opts[opt]) and is_nil(config[opt]) do
|
||||
Map.put(acc, opt, true)
|
||||
else
|
||||
acc
|
||||
end
|
||||
end)
|
||||
|
||||
do_parse(input, Map.merge(config, opts))
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue