From 5ce612b2723381a978f3810a414a3c3038a1859c Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Tue, 11 Mar 2025 18:21:27 +0400 Subject: Linting --- lib/pleroma/date_time.ex | 3 +++ lib/pleroma/date_time/impl.ex | 6 ++++++ lib/pleroma/datetime.ex | 3 --- lib/pleroma/datetime/impl.ex | 6 ------ lib/pleroma/mogrify.ex | 42 ---------------------------------------- lib/pleroma/mogrify_behaviour.ex | 15 ++++++++++++++ lib/pleroma/mogrify_wrapper.ex | 30 ++++++++++++++++++++++++++++ 7 files changed, 54 insertions(+), 51 deletions(-) create mode 100644 lib/pleroma/date_time.ex create mode 100644 lib/pleroma/date_time/impl.ex delete mode 100644 lib/pleroma/datetime.ex delete mode 100644 lib/pleroma/datetime/impl.ex delete mode 100644 lib/pleroma/mogrify.ex create mode 100644 lib/pleroma/mogrify_behaviour.ex create mode 100644 lib/pleroma/mogrify_wrapper.ex (limited to 'lib') diff --git a/lib/pleroma/date_time.ex b/lib/pleroma/date_time.ex new file mode 100644 index 000000000..d79cb848b --- /dev/null +++ b/lib/pleroma/date_time.ex @@ -0,0 +1,3 @@ +defmodule Pleroma.DateTime do + @callback utc_now() :: NaiveDateTime.t() +end diff --git a/lib/pleroma/date_time/impl.ex b/lib/pleroma/date_time/impl.ex new file mode 100644 index 000000000..102be047b --- /dev/null +++ b/lib/pleroma/date_time/impl.ex @@ -0,0 +1,6 @@ +defmodule Pleroma.DateTime.Impl do + @behaviour Pleroma.DateTime + + @impl true + def utc_now, do: NaiveDateTime.utc_now() +end diff --git a/lib/pleroma/datetime.ex b/lib/pleroma/datetime.ex deleted file mode 100644 index d79cb848b..000000000 --- a/lib/pleroma/datetime.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule Pleroma.DateTime do - @callback utc_now() :: NaiveDateTime.t() -end diff --git a/lib/pleroma/datetime/impl.ex b/lib/pleroma/datetime/impl.ex deleted file mode 100644 index 102be047b..000000000 --- a/lib/pleroma/datetime/impl.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule Pleroma.DateTime.Impl do - @behaviour Pleroma.DateTime - - @impl true - def utc_now, do: NaiveDateTime.utc_now() -end diff --git a/lib/pleroma/mogrify.ex b/lib/pleroma/mogrify.ex deleted file mode 100644 index 77725e8f2..000000000 --- a/lib/pleroma/mogrify.ex +++ /dev/null @@ -1,42 +0,0 @@ -# Pleroma: A lightweight social networking server -# Copyright © 2017-2022 Pleroma Authors -# SPDX-License-Identifier: AGPL-3.0-only - -defmodule Pleroma.MogrifyBehaviour do - @moduledoc """ - Behaviour for Mogrify operations. - This module defines the interface for Mogrify operations that can be mocked in tests. - """ - - @callback open(binary()) :: map() - @callback custom(map(), binary()) :: map() - @callback custom(map(), binary(), binary()) :: map() - @callback save(map(), keyword()) :: map() -end - -defmodule Pleroma.MogrifyWrapper do - @moduledoc """ - Default implementation of MogrifyBehaviour that delegates to Mogrify. - """ - @behaviour Pleroma.MogrifyBehaviour - - @impl true - def open(file) do - Mogrify.open(file) - end - - @impl true - def custom(image, action) do - Mogrify.custom(image, action) - end - - @impl true - def custom(image, action, options) do - Mogrify.custom(image, action, options) - end - - @impl true - def save(image, opts) do - Mogrify.save(image, opts) - end -end diff --git a/lib/pleroma/mogrify_behaviour.ex b/lib/pleroma/mogrify_behaviour.ex new file mode 100644 index 000000000..234cb86cf --- /dev/null +++ b/lib/pleroma/mogrify_behaviour.ex @@ -0,0 +1,15 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2022 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.MogrifyBehaviour do + @moduledoc """ + Behaviour for Mogrify operations. + This module defines the interface for Mogrify operations that can be mocked in tests. + """ + + @callback open(binary()) :: map() + @callback custom(map(), binary()) :: map() + @callback custom(map(), binary(), binary()) :: map() + @callback save(map(), keyword()) :: map() +end diff --git a/lib/pleroma/mogrify_wrapper.ex b/lib/pleroma/mogrify_wrapper.ex new file mode 100644 index 000000000..17174fd97 --- /dev/null +++ b/lib/pleroma/mogrify_wrapper.ex @@ -0,0 +1,30 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2022 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.MogrifyWrapper do + @moduledoc """ + Default implementation of MogrifyBehaviour that delegates to Mogrify. + """ + @behaviour Pleroma.MogrifyBehaviour + + @impl true + def open(file) do + Mogrify.open(file) + end + + @impl true + def custom(image, action) do + Mogrify.custom(image, action) + end + + @impl true + def custom(image, action, options) do + Mogrify.custom(image, action, options) + end + + @impl true + def save(image, opts) do + Mogrify.save(image, opts) + end +end -- cgit v1.2.3