LemonCore.Update.Version (lemon_core v0.1.0)

View Source

CalVer version parsing and comparison for Lemon.

Version format: YYYY.MM.PATCH

Examples: 2026.03.0, 2026.03.1, 2026.04.0

The patch counter resets to 0 on each new month and increments for hotfixes and out-of-cycle releases.

Summary

Functions

Compares two CalVer strings.

Returns the current Lemon version string, read from the OTP application spec. Falls back to the umbrella mix.exs version when running from source.

Returns true when candidate is strictly newer than current.

Parses a version string into {year, month, patch} tuple.

Returns true when the version string matches CalVer format.

Types

parsed()

@type parsed() :: {integer(), integer(), integer()}

Functions

compare(v1, v2)

@spec compare(String.t(), String.t()) :: :lt | :eq | :gt

Compares two CalVer strings.

Returns :lt, :eq, or :gt. Falls back to string comparison if either version cannot be parsed.

current()

@spec current() :: String.t()

Returns the current Lemon version string, read from the OTP application spec. Falls back to the umbrella mix.exs version when running from source.

newer?(current, candidate)

@spec newer?(String.t(), String.t()) :: boolean()

Returns true when candidate is strictly newer than current.

parse(str)

@spec parse(String.t()) :: {:ok, parsed()} | :error

Parses a version string into {year, month, patch} tuple.

Returns {:ok, {year, month, patch}} or :error.

valid?(str)

@spec valid?(String.t()) :: boolean()

Returns true when the version string matches CalVer format.