wand v0.3.2 Wand.Mode View Source

Each requirement in a wand.json follows some type of pattern. An exact pattern is one where the version is exactly specified. A tilde mode allows the patch version to be updated, and the caret mode allows the minor version to be updated.

Link to this section Summary

Functions

Determine the mode that the requirement is currently using. If the requirement is not one of the types set by wand, it is marked as custom

See Wand.Mode.get_requirement! On success, this returns {:ok, requirement}, and on failure, {:error, :invalid_version} is returned

Given a mode and a version, calculate the requirement that combines both part. Throws an exception on failure.

Examples

iex> Wand.Mode.get_requirement!(:exact, "2.3.1")
"== 2.3.1"

Link to this section Types

Link to this type requirement() View Source
requirement() :: String.t() | {:latest, t()}
Link to this type t() View Source
t() :: :caret | :tilde | :exact | :custom
Link to this type version() View Source
version() :: String.t() | :latest | Version.t()

Link to this section Functions

Link to this function from_requirement(requirement) View Source
from_requirement(requirement()) :: t()

Determine the mode that the requirement is currently using. If the requirement is not one of the types set by wand, it is marked as custom.

Examples

iex> Wand.Mode.from_requirement("== 2.3.2")
:exact

iex> Wand.Mode.from_requirement("~> 2.3.2")
:tilde

iex> Wand.Mode.from_requirement(">= 2.3.2 and < 3.0.0")
:caret

iex> Wand.Mode.from_requirement(">= 2.3.2 and < 3.0.0 and != 2.3.3")
:custom
Link to this function get_requirement(mode, version) View Source
get_requirement(t(), version()) ::
  {:ok, requirement()} | {:error, :invalid_version}

See Wand.Mode.get_requirement! On success, this returns {:ok, requirement}, and on failure, {:error, :invalid_version} is returned

Link to this function get_requirement!(mode, version) View Source
get_requirement!(t(), version()) :: requirement()

Given a mode and a version, calculate the requirement that combines both part. Throws an exception on failure.

Examples

iex> Wand.Mode.get_requirement!(:exact, "2.3.1")
"== 2.3.1"

iex> Wand.Mode.get_requirement!(:tilde, "2.3.1")
"~> 2.3.1"

iex> Wand.Mode.get_requirement!(:caret, "2.3.1")
">= 2.3.1 and < 3.0.0"

iex> Wand.Mode.get_requirement!(:caret, "0.3.3")
">= 0.3.3 and < 0.4.0"