diff options
author | Patrick Spek <p.spek@tyil.nl> | 2020-02-03 11:54:45 +0100 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2020-02-03 11:54:45 +0100 |
commit | df571eb8e8734e85b67df179e68bd17376e2f273 (patch) | |
tree | f761cb80dec77f489af10e1dfb9f7b91e87cee25 | |
download | Grammar::Version::Semantic-df571eb8e8734e85b67df179e68bd17376e2f273.tar.gz Grammar::Version::Semantic-df571eb8e8734e85b67df179e68bd17376e2f273.tar.bz2 |
Initial commit
-rw-r--r-- | .editorconfig | 16 | ||||
-rw-r--r-- | .gitignore | 14 | ||||
-rw-r--r-- | .gitlab-ci.yml | 23 | ||||
-rw-r--r-- | .travis.yml | 13 | ||||
-rw-r--r-- | CHANGELOG.md | 9 | ||||
-rw-r--r-- | META6.json | 22 | ||||
-rw-r--r-- | README.pod6 | 23 | ||||
-rw-r--r-- | lib/Grammar/Version/Semantic.pm6 | 49 | ||||
-rw-r--r-- | t/00-use.t | 13 | ||||
-rw-r--r-- | t/01-parse.t | 83 |
10 files changed, 265 insertions, 0 deletions
diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..74dde7f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = tab +indent_size = 4 + +[*.json] +indent_style = space +indent_size = 2 + +[*.yml] +indent_style = space +indent_size = 2 + +# vim: ft=dosini diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..93356c2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +## Perl 6 precompilation files ## +.precomp + +## Editor files ## + +# emacs +*~ + +# vim +.*.sw? + +# comma +.idea +*.iml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..3917e8d --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,23 @@ +Grammar::SemVer: + only: + - master + image: rakudo-star + before_script: + - zef install . --deps-only --test-depends --/test + script: AUTHOR_TESTING=1 prove -v -e "perl6 -Ilib" t + artifacts: + name: "perl6-Grammar-SemVer" + paths: + - META6.json + - bin + - lib + - resources + - t + +test: + except: + - master + image: rakudo-star + before_script: + - zef install . --deps-only --test-depends --/test + script: AUTHOR_TESTING=1 prove -v -e "perl6 -Ilib" t diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..077ddb0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +language: perl6 + +perl6: + - latest + +os: + - linux + +install: + - rakudobrew build zef + - zef install --deps-only . + +script: AUTHOR_TESTING=1 prove -v -e "perl6 -Ilib" t/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1003abb --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic +Versioning](http://semver.org/spec/v2.0.0.html). + +## [UNRELEASED] +- Initial release diff --git a/META6.json b/META6.json new file mode 100644 index 0000000..aae39f1 --- /dev/null +++ b/META6.json @@ -0,0 +1,22 @@ +{ + "api": "0", + "authors": [ + "Patrick Spek <p.spek@tyil.work>" + ], + "depends": [ + ], + "description": "A grammar for parisng the SemVer spec in the Raku programming language", + "license": "AGPL-3.0", + "meta-version": 0, + "name": "Grammar::Version::Semantic", + "perl": "6.d", + "provides": { + "Grammar::Version::Semantic": "lib/Grammar/Version/Semantic.pm6" + }, + "resources": [ + ], + "source-url": "https://home.tyil.nl/git/raku/Grammar::Version::Semantic", + "tags": [ + ], + "version": "0.0.0" +}
\ No newline at end of file diff --git a/README.pod6 b/README.pod6 new file mode 100644 index 0000000..9b091e5 --- /dev/null +++ b/README.pod6 @@ -0,0 +1,23 @@ +=begin pod + +=NAME Grammar::SemVer +=AUTHOR Patrick Spek <p.spek@tyil.work> +=VERSION 0.0.0 + +=head1 Description + +A grammar ng the SemVer spec in the rogramming language + +=head1 Installation + +Install this module through L<zef|https://github.com/ugexe/zef>: + +=begin code :lang<sh> +zef install Grammar::SemVer +=end code + +=head1 License + +This module is distributed under the terms of the AGPL-3.0. + +=end pod diff --git a/lib/Grammar/Version/Semantic.pm6 b/lib/Grammar/Version/Semantic.pm6 new file mode 100644 index 0000000..8656f01 --- /dev/null +++ b/lib/Grammar/Version/Semantic.pm6 @@ -0,0 +1,49 @@ +#! /usr/bin/env false + +use v6.d; + +unit grammar Grammar::Version::Semantic; + +token TOP { + [ <major> '.' <minor> '.' <patch> ] + [ '-' <pre-release> ]? + [ '+' <build> ]? +} + +token pre-release { + [ \w+ % '.' ]+ +} + +token build { + <[ \w - ]>+ +} + +token major { + \d+ +} + +token minor { + \d+ +} + +token patch { + \d+ +} + +=begin pod + +=NAME Grammar::Version::Semantic +=AUTHOR Patrick Spek <p.spek@tyil.work> +=VERSION 0.0.0 + +=head1 Synopsis + +=head1 Description + +=head1 Examples + +=head1 See also + +=end pod + +# vim: ft=perl6 noet diff --git a/t/00-use.t b/t/00-use.t new file mode 100644 index 0000000..8cd62a8 --- /dev/null +++ b/t/00-use.t @@ -0,0 +1,13 @@ +#! /usr/bin/env perl6 + +use v6.d; + +use Test; + +use Grammar::Version::Semantic; + +plan 1; + +use-ok 'Grammar::Version::Semantic', 'Grammar::Version::Semantic is usable'; + +# vim: ft=perl6 noet diff --git a/t/01-parse.t b/t/01-parse.t new file mode 100644 index 0000000..149cadb --- /dev/null +++ b/t/01-parse.t @@ -0,0 +1,83 @@ +#! /usr/bin/env perl6 + +use v6.d; + +use Test; + +use Grammar::Version::Semantic; + +plan 5; + +my $grammar = Grammar::Version::Semantic; + +subtest '1.2.3', { + plan 6; + + my $match = $grammar.parse('1.2.3'); + + ok $match, 'Matched'; + + is +$match<major>, 1, 'Major is 1'; + is +$match<minor>, 2, 'Minor is 2'; + is +$match<patch>, 3, 'Patch is 3'; + nok $match<pre-release>, 'No pre-release'; + nok $match<build>, 'No build'; +} + +subtest '2.3.4-alpha3.1', { + plan 6; + + my $match = $grammar.parse('2.3.4-alpha3.1'); + + ok $match, 'Matched'; + + is +$match<major>, 2, 'Major is 2'; + is +$match<minor>, 3, 'Minor is 3'; + is +$match<patch>, 4, 'Patch is 4'; + is $match<pre-release>, 'alpha3.1', 'Pre-release is alpha3.1'; + nok $match<build>, 'No build'; +} + +subtest '3.4.5+dbfae86', { + plan 6; + + my $match = $grammar.parse('3.4.5+dbfae86'); + + ok $match, 'Matched'; + + is +$match<major>, 3, 'Major is 3'; + is +$match<minor>, 4, 'Minor is 4'; + is +$match<patch>, 5, 'Patch is 5'; + nok $match<pre-release>, 'No pre-release'; + is $match<build>, 'dbfae86', 'Build is dbfae86'; +} + +subtest '4.5.6-beta9+f59acba', { + plan 6; + + my $match = $grammar.parse('4.5.6-beta9+f59acba'); + + ok $match, 'Matched'; + + is +$match<major>, 4, 'Major is 4'; + is +$match<minor>, 5, 'Minor is 5'; + is +$match<patch>, 6, 'Patch is 6'; + is $match<pre-release>, 'beta9', 'Pre-release is beta9'; + is $match<build>, 'f59acba', 'Build is f59acba86'; +} + +subtest '2020.01.1-rc2', { + plan 6; + + my $match = $grammar.parse('2020.01.1-rc2'); + + ok $match, 'Matched'; + + is +$match<major>, 2020, 'Major is 2020'; + is ~$match<minor>, '01', 'Minor is 01'; + is +$match<patch>, 1, 'Patch is 1'; + is $match<pre-release>, 'rc2', 'Pre-release is rc2'; + nok $match<build>, 'No build'; +} + +# vim: ft=perl6 noet |