Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aznashwan/gleamsver
Comprehensive set of native Gleam utilities for handling SemVer 2.0.0.
https://github.com/aznashwan/gleamsver
gleam gleam-lang gleam-language semver-compare semver-format semver-parser semver-syntax
Last synced: 27 days ago
JSON representation
Comprehensive set of native Gleam utilities for handling SemVer 2.0.0.
- Host: GitHub
- URL: https://github.com/aznashwan/gleamsver
- Owner: aznashwan
- License: mit
- Created: 2024-04-01T17:53:42.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-07-08T10:15:37.000Z (5 months ago)
- Last Synced: 2024-10-12T19:48:45.608Z (2 months ago)
- Topics: gleam, gleam-lang, gleam-language, semver-compare, semver-format, semver-parser, semver-syntax
- Language: Gleam
- Homepage: https://hex.pm/packages/gleamsver
- Size: 24.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gleam - gleamsver - [📚](https://hexdocs.pm/gleamsver/) - Comprehensive set of native Gleam utilities for handling SemVer 2.0.0 version strings. (Packages / Parsing)
README
# gleamsver
Comprehensive set of native Gleam utilities for handling
[SemVer 2.0.0](https://semver.org) version strings.[![Package Version](https://img.shields.io/hexpm/v/gleamsver)](https://hex.pm/packages/gleamsver)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/gleamsver/)```sh
gleam add gleamsver
``````gleam
import gleam/io
import gleamsverfn compress_message(message: String) -> String {
message <> ", but compressed ;)"
}pub fn main() {
// Parse correct SemVer 2.0.0 strings using `parse()`:
let assert Ok(server_version_with_compression) = gleamsver.parse("1.3.7-rc0")
io.debug(server_version_with_compression) // SemVer(1, 3, 7, "rc0", "")// Parse loose SemVer strings using `parse_loosely()`:
let assert Ok(current_server_version) = gleamsver.parse_loosely("v1.4")// Convert back to SemVer strings using `to_string()`:
let uncompressed_message =
"Hello, server version " <> gleamsver.to_string(current_server_version)let message = {
// Guard against version mismatches using `guard_version_*()` functions:
use <- gleamsver.guard_version_compatible(
version: server_version_with_compression,
compatible_with: current_server_version,
else_return: uncompressed_message,
)// Compression will only occur if the above guard succeeds:
compress_message(uncompressed_message)
}// Prints "Hello, server version 1.4.0, but compressed ;)"
io.println(message)
}
```Further documentation can be found at .
## Development
```sh
gleam run # Run the project
gleam test # Run the tests
gleam shell # Run an Erlang shell
```