blib/lib/Astro/App/Satpass2/Copier.pm

filter: Statementstmt 79.4% 54 / 68 Branchbran 75.0% 15 / 20 Conditioncond 27.7% 5 / 18 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 77.7% 14 / 18 Podpod 100% 10 / 10 totaltotal 67.1% 98 / 146 CC 20 SCAR 18.5
CC
20
Cov
70%
copy
20.0
warner
11.3
init
5.2
CRAP 6.4
« blib/lib/Astro/App/Satpass2/Format/Dump.pm ↑ Summary blib/lib/Astro/App/Satpass2/Format.pm »
1 package Astro::App::Satpass2::Copier;
2  
3 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 21 ▶use Clone ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 21 ▶use Astro::App::Satpass2::Utils qw{ @CARP_NOT };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 21 ▶use Astro::App::Satpass2::Warner;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 21 ▶use Scalar::Util 1.26 qw{ blessed };
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 21 our $VERSION = '0.059';
13  
14 69 ▶sub attribute_names {
Subroutine attribute_names: called CC=1 SCAR=0.0
Pod documented
15 69 return ( qw{ warner } );
16 }
17  
18 2 ▶sub class_name_of_record {
Subroutine class_name_of_record: called CC=2 SCAR=8.1
Pod documented
19 2 my ( $self ) = @_;
20 2 ▶ return ref $self || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
200
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
21 }
22  
23 0 ▶sub clone {
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
24 0 my ( $self ) = @_;
25 0 return Clone::clone( $self );
26 }
27  
28 0 ▶sub copy {
Subroutine copy: not called CC=4 SCAR=30.0
Pod documented
29 0 my ( $self, $copy, %skip ) = @_;
30 0 foreach my $attr ( $self->attribute_names() ) {
31 0 ▶ not exists $skip{$attr}
Branch: 1 branch
BranchTrueFalseTotal
not exists $skip{$attr} and $copy->can($attr) and $copy->$attr($self->$attr) 0 0 0
Condition0%0/3
not exists $skip{$attr} and $copy->can($attr)
!ll&&!rl&&r
000
MC/DC0%0/2
not exists $skip{$attr} and $copy->can($attr)
not exists $skip{$attr} $copy->can($attr)
Truth table0%0/3
not(A) and B
A= not exists $skip{$attr}B= $copy->can($attr)
ABresult
0X0
100
111
32 and $copy->can( $attr )
33 and $copy->$attr( $self->$attr() );
34 }
35 0 return $self;
36 }
37  
38 60 ▶sub create_attribute_methods {
Subroutine create_attribute_methods: called CC=4 SCAR=13.9
Pod documented
39 60 my ( $self ) = @_;
40 60 ▶ my $class = ref $self || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
0600
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
41 60 foreach my $attr ( $self->attribute_names() ) {
42 348 ▶ $class->can( $attr ) and next;
Branch: 1 branch
BranchTrueFalseTotal
$class->can($attr) and next 208 140 348
43 140 my $method = $class . '::' . $attr;
44 21 ▶ no strict qw{ refs };
Subroutine BEGIN: called CC=1 SCAR=0.0
45 3027 ▶ *$method = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
46 3027 my ( $self, @args ) = @_;
47 3027 ▶ if ( @args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) { } 87 2940 3027
48 87 $self->{$attr} = $args[0];
49 87 return $self;
50 } else {
51 2940 return $self->{$attr};
52 }
53 140 };
54 }
55 60 return;
56 }
57  
58 61 ▶sub init {
Subroutine init: called CC=5 SCAR=16.6
Pod documented
59 61 my ( $self, %arg ) = @_;
60 exists $arg{warner}
61 61 ▶ and $self->warner( delete $arg{warner} );
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{"warner"} and $self->warner(delete $arg{"warner"}) 12 49 61
62 61 foreach my $name ( $self->attribute_names() ) {
63 exists $arg{$name}
64 296 ▶ and $self->$name( delete $arg{$name} );
Branch: 1 branch
BranchTrueFalseTotal
exists $arg{$name} and $self->$name(delete $arg{$name}) 13 283 296
65 }
66 61 ▶ if ( %arg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (%arg) 0 61 61
67 0 my @extra = sort keys %arg;
68 0 $self->wail(
69 join ' ', 'Unknown attribute name(s):', @extra
70 );
71 }
72 61 return $self;
73 }
74  
75 1 ▶sub wail {
Subroutine wail: called CC=1 SCAR=0.0
Pod documented
76 1 my ( $self, @args ) = @_;
77 1 return $self->warner()->wail( @args );
78 }
79  
80 1310 ▶sub warner {
Subroutine warner: called CC=8 SCAR=24.2
Pod documented
81 1310 my ( $self, @args ) = @_;
82 1310 ▶ if ( @args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) { } 812 498 1310
83 812 my $val = shift @args;
84 812 ▶ if ( ! defined $val ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $val) { } 19 793 812
elsif (not ref $val and $val->isa('Astro::App::Satpass2::Warner')) { } 0 793 793
elsif (not builtin::blessed($val) && $val->isa('Astro::App::Satpass2::Warner')) { } 0 793 793
85 19 $val = Astro::App::Satpass2::Warner->new();
86 ▶ } elsif ( ! ref $val && $val->isa(
Condition33%1/3
not ref $val and $val->isa("Astro::App::Satpass2::Warner")
!ll&&!rl&&r
79300
MC/DC0%0/2
not ref $val and $val->isa("Astro::App::Satpass2::Warner")
not ref $val $val->isa("Astro::App::Satpass2::Warner")
Truth table33%1/3
not(A) and B
A= not ref $valB= $val->isa("Astro::App::Satpass2::Warner")
ABresult
0X0
100
111
87 'Astro::App::Satpass2::Warner' ) ) {
88 0 $val = Astro::App::Satpass2::Warner->new();
89 ▶ } elsif ( ! ( blessed( $val ) &&
Condition33%1/3
builtin::blessed($val) && $val->isa('Astro::App::Satpass2::Warner')
!ll&&!rl&&r
00793
MC/DC0%0/2
builtin::blessed($val) && $val->isa('Astro::App::Satpass2::Warner')
builtin::blessed($val) $val->isa('Astro::App::Satpass2::Warner')
Truth table33%1/3
A && B
A= builtin::blessed($val)B= $val->isa('Astro::App::Satpass2::Warner')
ABresult
0X0
100
111
90 $val->isa('Astro::App::Satpass2::Warner' ) ) ) {
91 0 $self->wail(
92 'Warner must be undef or an Astro::App::Satpass2::Warner'
93 );
94 }
95 812 $self->{warner} = $val;
96 812 return $self;
97 } else {
98 498 ▶ return $self->{warner} ||= Astro::App::Satpass2::Warner->new();
Condition33%1/3
$self->{"warner"} ||= "Astro::App::Satpass2::Warner"->new
l!l&&r!l&&!r
49800
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
ABresult
1X1
011
000
99 }
100 }
101  
102 0 ▶sub weep {
Subroutine weep: not called CC=1 SCAR=6.9
Pod documented
103 0 my ( $self, @args ) = @_;
104 0 return $self->warner()->weep( @args );
105 }
106  
107 0 ▶sub whinge {
Subroutine whinge: not called CC=1 SCAR=6.9
Pod documented
108 0 my ( $self, @args ) = @_;
109 0 return $self->warner()->whinge( @args );
110 }
111  
112 21 1;
113  
114 __END__
« blib/lib/Astro/App/Satpass2/Format/Dump.pm ↑ Summary blib/lib/Astro/App/Satpass2/Format.pm »