All Projects → steveklabnik → Semver

steveklabnik / Semver

Licence: other
Semantic version parsing and comparison.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Semver

Semver
Work with Semantic Versions in Go
Stars: ✭ 608 (+114.84%)
Mutual labels:  comparison, semver
Nearley
📜🔜🌲 Simple, fast, powerful parser toolkit for JavaScript.
Stars: ✭ 3,089 (+991.52%)
Mutual labels:  parsing
parse-md
Parse Markdown file's metadata from its content
Stars: ✭ 15 (-94.7%)
Mutual labels:  parsing
semver
Semantic version object for Perl
Stars: ✭ 12 (-95.76%)
Mutual labels:  semver
cs-resources
Curated Computer Science and Programming Resource Guide
Stars: ✭ 42 (-85.16%)
Mutual labels:  parsing
Stringsareevil
Reducing memory allocations from 7.5GB to 32KB
Stars: ✭ 260 (-8.13%)
Mutual labels:  parsing
rest-query-parser
Query Parser for REST
Stars: ✭ 29 (-89.75%)
Mutual labels:  parsing
Ldetool
Code generator for fast log file parsers
Stars: ✭ 273 (-3.53%)
Mutual labels:  parsing
Nlpython
This repository contains the code related to Natural Language Processing using python scripting language. All the codes are related to my book entitled "Python Natural Language Processing"
Stars: ✭ 265 (-6.36%)
Mutual labels:  parsing
CalPack
Packets in Python Simplified
Stars: ✭ 19 (-93.29%)
Mutual labels:  parsing
ofxgo
Golang library for querying and parsing OFX
Stars: ✭ 96 (-66.08%)
Mutual labels:  parsing
literator
📝 Generate literate-style markdown docs from your sources
Stars: ✭ 55 (-80.57%)
Mutual labels:  parsing
Python Semver
Python package to work with Semantic Versioning (http://semver.org/)
Stars: ✭ 264 (-6.71%)
Mutual labels:  semver
python-hslog
Python module to parse Hearthstone Power.log files
Stars: ✭ 37 (-86.93%)
Mutual labels:  parsing
Creek
Ruby library for parsing large Excel files.
Stars: ✭ 270 (-4.59%)
Mutual labels:  parsing
case-insensitive
Case insensitive string comparison
Stars: ✭ 24 (-91.52%)
Mutual labels:  comparison
change
A simple tool that automates generating and updating a changelog
Stars: ✭ 47 (-83.39%)
Mutual labels:  semver
inmemantlr
ANTLR as a libray for JVM based languages
Stars: ✭ 87 (-69.26%)
Mutual labels:  parsing
Serpent
A protocol to serialize Swift structs and classes for encoding and decoding.
Stars: ✭ 281 (-0.71%)
Mutual labels:  parsing
Cli
🆑📍 Setup automated semver compliant package publishing
Stars: ✭ 272 (-3.89%)
Mutual labels:  semver

semver

Semantic version parsing and comparison.

Build Status

Documentation

Semantic versioning (see https://semver.org/) is a set of rules for assigning version numbers.

SemVer and the Rust ecosystem

Rust itself follows the SemVer specification, as does its standard libraries. The two are not tied together.

Cargo, Rust's package manager, uses SemVer to determine which versions of packages you need installed.

Installation

To use semver, add this to your [dependencies] section:

semver = "0.11.0"

And this to your crate root:

extern crate semver;

Versions

At its simplest, the semver crate allows you to construct Version objects using the parse method:

use semver::Version;

assert!(Version::parse("1.2.3") == Ok(Version {
   major: 1,
   minor: 2,
   patch: 3,
   pre: vec!(),
   build: vec!(),
}));

If you have multiple Versions, you can use the usual comparison operators to compare them:

use semver::Version;

assert!(Version::parse("1.2.3-alpha")  != Version::parse("1.2.3-beta"));
assert!(Version::parse("1.2.3-alpha2") >  Version::parse("1.2.0"));

Requirements

The semver crate also provides the ability to compare requirements, which are more complex comparisons.

For example, creating a requirement that only matches versions greater than or equal to 1.0.0:

use semver::Version;
use semver::VersionReq;

let r = VersionReq::parse(">= 1.0.0").unwrap();
let v = Version::parse("1.0.0").unwrap();

assert!(r.to_string() == ">= 1.0.0".to_string());
assert!(r.matches(&v))

It also allows parsing of ~x.y.z and ^x.y.z requirements as defined at https://www.npmjs.com/package/semver

Tilde requirements specify a minimal version with some updates:

~1.2.3 := >=1.2.3 <1.3.0
~1.2   := >=1.2.0 <1.3.0
~1     := >=1.0.0 <2.0.0

Caret requirements allow SemVer compatible updates to a specified version, 0.x and 0.x+1 are not considered compatible, but 1.x and 1.x+1 are.

0.0.x is not considered compatible with any other version. Missing minor and patch versions are desugared to 0 but allow flexibility for that value.

^1.2.3 := >=1.2.3 <2.0.0
^0.2.3 := >=0.2.3 <0.3.0
^0.0.3 := >=0.0.3 <0.0.4
^0.0   := >=0.0.0 <0.1.0
^0     := >=0.0.0 <1.0.0
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].