Description

Semantic Versioning Library

Package Information

Version0.3.1 (2016-Apr-07)
Repositoryhttps://github.com/dcarp/semver
LicenseMIT
CopyrightCopyright © 2014 Dragoş Carp
AuthorsDragoş Carp
Registered byDragos Carp
Dependenciesnone

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

Build Status

semver

Semantic Versioning Library

Implementation

This library parses, validates and compares version numbers and version ranges.

It uses the following formats:

  • Semantic Versioning 2.0.0 - http://semver.org
  • Semantic Versioning Range - https://github.com/isaacs/node-semver

Usage

auto version1 = SemVer("1.0.0");
assert(version1.isValid);
assert(version1.isStable);

auto version2 = SemVer("1.0.0-rc.1");
assert(version2.isValid);
assert(!version2.isStable);

assert(SemVer("1.0.0") > SemVer("1.0.0+build.1"));
assert(SemVer("1.0.0").differAt(SemVer("1.0.0+build.1")) == VersionPart.BUILD);

auto versionRange = SemVerRange(">=1.0.0");
assert(versionRange.isValid);

assert(SemVer("1.0.1").satisfies(versionRange));
assert(SemVer("1.1.0").satisfies(versionRange));

auto semVers = [SemVer("1.1.0"), SemVer("1.0.0"), SemVer("0.8.0")];
assert(semVers.maxSatisfying(SemVerRange("<=1.0.0")) == SemVer("1.0.0"));
assert(semVers.maxSatisfying(SemVerRange(">=1.0")) == SemVer("1.1.0"));

semVers = [SemVer("1.0.0+build.3"), SemVer("1.0.0+build.1"), SemVer("1.1.0")];
assert(semVers.maxSatisfying(SemVerRange("<=1.0.0")) == SemVer("1.0.0+build.3"));
assert(semVers.maxSatisfying(SemVerRange(">=1.0")) == SemVer("1.1.0"));

Available versions

0.3.1 0.3.0 0.2.1 0.2.0 0.1.0 ~master