1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! Create, parse, edit, and compare semantic version numbers.
//!
//! This library provides you with nearly everything you need to make use of
//! version numbers that are compatible with version 2.0.0 of the Semantic
//! Versioning specification. The specification is required reading if you do
//! not already know the rules and requirements for a semantic version number.
//! The specification is pretty small, so it shouldn't take too long!
//!
//! Specification
//! -------------
//!
//! You can find the specification at [semver.org][].
//!
//! [semver.org]: https://semver.org/
//!
//! Usage
//! -----
//!
//! The library tries to make working with semantic version numbers as simple
//! as possible. As a result of this effort, there is a lot of things you can
//! do with these numbers. This usage guide will cover high level stuff, so
//! you may want to read the documentation for the structures and traits that
//! are included for more advanced information.
//!
//! ```
//! #[macro_use]
//! extern crate recital;
//!
//! use recital::prelude::*;
//! # fn main() {
//! # }
//! ```
//!
//! ### Creating
//!
//! ```
//! # #[macro_use]
//! # extern crate recital;
//! # fn main() {
//! let version = version!(1, 2, 3,
//!                        vec![id!("abc"), id!(456)],
//!                        vec![id!("def"), id!(789)]);
//! # }
//! ```
//!
//! ### Parsing
//!
//! ```
//! # use recital::version::Version;
//! let version: Version = "1.2.3-abc.456+def.789".parse().unwrap();
//! ```
//!
//! ### Modifying
//!
//! ```
//! # #[macro_use]
//! # extern crate recital;
//! # use recital::version::Version;
//! # fn main() {
//! // `0.0.0`
//! let mut version = Version::new();
//!
//! // `1.2.3`
//! version.major = 1;
//! version.minor = 2;
//! version.patch = 3;
//!
//! // `1.2.3-abc.456+def.789`
//! version.pre.push(id!("abc"));
//! version.pre.push(id!(456));
//! version.build.push(id!("def"));
//! version.build.push(id!(789));
//!
//! // `2.1.1`
//! version.increment_major();
//! version.increment_minor();
//! version.increment_patch();
//! # }
//! ```
//!
//! ### Comparing
//!
//! You can compare versions like you would any number.
//!
//! ```
//! # use recital::version::Version;
//! let a: Version = "1.2.3-alpha".parse().unwrap();
//! let b: Version = "1.2.3".parse().unwrap();
//!
//! assert!(a < b);
//! assert!(!(a > b));
//! assert!(a != b);
//! ```

#[macro_use]
extern crate nom;

// Version number management.
#[macro_use]
pub mod version;

// Version string parser.
mod parser;

/// Re-exports submodules for glob imports.
pub mod prelude {
    pub use resolve::{Constraint, Constraints, Operation, resolve};
    pub use version::{Identifier, Version};
}

// Version constraints management.
#[macro_use]
pub mod resolve;