Functions for parsing and matching versions against requirements.
A version is a string in a specific format or a Version
generated after parsing via Version.parse/1
.
Version
parsing and requirements follow
SemVer 2.0 schema.
Versions
In a nutshell, a version is given by three numbers:
MAJOR.MINOR.PATCH
Pre-releases are supported by appending -[0-9A-Za-z-\.]
:
"1.0.0-alpha.3"
Build information can be added by appending +[0-9A-Za-z-\.]
:
"1.0.0-alpha.3+20130417140000"
Struct
The version is represented by the Version struct and it has its
fields named according to Semver: :major
, :minor
, :patch
,
:pre
and :build
.
Requirements
Requirements allow you to specify which versions of a given
dependency you are willing to work against. It supports common
operators like >=
, <=
, >
, ==
and friends that
work as one would expect:
# Only version 2.0.0
"== 2.0.0"
# Anything later than 2.0.0
"> 2.0.0"
Requirements also support and
and or
for complex conditions:
# 2.0.0 and later until 2.1.0
">= 2.0.0 and < 2.1.0"
Since the example above is such a common requirement, it can be expressed as:
"~> 2.0.0"