Giter VIP home page Giter VIP logo

clj-semver's Introduction

clj-semver

Functions for parsing, comparison, and manipulation of semantic version strings. The intent is to implement the actual spec, including proper comparisons on pre-release and build fields.

Installation

clj-semver is available as a Maven artifact via Clojars.

Use the following build dependency:

[grimradical/clj-semver "0.3.0-SNAPSHOT"]

A non-snapshot release is forthcoming!

Usage

The main namespace for date-time operations in the clj-semver library is clj-semver.core.

user> (use 'clj-semver.core)

Parse a version string:

user> (version "1.0.0")
{:major 1, :minor 0, :patch 0, :pre-release nil, :build nil}

user> (version "1.0.0-alpha.1")
{:major 1, :minor 0, :patch 0, :pre-release "alpha.1", :build nil}

user> (version "1.0.0-alpha.1+build.234")
{:major 1, :minor 0, :patch 0, :pre-release "alpha.1", :build "build.234"}

They are regular clojure maps, so you can interrogate them the expected way:

user> (:minor (version "1.2.3"))

The version function is idempotent, so you can call it on a pre-parsed version and it'll will just pass-through the value. This makes it easier to create functions that operate on either string versions, or parsed version maps.

Comparison is straightforward:

user> (newer? "1.2.0" "1.0.1")
true
user> (older? "1.0.0-alpha.1" "1.0.0")
true

...etc

Apache licensed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.