| 1 | package App::Changelord::Command::Validate; | ||||||||||
| 2 | 2 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||
| 3 | 2 | $App::Changelord::Command::Validate::VERSION = '0.0.2'; | |||||||||
| 4 | 2 | ▶ | use 5.36.0; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | use CLI::Osprey | ||||||||||
| 8 | 2 | ▶ | doc => 'validate the changelog yaml', | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | description_pod => <<'END'; | |||||||||
| 10 | Validate the changelog against the JSON Schema used by changelord. | ||||||||||
| 11 | END | ||||||||||
| 12 | |||||||||||
| 13 | 2 | ▶ | use Path::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 2 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 2 | ▶ | use YAML::XS; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 2 | ▶ | use JSON::Schema::Modern; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 2 | with 'App::Changelord::Role::Changelog'; | |||||||||
| 19 | |||||||||||
| 20 | 2 | option json => ( | |||||||||
| 21 | is => 'ro', | ||||||||||
| 22 | default => 0, | ||||||||||
| 23 | doc => 'output schema as json', | ||||||||||
| 24 | ); | ||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | sub run($self) { | ||||||||
|
Subroutine
run: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 27 | 0 | local $YAML::XS::Boolean = 'boolean'; | |||||||||
| 28 | |||||||||||
| 29 | 0 | my $schema = path(__FILE__)->sibling('changelog-schema.yml')->slurp; | |||||||||
| 30 | |||||||||||
| 31 | 0 | my $result = JSON::Schema::Modern->new( | |||||||||
| 32 | output_format => 'detailed', | ||||||||||
| 33 | )->evaluate( | ||||||||||
| 34 | $self->changelog, | ||||||||||
| 35 | YAML::XS::Load($schema), | ||||||||||
| 36 | ); | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | return say "woo, changelog is valid!" if( $result eq 'valid' ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | 0 | print $result; | |||||||||
| 42 | 0 | die "\n"; | |||||||||
| 43 | |||||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 2 | 'end of App::Changelog::Command::Validate'; | |||||||||
| 47 | |||||||||||
| 48 | __END__ | ||||||||||