BIMI/App/Command/checksvg.pm

filter: Statementstmt 48.9% 23 / 47 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 61.5% 8 / 13 Podpod 100% 5 / 5 totaltotal 43.9% 36 / 82 CC 8 SCAR 25.0
CC
8
Cov
37%
validate_args
30.0
execute
20.0
description
2.0
CRAP 12.2
« BIMI.pm ↑ Summary BIMI/Role/Cacheable.pm »
1 package Mail::BIMI::App::Command::checksvg;
2 # ABSTRACT: Check an SVG for validation
3 1 our $VERSION = '3.20261116'; # VERSION
4 1 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶BEGIN { $ENV{MAIL_BIMI_CACHE_DEFAULT_BACKEND} = 'Null' };
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Mail::BIMI::Prelude;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Mail::BIMI::App -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Mail::BIMI;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Mail::BIMI::Indicator;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use File::Slurp qw{ read_file write_file };
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Term::ANSIColor qw{ :constants };
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 0 ▶sub description { 'Check a SVG from a given URI or File for validity' }
Subroutine description: not called CC=1 SCAR=6.9
Pod documented
15 0 ▶sub usage_desc { "%c checksvg %o <URI>" }
Subroutine usage_desc: not called CC=1 SCAR=6.9
Pod documented
16  
17 0 ▶sub opt_spec {
Subroutine opt_spec: not called CC=1 SCAR=6.9
Pod documented
18 return (
19 0 [ 'profile=s', 'SVG Profile to validate against ('.join('|',@Mail::BIMI::Indicator::VALIDATOR_PROFILES).')' ],
20 [ 'fromfile', 'Fetch from file instead of from URI' ],
21 );
22 }
23  
24 0 ▶sub validate_args($self,$opt,$args) {
Subroutine validate_args: not called CC=5 SCAR=34.0
Pod documented
25 0 ▶ $self->usage_error('No URI specified') if !@$args;
Branch: 1 branch
BranchTrueFalseTotal
unless @$args 0 0 0
26 0 ▶ $self->usage_error('Multiple URIs specified') if scalar @$args > 1;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @$args > 1 0 0 0
27 0 ▶ $self->usage_error('Unknown SVG Profile') if $opt->profile && !grep {;$_ eq $opt->profile} @Mail::BIMI::Indicator::VALIDATOR_PROFILES;
Branch: 1 branch
BranchTrueFalseTotal
if $opt->profile and not grep({$_ eq $opt->profile;} @Mail::BIMI::Indicator::VALIDATOR_PROFILES) 0 0 0
Condition0%0/3
$opt->profile and not grep({$_ eq $opt->profile;} @Mail::BIMI::Indicator::VALIDATOR_PROFILES)
!ll&&!rl&&r
000
MC/DC0%0/2
$opt->profile and not grep({$_ eq $opt->profile;} @Mail::BIMI::Indicator::VALIDATOR_PROFILES)
$opt->profile not grep({$_ eq $opt->profile;} @Mail::BIMI::Indicator::VALIDATOR_PROFILES)
Truth table0%0/3
A and not(B)
A= $opt->profileB= not grep({$_ eq $opt->profile;} @Mail::BIMI::Indicator::VALIDATOR_PROFILES)
ABresult
0X0
100
111
28 }
29  
30 0 ▶sub execute($self,$opt,$args) {
Subroutine execute: not called CC=4 SCAR=30.0
Pod documented
31 0 my $uri = $args->[0];
32 0 my $bimi = Mail::BIMI->new(domain=>'example.com');
33  
34 0 my %bimi_opt = (
35 bimi_object => $bimi,
36 );
37 0 ▶ if ( $opt->fromfile ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->fromfile) { } 0 0 0
38 0 my $data = scalar read_file($uri);
39 0 $bimi_opt{data} = $data;
40 }
41 else {
42 0 $bimi_opt{uri} = $uri;
43 }
44  
45 0 my $indicator = Mail::BIMI::Indicator->new(%bimi_opt);
46 0 ▶ $indicator->validator_profile($opt->profile) if $opt->profile;
Branch: 1 branch
BranchTrueFalseTotal
if $opt->profile 0 0 0
47 0 say "BIMI SVG checker";
48 0 say '';
49 0 say 'Requested:';
50 0 ▶ say YELLOW.($opt->fromfile?'File':'URI').WHITE.': '.$uri.RESET;
Branch: 1 branch
BranchTrueFalseTotal
$opt->fromfile ? : 0 0 0
51 0 say '';
52 0 $indicator->app_validate;
53 0 say '';
54  
55 0 $bimi->finish;
56 }
57  
58 1 1;
59  
60 __END__
« BIMI.pm ↑ Summary BIMI/Role/Cacheable.pm »