Regions/CFITSIO/Variant.pm

filter: Statementstmt 95.9% 47 / 49 Branchbran 75.0% 9 / 12 Conditioncond 35.7% 5 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 91.6% 11 / 12 Podpod 0.0% 0 / 3 totaltotal 72.7% 72 / 99 CC 14 SCAR 20.2
CC
14
Cov
81%
make_variant
15.3
params
5.0
_croak
2.0
CRAP 7.5
« Regions/DS9/Variant.pm ↑ Summary Regions/CIAO/Variant.pm »
1 package CXC::Astro::Regions::CFITSIO::Variant;
2  
3 # ABSTRACT: Generate CFITSIO Region classes
4  
5 3 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use experimental 'signatures', 'postderef';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 our $VERSION = '0.05';
10  
11 3 ▶use Module::Runtime 'module_notional_filename';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use Ref::Util qw( is_arrayref );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 use Package::Variant
16 3 ▶ importing => [ 'Moo', 'MooX::StrictConstructor' ],
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 subs => [qw( has extends around with )];
18  
19 3 ▶use constant PREFIX => __PACKAGE__ =~ s/[^:]+$//r;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 0 ▶sub _croak {
Subroutine _croak: not called CC=1 SCAR=6.9
22 0 require Carp;
23 0 goto \&Carp::croak;
24 }
25  
26  
27 22 ▶sub make_variant_package_name ( $, $package, % ) {
Subroutine make_variant_package_name: called CC=1 SCAR=0.0
Pod undocumented
28 22 return PREFIX . ucfirst( $package );
29 }
30  
31  
32 22 ▶sub make_variant ( $, $, $region, %args ) {
Subroutine make_variant: called CC=10 SCAR=27.3
Pod undocumented
33  
34 22 ▶ my $params = $args{params} // [];
Condition50%1/2
$args{"params"} // []
l!l
220
MC/DC0%0/1
$args{"params"} // []
$args{"params"}
Truth table50%1/2
A
A= $args{"params"}
Aresult
11
00
35 22 ▶ $region = $args{name} // $region;
Condition33%1/3
$args{"name"} // $region
l!l&&r!l&&!r
0220
MC/DC0%0/2
$args{"name"} // $region
$args{"name"} $region
Truth table33%1/3
A // B
A= $args{"name"}B= $region
ABresult
1X1
011
000
36  
37 22 ▶ extends $args{extends}->@* if $args{extends} && $args{extends}->@*;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"extends"} and @{$args{"extends"}} 0 22 22
Condition33%1/3
$args{"extends"} and @{$args{"extends"}}
!ll&&!rl&&r
2200
MC/DC0%0/2
$args{"extends"} and @{$args{"extends"}}
$args{"extends"} @{$args{"extends"}}
Truth table33%1/3
A and B
A= $args{"extends"}B= @{$args{"extends"}}
ABresult
0X0
100
111
38  
39 22 my @private = qw( label );
40  
41 22 for my $arg ( $params->@* ) {
42 66 my %has = ( is => 'ro', required => 1, $arg->%* );
43 66 my ( $name ) = delete @has{ 'name', @private };
44 66 has $name => %has;
45 }
46  
47 21 ▶ install render => sub ( $self ) {
Subroutine __ANON__: called CC=1 SCAR=0.0
48 21 return sprintf( '%s(%s)', $region, join( q{,}, params( $self, $params ) ) );
49 22 };
50  
51 22 ▶ around $args{around}->@* if $args{around} && $args{around}->@*;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"around"} and @{$args{"around"}} 0 22 22
Condition33%1/3
$args{"around"} and @{$args{"around"}}
!ll&&!rl&&r
2200
MC/DC0%0/2
$args{"around"} and @{$args{"around"}}
$args{"around"} @{$args{"around"}}
Truth table33%1/3
A and B
A= $args{"around"}B= @{$args{"around"}}
ABresult
0X0
100
111
52 22 ▶ with $args{with}->@* if $args{with} && $args{with}->@*;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"with"} and @{$args{"with"}} 0 22 22
Condition33%1/3
$args{"with"} and @{$args{"with"}}
!ll&&!rl&&r
2200
MC/DC0%0/2
$args{"with"} and @{$args{"with"}}
$args{"with"} @{$args{"with"}}
Truth table33%1/3
A and B
A= $args{"with"}B= @{$args{"with"}}
ABresult
0X0
100
111
53  
54 }
55  
56 21 ▶sub params ( $self, $params ) {
Subroutine params: called CC=5 SCAR=16.1
Pod undocumented
57 21 my @output;
58  
59 21 for my $param ( $params->@* ) {
60  
61 74 my $name = $param->{name};
62 74 my @values = ( $self->$name );
63 74 ▶ next if !defined $values[0];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $values[0] 5 69 74
64  
65 69 ▶ while ( @values ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@values) 146 69 215
66 146 my $value = shift @values;
67 146 ▶ if ( is_arrayref( $value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_arrayref($value)) 38 108 146
68 38 unshift @values, $value->@*;
69 38 next;
70 }
71 108 push @output, $value;
72 }
73 }
74  
75 21 return @output;
76 }
77  
78  
79 3 1;
80  
81 #
82 # This file is part of CXC-Astro-Regions
83 #
84 # This software is Copyright (c) 2023 by Smithsonian Astrophysical Observatory.
85 #
86 # This is free software, licensed under:
87 #
88 # The GNU General Public License, Version 3, June 2007
89 #
90  
91 __END__
« Regions/DS9/Variant.pm ↑ Summary Regions/CIAO/Variant.pm »