View Source Bex (bex v0.4.0)

Bex internals and helpers.

Summary

Functions

Fetches the spec from BEAM file generated for a module

IO formatter for diffs

Retrieves mfa tuple from Macro.Env

Builds a telemetry event base name from Macro.Env

Functions

Link to this function

fetch_spec(mod, fun, arity)

View Source
@spec fetch_spec(module(), atom(), arity()) :: {:ok, String.t()} | {:error, any()}

Fetches the spec from BEAM file generated for a module

Example

iex> Bex.fetch_spec Process, :send_after, 4
{:ok, "send_after(pid() | atom(), term(), non_neg_integer(), [option]) :: reference() when option: var"}
@spec io_diff(ast :: Macro.t() | String.t(), leader :: :delete | :add | String.t()) ::
  String.t()

IO formatter for diffs

Examples

iex> Bex.io_diff("foo", :delete)
"- foo"
iex> Bex.io_diff("foo", :add)
"+ foo"
iex> Bex.io_diff("foo", "→")
"→ foo"

Retrieves mfa tuple from Macro.Env

Examples

iex> Bex.mfa(__ENV__)
{BexTest, :"doctest Bex.mfa/1 (1)", 1}
Link to this function

telemetry_event_base(env)

View Source
@spec telemetry_event_base(Macro.Env.t() | mfa()) :: :telemetry.event_name()

Builds a telemetry event base name from Macro.Env

Examples

iex> Bex.telemetry_event_base(__ENV__)
[:bextest, :"doctest Bex.telemetry_event_base/1 (2)_1"]
Link to this function

telemetry_measurements_base(additional_measurements \\ %{})

View Source
@spec telemetry_measurements_base(map() | keyword()) :: %{
  :system_time => integer(),
  :monotonic_time => integer(),
  optional(atom()) => any()
}

Standard :telemetry.span/3-like measurements

Examples

iex> measurements = Bex.telemetry_measurements_base(%{foo: :bar})
...> match?(%{monotonic_time: _, system_time: _, foo: :bar}, measurements)
true