summaryrefslogtreecommitdiff
path: root/lib/gen_magic.ex
blob: c60e357c4ea1dc0f97a49974a1e3d8727faa85b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
defmodule GenMagic do
  @moduledoc """
  Top-level namespace for GenMagic, the libMagic client for Elixir.
  """

  alias GenMagic.ApprenticeServer

  @doc """
  Top-level convenience function which creates an ad-hoc process. Usually
  this will be wrapped in a pool established by the author of the application
  that uses the library.
  """
  def perform(path) do
    {:ok, pid} = ApprenticeServer.start_link([])
    result = ApprenticeServer.file(pid, path)
    :ok = GenServer.stop(pid)
    result
  end
end