Simple tool for comparing version numbers in Clojure and ClojureScript
Clojure
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/boxuk
test/boxuk/test
.gitignore
.travis.yml
README.md
project.clj

README.md

Versions Build Status Dependencies Status

Versions is a super-simple library for comparing version numbers.

Usage

Just pass version strings to the comparison functions.

(use boxuk.versions)

(later-version? "1.0.0" "1.0.1") ; true
(later-version? "2.1.0" "1.2.0") ; false

(earlier-version? "1.0" "0.0.9" ) ; true
(earlier-version? "0.9.0" "0.10" ) ; false

(same-version? "0.1" "0.1.0.0.0.0" ) ; true
(same-version? "2.1" "1.2") ; false

You can also filter a sequence for the latest or earliest version.

(latest-version ["1.1" "2.3"]) ; "2.3"
(earliest-version ["2.4" "3.4.2"]) ; "2.4"

Stable/Unstable

Versions can make a distinction between stable and unstable versions. Unstable versions are anything postfixed with for example alpha, RC, or SNAPSHOT.

(stable? "1.2.3-SNAPSHOT") ; false
(unstable? "1.2.3-alpha2") ; true

(latest-stable ["1.2.2" "1.2.2-SNAPSHOT"] ; "1.2.2"

The order of comparison for unstable versions is:

(> "SNAPSHOT" "RC" "beta" "alpha")

Installation

Versions is available from Clojars

ClojureScript

Versions also supports being used via ClojureScript.

License

Dual licensed under GPLv2 and MIT.