Skip to content

Commit

Permalink
Update README.
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed May 11, 2024
1 parent c85dbe1 commit ab75c32
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 5 deletions.
70 changes: 70 additions & 0 deletions README.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

## verona

The `verona` package provides types implementing the
[Semantic Versioning](https://www.semver.org) specification.

## Features

* Types for representing versions and version ranges.
* Parsers for version numbers and version ranges.
* Written in pure Java 17.
* [OSGi](https://www.osgi.org/) ready.
* [JPMS](https://en.wikipedia.org/wiki/Java_Platform_Module_System) ready.
* ISC license.
* High-coverage automated test suite.

## Description

### Types

The `verona` package contains types for representing versions and version
ranges.

```
assert Version.of(1, 0, 2).toString() == "1.0.2";
assert Version.of(2, 3, 1, "SNAPSHOT").toString() == "2.3.1-SNAPSHOT";
assert Version.of(3, 0, 0, "SNAPSHOT").toString() == "2.3.1-SNAPSHOT";
```

Values of type `Version` are comparable and are ordered such that version
number components are treated as unsigned values and, for two versions `x`
and `y`:

```
Comparator.comparing(Version::major, COMPARE_UNSIGNED)
.thenComparing(Version::minor, COMPARE_UNSIGNED)
.thenComparing(Version::patch, COMPARE_UNSIGNED)
.thenComparing(Version::qualifier, COMPARE_QUALIFIER)
.compare(x, y);
```

For a given version `x.y.z`, the version `x.y.z-q` is considered less than
`x.y.z` for any `q`.

### Parsing

Version numbers can be parsed:

```
assert VersionParser.parse("1.0.2").toString() == "1.0.2";
```

Parsing is strict by default. This means that exactly three version number
components must be provided, along with an optional qualifier. Support is
provided for _lax_ parsing that allows for missing components. For example:

```
assert VersionParser.parse("1.2.0").toString() == "1.2.0";

VersionParser.parse("1.2"); // throws VersionException

assert VersionParser.parseLax("1.2").toString() == "1.2.0";
```

Additional support is provided for [OSGi](https://www.osgi.org) version
numbers where the qualifier is separated with a dot instead of a hyphen:

```
assert VersionParser.parseOSGi("1.2.0.SNAPSHOT").toString() == "1.2.0-SNAPSHOT";
```
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,74 @@ verona
| OpenJDK (Temurin) LTS | Linux | [![Build (OpenJDK (Temurin) LTS, Linux)](https://img.shields.io/github/actions/workflow/status/io7m-com/verona/main.linux.temurin.lts.yml)](https://www.github.com/io7m-com/verona/actions?query=workflow%3Amain.linux.temurin.lts)|
| OpenJDK (Temurin) Current | Windows | [![Build (OpenJDK (Temurin) Current, Windows)](https://img.shields.io/github/actions/workflow/status/io7m-com/verona/main.windows.temurin.current.yml)](https://www.github.com/io7m-com/verona/actions?query=workflow%3Amain.windows.temurin.current)|
| OpenJDK (Temurin) LTS | Windows | [![Build (OpenJDK (Temurin) LTS, Windows)](https://img.shields.io/github/actions/workflow/status/io7m-com/verona/main.windows.temurin.lts.yml)](https://www.github.com/io7m-com/verona/actions?query=workflow%3Amain.windows.temurin.lts)|

## verona

The `verona` package provides types implementing the
[Semantic Versioning](https://www.semver.org) specification.

## Features

* Types for representing versions and version ranges.
* Parsers for version numbers and version ranges.
* Written in pure Java 17.
* [OSGi](https://www.osgi.org/) ready.
* [JPMS](https://en.wikipedia.org/wiki/Java_Platform_Module_System) ready.
* ISC license.
* High-coverage automated test suite.

## Description

### Types

The `verona` package contains types for representing versions and version
ranges.

```
assert Version.of(1, 0, 2).toString() == "1.0.2";
assert Version.of(2, 3, 1, "SNAPSHOT").toString() == "2.3.1-SNAPSHOT";
assert Version.of(3, 0, 0, "SNAPSHOT").toString() == "2.3.1-SNAPSHOT";
```

Values of type `Version` are comparable and are ordered such that version
number components are treated as unsigned values and, for two versions `x`
and `y`:

```
Comparator.comparing(Version::major, COMPARE_UNSIGNED)
.thenComparing(Version::minor, COMPARE_UNSIGNED)
.thenComparing(Version::patch, COMPARE_UNSIGNED)
.thenComparing(Version::qualifier, COMPARE_QUALIFIER)
.compare(x, y);
```

For a given version `x.y.z`, the version `x.y.z-q` is considered less than
`x.y.z` for any `q`.

### Parsing

Version numbers can be parsed:

```
assert VersionParser.parse("1.0.2").toString() == "1.0.2";
```

Parsing is strict by default. This means that exactly three version number
components must be provided, along with an optional qualifier. Support is
provided for _lax_ parsing that allows for missing components. For example:

```
assert VersionParser.parse("1.2.0").toString() == "1.2.0";
VersionParser.parse("1.2"); // throws VersionException
assert VersionParser.parseLax("1.2").toString() == "1.2.0";
```

Additional support is provided for [OSGi](https://www.osgi.org) version
numbers where the qualifier is separated with a dot instead of a hyphen:

```
assert VersionParser.parseOSGi("1.2.0.SNAPSHOT").toString() == "1.2.0-SNAPSHOT";
```

3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
</modules>

<properties>
<!-- Configuration. -->
<io7m.api.previousVersion>1.0.0</io7m.api.previousVersion>
<io7m.java.targetJavaVersion>21</io7m.java.targetJavaVersion>
<io7m.java.targetJavaVersion>17</io7m.java.targetJavaVersion>
</properties>

<licenses>
Expand Down
4 changes: 3 additions & 1 deletion src/site/resources/documentation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

<div xmlns="http://www.w3.org/1999/xhtml">
<h3>User Documentation</h3>
<p>No user documentation is currently available.</p>
<p>
See the <a href="https://www.github.com/io7m-com/verona">README</a>.
</p>
</div>
9 changes: 6 additions & 3 deletions src/site/resources/features.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

<div xmlns="http://www.w3.org/1999/xhtml">
<ul>
<li><a href="https://www.osgi.org/">OSGi</a>-ready</li>
<li><a href="https://en.wikipedia.org/wiki/Java_Platform_Module_System">JPMS</a>-ready</li>
<li>ISC license</li>
<li>Types for representing versions and version ranges.</li>
<li>Parsers for version numbers and version ranges.</li>
<li>High coverage automated test suite.</li>
<li><a href="https://www.osgi.org/">OSGi</a>-ready.</li>
<li><a href="https://en.wikipedia.org/wiki/Java_Platform_Module_System">JPMS</a>-ready.</li>
<li>ISC license.</li>
</ul>
</div>

0 comments on commit ab75c32

Please sign in to comment.