-
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.
- Loading branch information
Showing
73 changed files
with
3,251 additions
and
116 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Config | ||
|
||
if config_env() == :test do | ||
config :coloured_flow, | ||
ColouredFlow.Runner.Storage, | ||
repo: ColouredFlow.TestRepo | ||
|
||
config :coloured_flow, | ||
ecto_repos: [ColouredFlow.TestRepo] | ||
|
||
config :coloured_flow, ColouredFlow.TestRepo, | ||
database: "coloured_flow_test", | ||
username: "postgres", | ||
password: "postgres", | ||
hostname: "localhost", | ||
pool: Ecto.Adapters.SQL.Sandbox | ||
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
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,48 @@ | ||
defmodule ColouredFlow.Definition.ColourSet.Value do | ||
@moduledoc """ | ||
The value of a colour set. | ||
""" | ||
|
||
@doc """ | ||
Check if the value is valid. | ||
""" | ||
# credo:disable-for-next-line JetCredo.Checks.ExplicitAnyType | ||
@spec valid?(value :: term()) :: boolean() | ||
def valid?(term) | ||
|
||
def valid?(int) when is_integer(int), do: true | ||
def valid?(float) when is_float(float), do: true | ||
def valid?(bool) when is_boolean(bool), do: true | ||
def valid?(binary) when is_binary(binary), do: true | ||
def valid?({}), do: true | ||
|
||
# union: place it before tuple | ||
def valid?({tag, value}) when is_atom(tag) do | ||
valid?(value) | ||
end | ||
|
||
# tuple | ||
def valid?(tuple) when is_tuple(tuple) and tuple_size(tuple) >= 2 do | ||
values = Tuple.to_list(tuple) | ||
|
||
Enum.all?(values, &valid?/1) | ||
end | ||
|
||
# map | ||
def valid?(map) when is_map(map) and map_size(map) >= 1 do | ||
Enum.all?(map, fn | ||
{key, value} when is_atom(key) -> valid?(value) | ||
_other -> false | ||
end) | ||
end | ||
|
||
# enum | ||
def valid?(enum) when is_atom(enum), do: true | ||
|
||
# list | ||
def valid?(list) when is_list(list) do | ||
Enum.all?(list, &valid?/1) | ||
end | ||
|
||
def valid?(_value), do: false | ||
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
Oops, something went wrong.