| 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.04'; | |||||||||||||||||||||||||||
| 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' ], | |||||||||||||||||||||||||||
| 17 | 3 | ▶ | subs => [qw( has extends around with )]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 3 | ▶ | use constant PREFIX => __PACKAGE__ =~ s/[^:]+$//r; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | sub _croak { | ||||||||||||||||||||||||||||
| 22 | 0 | ▶ | require Carp; | ||||||||||||||||||||||||||
|
Subroutine
_croak: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 23 | 0 | goto \&Carp::croak; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | ▶ | 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 | ▶ | sub make_variant ( $, $, $region, %args ) { | |||||||||||||||||||||||||||
|
Subroutine
make_variant: called CC=10 SCAR=26.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 22 | ▶ | my $params = $args{params} // []; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{"params"} // []
MC/DC0%0/1
$args{"params"} // []
$args{"params"}
Truth table50%1/2
A
A= $args{"params"}
| |||||||||||||||||||||||||||||
| 35 | 22 | ▶ | $region = $args{name} // $region; | ||||||||||||||||||||||||||
|
Condition66%2/3
$args{"name"} // $region
MC/DC0%0/2
$args{"name"} // $region
$args{"name"}
$region
Truth table66%2/3
A // B
A= $args{"name"}B= $region
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 22 | ▶ | extends $args{extends}->@* if $args{extends} && $args{extends}->@*; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{"extends"} and @{$args{"extends"}}
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"}}
| |||||||||||||||||||||||||||||
| 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 | ▶ | 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
Condition33%1/3
$args{"around"} and @{$args{"around"}}
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"}}
| |||||||||||||||||||||||||||||
| 52 | 22 | ▶ | with $args{with}->@* if $args{with} && $args{with}->@*; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{"with"} and @{$args{"with"}}
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"}}
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | ▶ | 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
| |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 69 | ▶ | while ( @values ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 146 | my $value = shift @values; | |||||||||||||||||||||||||||
| 67 | 146 | ▶ | if ( is_arrayref( $value ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||