semver_parser 0.1.0-alpha copy "semver_parser: ^0.1.0-alpha" to clipboard
semver_parser: ^0.1.0-alpha copied to clipboard

outdatedDart 1 only

Provides an API to parse strings to Semantic Versions along with Semantic Version comparison logic.

semver_parser License: MIT Build Status codecov #

A Dart library that provides an API to parse strings to Semantic Versions along with Semantic Version comparison logic. The library's semver parsing and comparison logic follows the Semantic Version 2.0.0 spec.

This library can take an arbitrary string value and attempt to parse it into a single Semantic Version, represented by the Semver object. For a string to parse to a Semantic Version it must contain one, and only one, valid Semantic Version. Additional "noise" in the string will not affect the parse and will be dropped.

E.X.

  • '1.2.3' = Major: 1 Minor: 2 Patch: 3
  • 'react-16.3.2' = Major: 16 Minor: 3 Patch 2 ('react-' is ignored as it does not affect the Semantic Version)
  • 'California' = No Semantic Version, exception would be thrown.
  • '2.1.5 and 5.12.6' = Two potential Semantic Versions, exception would be thrown.
Note: Pre-Release information is not parsed currently, issue #17 will add support for parsing this information.
Note: Built metadata information is not parsed currently, issue #18 will add support for parsing this information.

Semantic Version Comparison Logic #

Two Semver objects can be compared using the standard comparison operators such as ==, !=, <, <=, > or >=.

E.X.

  • '1.2.3' == '1.2.3' (true)
  • '4.3.1' != '4.3.1' (false)
  • '2.4.5' > '2.3.0' (true)
  • '1.12.43' < '1.12.42' (false)
Note: <, <=, > or >= are not supported currently, issue #12 will add support for them.

Example Parsing #

var versionOne = parseSemverString('some-12.5.3%thing');
var versionTwo = parseSemverString('11.5.12');

print(versionOne); // 12.5.3
print(versionTwo); // 11.5.12

print(versionOne == versionTwo); // true
print(versionOne < versionTwo); // false

Example Parsing App #

An example app to test or demo semver string parsing is included under 'example/'. This app can be run using dart example/semver_parsing_example.dart or pub run example/semver_parsing_example.dart. The example app takes input from stdin and parses that input. Run the example to see more details about all its functions.

Releases/Roadmap #

Currently no releases have been cut. The initial release will almost certainly be '0.1.0', and although I don't expect many breaking changes, it would be wise to read any change notes until '1.0.0' is made.

Release '1.0.0' will likely be made after support for parsing all Semantic Version information and comparison logic work is complete.

Contributing #

Feel free to submit issues for any bugs, feature requests or questions in generally. Please provide as much information as possible so I can best help you out.

If you'd like to contribute, feel free to open pulls for changes. I'd suggest you read the contributing guide as well.

0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Provides an API to parse strings to Semantic Versions along with Semantic Version comparison logic.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on semver_parser