From 975c0c92b9dbfcbcd6c8d54c5dd2b9753bba44f5 Mon Sep 17 00:00:00 2001 From: Ryan Daigle Date: Wed, 12 Jun 2024 17:55:11 -0400 Subject: [PATCH] Add mix test.watch --- lib/context.ex | 5 +++-- mix.exs | 25 ++++++++++++++----------- mix.lock | 4 +++- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/context.ex b/lib/context.ex index 5179a0a..194179e 100644 --- a/lib/context.ex +++ b/lib/context.ex @@ -1,5 +1,4 @@ defmodule Metrix.Context do - use Agent @doc """ @@ -8,6 +7,7 @@ defmodule Metrix.Context do def start_link(initial_context) when is_list(initial_context) do Enum.into(initial_context, %{}) |> start_link end + def start_link(initial_context) when is_map(initial_context) do Agent.start_link(fn -> initial_context end, name: __MODULE__) end @@ -16,13 +16,14 @@ defmodule Metrix.Context do Gets current context """ def get do - Agent.get(__MODULE__, &(&1)) + Agent.get(__MODULE__, & &1) end @doc """ Adds the `metadata` to the context """ def put(metadata) when is_list(metadata), do: Enum.into(metadata, %{}) |> put + def put(metadata) when is_map(metadata) do Agent.update(__MODULE__, &Map.merge(&1, metadata)) end diff --git a/mix.exs b/mix.exs index 9505038..e779c99 100644 --- a/mix.exs +++ b/mix.exs @@ -2,21 +2,22 @@ defmodule Metrix.Mixfile do use Mix.Project def project do - [app: :metrix, - version: "1.0.0", - description: description(), - elixir: ">= 1.3.0", - deps: deps(), - package: package(), - source_url: "https://github.com/rwdaigle/metrix"] + [ + app: :metrix, + version: "1.0.0", + description: description(), + elixir: ">= 1.3.0", + deps: deps(), + package: package(), + source_url: "https://github.com/rwdaigle/metrix" + ] end # Configuration for the OTP application # # Type `mix help compile.app` for more information def application do - [applications: [:logger, :logfmt], - mod: {Metrix, []}] + [applications: [:logger, :logfmt], mod: {Metrix, []}] end # Dependencies can be Hex packages: @@ -30,7 +31,8 @@ defmodule Metrix.Mixfile do # Type `mix help deps` for more examples and options defp deps do [ - {:logfmt, "~> 3.3"} + {:logfmt, "~> 3.3"}, + {:mix_test_watch, "~> 1.0", only: [:dev, :test], runtime: false} ] end @@ -50,7 +52,8 @@ defmodule Metrix.Mixfile do "Kevin Lewis ", "Emanuel Evans ", "Stephen Ball ", - "David Santoso"], + "David Santoso" + ], licenses: ["MIT"], links: %{"GitHub" => "https://github.com/rwdaigle/metrix"}, files: ~w(mix.exs lib README.md) diff --git a/mix.lock b/mix.lock index e4fdc6f..0634c93 100644 --- a/mix.lock +++ b/mix.lock @@ -1,3 +1,5 @@ %{ - "logfmt": {:hex, :logfmt, "3.3.3", "6521ee4a5c532088e15d487fab9f736c07bdd161d643560c73cd4b10685deb65", [:mix], [], "hexpm", "dbd51cd3fe37c3429b9bd687bad1f531a533505f4a641592129e7a47e24104d1"} + "file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"}, + "logfmt": {:hex, :logfmt, "3.3.3", "6521ee4a5c532088e15d487fab9f736c07bdd161d643560c73cd4b10685deb65", [:mix], [], "hexpm", "dbd51cd3fe37c3429b9bd687bad1f531a533505f4a641592129e7a47e24104d1"}, + "mix_test_watch": {:hex, :mix_test_watch, "1.2.0", "1f9acd9e1104f62f280e30fc2243ae5e6d8ddc2f7f4dc9bceb454b9a41c82b42", [:mix], [{:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "278dc955c20b3fb9a3168b5c2493c2e5cffad133548d307e0a50c7f2cfbf34f6"}, }