Add more tests to upload filters
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -276,17 +276,19 @@ defmodule Mobilizon.Config do
|
||||
end
|
||||
end
|
||||
|
||||
@spec put([module | atom], any) :: any
|
||||
def put([key], value), do: put(key, value)
|
||||
|
||||
def put([parent_key | keys], value) do
|
||||
parent = put_in(Application.get_env(:mobilizon, parent_key), keys, value)
|
||||
parent =
|
||||
Application.get_env(:mobilizon, parent_key, [])
|
||||
|> put_in(keys, value)
|
||||
|
||||
Application.put_env(:mobilizon, parent_key, parent)
|
||||
end
|
||||
|
||||
@spec put(module | atom, any) :: any
|
||||
def put(key, value), do: Application.put_env(:mobilizon, key, value)
|
||||
def put(key, value) do
|
||||
Application.put_env(:mobilizon, key, value)
|
||||
end
|
||||
|
||||
@spec to_boolean(boolean | String.t()) :: boolean
|
||||
defp to_boolean(boolean), do: "true" == String.downcase("#{boolean}")
|
||||
|
||||
25
lib/mobilizon/utils.ex
Normal file
25
lib/mobilizon/utils.ex
Normal file
@@ -0,0 +1,25 @@
|
||||
# Portions of this file are derived from Pleroma:
|
||||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Mobilizon.Utils do
|
||||
@moduledoc """
|
||||
Module that provide generic utils functions for Mobilizon
|
||||
"""
|
||||
|
||||
@doc """
|
||||
POSIX-compliant check if command is available in the system
|
||||
|
||||
## Examples
|
||||
iex> command_available?("git")
|
||||
true
|
||||
iex> command_available?("wrongcmd")
|
||||
false
|
||||
|
||||
"""
|
||||
@spec command_available?(String.t()) :: boolean()
|
||||
def command_available?(command) do
|
||||
match?({_output, 0}, System.cmd("sh", ["-c", "command -v #{command}"]))
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user