From 799fa4fe32d9e7060e9a124a90ee0e291bab497e Mon Sep 17 00:00:00 2001 From: Kieran Eglin Date: Wed, 1 May 2024 09:37:15 -0700 Subject: [PATCH] Namespaced notification modules under lifecycle --- config/config.exs | 2 +- lib/pinchflat/fast_indexing/fast_indexing_worker.ex | 2 +- .../{ => lifecycle}/notifications/apprise_command_runner.ex | 2 +- lib/pinchflat/{ => lifecycle}/notifications/command_runner.ex | 4 ++-- .../{ => lifecycle}/notifications/source_notifications.ex | 2 +- .../lifecycle/user_scripts/user_script_command_runner.ex | 0 .../slow_indexing/media_collection_indexing_worker.ex | 2 +- .../{ => lifecycle}/notifications/command_runner_test.exs | 4 ++-- .../notifications/source_notifications_test.exs | 4 ++-- test/test_helper.exs | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) rename lib/pinchflat/{ => lifecycle}/notifications/apprise_command_runner.ex (85%) rename lib/pinchflat/{ => lifecycle}/notifications/command_runner.ex (92%) rename lib/pinchflat/{ => lifecycle}/notifications/source_notifications.ex (96%) create mode 100644 lib/pinchflat/lifecycle/user_scripts/user_script_command_runner.ex rename test/pinchflat/{ => lifecycle}/notifications/command_runner_test.exs (92%) rename test/pinchflat/{ => lifecycle}/notifications/source_notifications_test.exs (96%) diff --git a/config/config.exs b/config/config.exs index c157fab..b406088 100644 --- a/config/config.exs +++ b/config/config.exs @@ -14,7 +14,7 @@ config :pinchflat, yt_dlp_executable: System.find_executable("yt-dlp"), apprise_executable: System.find_executable("apprise"), yt_dlp_runner: Pinchflat.YtDlp.CommandRunner, - apprise_runner: Pinchflat.Notifications.CommandRunner, + apprise_runner: Pinchflat.Lifecycle.Notifications.CommandRunner, media_directory: "/downloads", # The user may or may not store metadata for their needs, but the app will always store its copy metadata_directory: "/config/metadata", diff --git a/lib/pinchflat/fast_indexing/fast_indexing_worker.ex b/lib/pinchflat/fast_indexing/fast_indexing_worker.ex index 0f85d40..ccd7126 100644 --- a/lib/pinchflat/fast_indexing/fast_indexing_worker.ex +++ b/lib/pinchflat/fast_indexing/fast_indexing_worker.ex @@ -15,7 +15,7 @@ defmodule Pinchflat.FastIndexing.FastIndexingWorker do alias Pinchflat.Settings alias Pinchflat.Sources.Source alias Pinchflat.FastIndexing.FastIndexingHelpers - alias Pinchflat.Notifications.SourceNotifications + alias Pinchflat.Lifecycle.Notifications.SourceNotifications @doc """ Starts the source fast indexing worker and creates a task for the source. diff --git a/lib/pinchflat/notifications/apprise_command_runner.ex b/lib/pinchflat/lifecycle/notifications/apprise_command_runner.ex similarity index 85% rename from lib/pinchflat/notifications/apprise_command_runner.ex rename to lib/pinchflat/lifecycle/notifications/apprise_command_runner.ex index 13ad327..8251b95 100644 --- a/lib/pinchflat/notifications/apprise_command_runner.ex +++ b/lib/pinchflat/lifecycle/notifications/apprise_command_runner.ex @@ -1,4 +1,4 @@ -defmodule Pinchflat.Notifications.AppriseCommandRunner do +defmodule Pinchflat.Lifecycle.Notifications.AppriseCommandRunner do @moduledoc """ A behaviour for running CLI commands against a notification backend (apprise). diff --git a/lib/pinchflat/notifications/command_runner.ex b/lib/pinchflat/lifecycle/notifications/command_runner.ex similarity index 92% rename from lib/pinchflat/notifications/command_runner.ex rename to lib/pinchflat/lifecycle/notifications/command_runner.ex index 782b1a9..c9ef100 100644 --- a/lib/pinchflat/notifications/command_runner.ex +++ b/lib/pinchflat/lifecycle/notifications/command_runner.ex @@ -1,4 +1,4 @@ -defmodule Pinchflat.Notifications.CommandRunner do +defmodule Pinchflat.Lifecycle.Notifications.CommandRunner do @moduledoc """ Runs apprise commands using the `System.cmd/3` function """ @@ -7,7 +7,7 @@ defmodule Pinchflat.Notifications.CommandRunner do alias Pinchflat.Utils.CliUtils alias Pinchflat.Utils.FunctionUtils - alias Pinchflat.Notifications.AppriseCommandRunner + alias Pinchflat.Lifecycle.Notifications.AppriseCommandRunner @behaviour AppriseCommandRunner diff --git a/lib/pinchflat/notifications/source_notifications.ex b/lib/pinchflat/lifecycle/notifications/source_notifications.ex similarity index 96% rename from lib/pinchflat/notifications/source_notifications.ex rename to lib/pinchflat/lifecycle/notifications/source_notifications.ex index 88cc189..4d0cf28 100644 --- a/lib/pinchflat/notifications/source_notifications.ex +++ b/lib/pinchflat/lifecycle/notifications/source_notifications.ex @@ -1,4 +1,4 @@ -defmodule Pinchflat.Notifications.SourceNotifications do +defmodule Pinchflat.Lifecycle.Notifications.SourceNotifications do @moduledoc """ Contains utilities for sending notifications about sources """ diff --git a/lib/pinchflat/lifecycle/user_scripts/user_script_command_runner.ex b/lib/pinchflat/lifecycle/user_scripts/user_script_command_runner.ex new file mode 100644 index 0000000..e69de29 diff --git a/lib/pinchflat/slow_indexing/media_collection_indexing_worker.ex b/lib/pinchflat/slow_indexing/media_collection_indexing_worker.ex index 678a9a5..50af81e 100644 --- a/lib/pinchflat/slow_indexing/media_collection_indexing_worker.ex +++ b/lib/pinchflat/slow_indexing/media_collection_indexing_worker.ex @@ -15,7 +15,7 @@ defmodule Pinchflat.SlowIndexing.MediaCollectionIndexingWorker do alias Pinchflat.Sources.Source alias Pinchflat.FastIndexing.FastIndexingWorker alias Pinchflat.SlowIndexing.SlowIndexingHelpers - alias Pinchflat.Notifications.SourceNotifications + alias Pinchflat.Lifecycle.Notifications.SourceNotifications @doc """ Starts the source slow indexing worker and creates a task for the source. diff --git a/test/pinchflat/notifications/command_runner_test.exs b/test/pinchflat/lifecycle/notifications/command_runner_test.exs similarity index 92% rename from test/pinchflat/notifications/command_runner_test.exs rename to test/pinchflat/lifecycle/notifications/command_runner_test.exs index 0ed4cc6..3635c48 100644 --- a/test/pinchflat/notifications/command_runner_test.exs +++ b/test/pinchflat/lifecycle/notifications/command_runner_test.exs @@ -1,7 +1,7 @@ -defmodule Pinchflat.Notifications.CommandRunnerTest do +defmodule Pinchflat.Lifecycle.Notifications.CommandRunnerTest do use ExUnit.Case, async: true - alias Pinchflat.Notifications.CommandRunner, as: Runner + alias Pinchflat.Lifecycle.Notifications.CommandRunner, as: Runner @original_executable Application.compile_env(:pinchflat, :apprise_executable) diff --git a/test/pinchflat/notifications/source_notifications_test.exs b/test/pinchflat/lifecycle/notifications/source_notifications_test.exs similarity index 96% rename from test/pinchflat/notifications/source_notifications_test.exs rename to test/pinchflat/lifecycle/notifications/source_notifications_test.exs index 7975784..42bbd7f 100644 --- a/test/pinchflat/notifications/source_notifications_test.exs +++ b/test/pinchflat/lifecycle/notifications/source_notifications_test.exs @@ -1,11 +1,11 @@ -defmodule Pinchflat.Notifications.SourceNotificationsTest do +defmodule Pinchflat.Lifecycle.Notifications.SourceNotificationsTest do use Pinchflat.DataCase import Mox import Pinchflat.MediaFixtures import Pinchflat.SourcesFixtures - alias Pinchflat.Notifications.SourceNotifications + alias Pinchflat.Lifecycle.Notifications.SourceNotifications @apprise_servers ["server_1", "server_2"] diff --git a/test/test_helper.exs b/test/test_helper.exs index e6cd91e..9b45123 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,7 +1,7 @@ Mox.defmock(YtDlpRunnerMock, for: Pinchflat.YtDlp.YtDlpCommandRunner) Application.put_env(:pinchflat, :yt_dlp_runner, YtDlpRunnerMock) -Mox.defmock(AppriseRunnerMock, for: Pinchflat.Notifications.AppriseCommandRunner) +Mox.defmock(AppriseRunnerMock, for: Pinchflat.Lifecycle.Notifications.AppriseCommandRunner) Application.put_env(:pinchflat, :apprise_runner, AppriseRunnerMock) Mox.defmock(HTTPClientMock, for: Pinchflat.HTTP.HTTPBehaviour)