| 1 | package OPM::Maker::Command::sopmtest; | ||||||||||
| 2 | 21 | $OPM::Maker::Command::sopmtest::VERSION = '1.17'; | |||||||||
| 3 | # ABSTRACT: Check if sopm is valid | ||||||||||
| 4 | |||||||||||
| 5 | 21 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 21 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 21 | ▶ | use Path::Class (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 21 | ▶ | use OPM::Validate; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 21 | ▶ | use OPM::Maker -command; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 21 | ▶ | use OPM::Maker::Utils qw(check_args_sopm); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | sub abstract { | ||||||||
|
Subroutine
abstract: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 15 | 1 | return "check .sopm if it is valid"; | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | sub usage_desc { | ||||||||
|
Subroutine
usage_desc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 19 | 1 | return "opmbuild sopmtest <path_to_sopm>"; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 16 | ▶ | sub validate_args { | ||||||||
|
Subroutine
validate_args: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 23 | 16 | my ($self, $opt, $args) = @_; | |||||||||
| 24 | |||||||||||
| 25 | 16 | my $sopm = check_args_sopm( $args, 1 ); | |||||||||
| 26 | 16 | ▶ | $self->usage_error( 'need path to .sopm' ) if | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | !$sopm; | ||||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 9 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||
| 31 | 9 | my ($self, $opt, $args) = @_; | |||||||||
| 32 | |||||||||||
| 33 | 9 | my $file = check_args_sopm( $args, 1 ); | |||||||||
| 34 | |||||||||||
| 35 | 9 | ▶ | if ( !defined $file ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 2 | print "No file given!"; | |||||||||
| 37 | 2 | return; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 7 | ▶ | if ( !-f $file ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | print "$file does not exist"; | |||||||||
| 42 | 0 | return; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | eval { | ||||||||||
| 46 | 7 | my $content = do{ local (@ARGV, $/) = $file; <> }; | |||||||||
| 47 | 7 | OPM::Validate->validate( $content, 1 ); | |||||||||
| 48 | 4 | 1; | |||||||||
| 49 | 7 | ▶ | } or do { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 3 | print ".sopm is not valid: $@\n"; | |||||||||
| 51 | 3 | return; | |||||||||
| 52 | }; | ||||||||||
| 53 | |||||||||||
| 54 | 4 | return 1; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 21 | 1; | |||||||||
| 58 | |||||||||||
| 59 | __END__ | ||||||||||