| 1 | package Astro::App::Satpass2::Macro; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 20 | ▶ | use 5.008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 20 | ▶ | use Astro::App::Satpass2::Utils qw{ | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | instance | ||||||||||||||||||||||||||||
| 10 | CODE_REF | ||||||||||||||||||||||||||||
| 11 | @CARP_NOT | ||||||||||||||||||||||||||||
| 12 | 20 | }; | |||||||||||||||||||||||||||
| 13 | 20 | ▶ | use Astro::App::Satpass2::Warner; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 20 | ▶ | use Scalar::Util 1.26 qw{ weaken }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 20 | our $VERSION = '0.059'; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 20 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | 20 | my ( $class, %arg ) = @_; | |||||||||||||||||||||||||||
| 20 | 20 | ▶ | my $self = bless \%arg, ref $class || $class; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||
| 21 | 20 | $self->init(); | |||||||||||||||||||||||||||
| 22 | 20 | return $self; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub execute { | ||||||||||||||||||||||||||
|
Subroutine
execute: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | 0 | __PACKAGE__->weep( 'execute() must be overridden' ); | |||||||||||||||||||||||||||
| 27 | 0 | return; # weep() dies, but Perl::Critic does not know this. | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 11 | ▶ | sub generator { | ||||||||||||||||||||||||||
|
Subroutine
generator: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | 11 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 32 | $self->{generate} | ||||||||||||||||||||||||||||
| 33 | 11 | ▶ | or $self->weep( q{'generate' attribute not specified} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | @args | ||||||||||||||||||||||||||||
| 35 | 11 | ▶ | or return $self->{generate}->( $self, sort $self->implements() ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 10 | foreach my $macro ( @args ) { | |||||||||||||||||||||||||||
| 37 | 10 | $self->implements( $macro, required => 1 ); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | 10 | return $self->{generate}->( $self, @args ); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 42 | ▶ | sub implements { | ||||||||||||||||||||||||||
|
Subroutine
implements: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 42 | my ( $self, $name, %arg ) = @_; | |||||||||||||||||||||||||||
| 44 | defined $name | ||||||||||||||||||||||||||||
| 45 | 42 | ▶ | or return ( keys %{ $self->{implements} } ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | $self->{implements}{$name} | ||||||||||||||||||||||||||||
| 47 | or not $arg{required} | ||||||||||||||||||||||||||||
| 48 | 40 | ▶ | or $self->wail( "This object does not implement macro $name" ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"implements"}{$name} or not $arg{"required"}
MC/DC0%0/2
$self->{"implements"}{$name} or not $arg{"required"}
$self->{"implements"}{$name}
not $arg{"required"}
Truth table33%1/3
A or not(B)
A= $self->{"implements"}{$name}B= not $arg{"required"}
| |||||||||||||||||||||||||||||
| 49 | 40 | return $self->{implements}{$name}; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 20 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=7 SCAR=22.4
Pod
documented
| |||||||||||||||||||||||||||||
| 53 | 20 | my ( $self ) = @_; | |||||||||||||||||||||||||||
| 54 | 20 | ▶ | $self->{warner} ||= Astro::App::Satpass2::Warner->new(); | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"warner"} ||= "Astro::App::Satpass2::Warner"->new
MC/DC0%0/2
$self->{"warner"} ||= "Astro::App::Satpass2::Warner"->new
$self->{"warner"}
"Astro::App::Satpass2::Warner"->new
Truth table33%1/3
A ||= B
A= $self->{"warner"}B= "Astro::App::Satpass2::Warner"->new
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | defined $self->{generate} | ||||||||||||||||||||||||||||
| 57 | and CODE_REF ne ref $self->{generate} | ||||||||||||||||||||||||||||
| 58 | 20 | ▶ | and $self->wail( q{If specified, 'generate' must be a code ref} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"generate"} and "CODE" ne ref $self->{"generate"}
MC/DC0%0/2
defined $self->{"generate"} and "CODE" ne ref $self->{"generate"}
defined $self->{"generate"}
"CODE" ne ref $self->{"generate"}
Truth table33%1/3
A and B
A= defined $self->{"generate"}B= "CODE" ne ref $self->{"generate"}
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | defined $self->{name} | ||||||||||||||||||||||||||||
| 61 | 20 | ▶ | or $self->wail( q{Attribute 'name' is required} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | defined $self->{parent} | ||||||||||||||||||||||||||||
| 64 | 20 | ▶ | or $self->wail( q{Attribute 'parent' is required} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 20 | ▶ | instance( $self->{parent}, 'Astro::App::Satpass2' ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | or $self->wail( q{Attribute 'parent' must be an Astro::App::Satpass2} ); | ||||||||||||||||||||||||||||
| 67 | 20 | weaken( $self->{parent} ); | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 20 | return; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 30 | ▶ | sub name { | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | 30 | my ( $self ) = @_; | |||||||||||||||||||||||||||
| 74 | 30 | return $self->{name}; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 31 | ▶ | sub parent { | ||||||||||||||||||||||||||
|
Subroutine
parent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 78 | 31 | my ( $self ) = @_; | |||||||||||||||||||||||||||
| 79 | 31 | return $self->{parent}; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 1 | ▶ | sub wail { | ||||||||||||||||||||||||||
|
Subroutine
wail: called CC=1 SCAR=0.4
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 84 | 1 | $self->warner()->wail( @args ); | |||||||||||||||||||||||||||
| 85 | 0 | return; # wail() dies, but Perl::Critic does not know this. | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 3 | ▶ | sub warner { | ||||||||||||||||||||||||||
|
Subroutine
warner: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 89 | 3 | my ( $self ) = @_; | |||||||||||||||||||||||||||
| 90 | 3 | ▶ | ref $self | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | or return Astro::App::Satpass2::Warner->new(); | ||||||||||||||||||||||||||||
| 92 | 3 | return $self->{warner}; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 1 | ▶ | sub weep { | ||||||||||||||||||||||||||
|
Subroutine
weep: called CC=1 SCAR=0.4
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 97 | 1 | $self->warner()->weep( @args ); | |||||||||||||||||||||||||||
| 98 | 0 | return; # weep() dies, but Perl::Critic does not know this. | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 1 | ▶ | sub whinge { | ||||||||||||||||||||||||||
|
Subroutine
whinge: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 102 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 103 | 1 | $self->warner()->whinge( @args ); | |||||||||||||||||||||||||||
| 104 | 1 | return; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | # TODO get rid of this when level1 support goes away. | ||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub __level1_rewrite { | ||||||||||||||||||||||||||
|
Subroutine
__level1_rewrite: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 109 | 0 | return; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 20 | 1; | |||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | __END__ | ||||||||||||||||||||||||||||