Plumb.Readme (plumb v0.2.6)

Copy Markdown View Source

Checks a README's install snippet against the version being released.

The requirement is read from the first {:app_name, "requirement"} in the source. The version compared against is the one being released, not the one in mix.exs.

Modes

  • :satisfies — the version must satisfy the requirement the README names.
  • :exact — the README must name ~> MAJOR.MINOR of the version.

Summary

Functions

Whether source is fit to publish version of app under mode.

The requirement source names for app, from a {:app, "requirement"} pair.

Types

mode()

@type mode() :: :satisfies | :exact

Functions

check(source, app, version, mode)

@spec check(String.t(), atom(), String.t(), mode()) :: :ok | {:error, String.t()}

Whether source is fit to publish version of app under mode.

Returns :ok, or {:error, message} naming what the README says and what it should say.

Examples

iex> Plumb.Readme.check(~s|{:drafter, "~> 0.3"}|, :drafter, "0.3.1", :satisfies)
:ok

iex> Plumb.Readme.check(~s|{:drafter, "~> 0.3"}|, :drafter, "0.3.1", :exact)
:ok

requirement(source, app)

@spec requirement(String.t(), atom()) :: {:ok, String.t()} | {:error, String.t()}

The requirement source names for app, from a {:app, "requirement"} pair.

Takes the first occurrence. Returns {:error, message} when the app is not named at all, which is treated as a failure rather than a pass — a README with no install snippet cannot be verified.

Examples

iex> Plumb.Readme.requirement(~s|{:drafter, "~> 0.3"}|, :drafter)
{:ok, "~> 0.3"}