Versioning v0.3.0 Versioning.Adapter.Semantic View Source

A versioning adapter for semantic-based versions.

Under the hood, this adapter uses the Version module. For details on the rules that are used for parsing and comparison, please see the Version module.

Example

defmodule MyApp.Versioning do
  use Versioning.Schema, adapter: Versioning.Adapter.Semantic

  version "1.0.0" do
    type "Post" do
      change(MyApp.Change)
    end
  end
end

Link to this section Summary

Functions

Compares semantic based versions.

Parses semantic based versions.

Link to this section Functions

Link to this function

compare(version1, version2) View Source
compare(binary() | Version.t(), binary() | Version.t()) ::
  :eq | :error | :gt | :lt

Compares semantic based versions.

Returns :gt if the first verison is greater than the second, and :lt for vice-versa. If the two versions are equal, :eq is returned. Returns :error if the version cannot be parsed.

Example

  iex> Versioning.Adapter.Semantic.compare("1.0.1", "1.0.0")
  :gt
  iex> Versioning.Adapter.Semantic.compare("1.0.0", "1.0.1)
  :lt
  iex> Versioning.Adapter.Semantic.compare("1.0.1", "1.0.1")
  :eq
  iex> Versioning.Adapter.Semantic.compare("foo", "bar")
  :error
Link to this function

parse(version) View Source
parse(binary() | Version.t()) :: :error | {:ok, Version.t()}

Parses semantic based versions.

Example

  iex> Versioning.Adapter.Semantic.parse("1.0.0")
  {:ok, #Version<1.0.0>}
  iex> Versioning.Adapter.Semantic.parse("foo")
  :error