Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/boxuk/versions

Simple tool for comparing version numbers in Clojure and ClojureScript
https://github.com/boxuk/versions

Last synced: about 2 months ago
JSON representation

Simple tool for comparing version numbers in Clojure and ClojureScript

Awesome Lists containing this project

README

        

# Versions [![Build Status](https://secure.travis-ci.org/boxuk/versions.png?branch=master)](http://travis-ci.org/boxuk/versions) [![Dependencies Status](http://clj-deps.herokuapp.com/github/boxuk/versions/status.png)](http://clj-deps.herokuapp.com/github/boxuk/versions)

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

## Usage

Just pass version strings to the comparison functions.

```clojure
(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.

```clojure
(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_.

```clojure
(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:

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

# Installation

Versions is available from [Clojars](http://clojars.org/boxuk/versions)

## ClojureScript

Versions also supports being used via ClojureScript.

## License

Dual licensed under GPLv2 and MIT.