blib/lib/Astro/App/Satpass2/Macro/Command.pm

filter: Statementstmt 100% 52 / 52 Branchbran 65.0% 13 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 91.8% 79 / 86 CC 12 SCAR 11.1
CC
12
Cov
90%
execute
5.0
completion
4.1
init
3.0
CRAP 3.0
« blib/lib/Astro/App/Satpass2/Format/Template/Provider.pm ↑ Summary blib/lib/Astro/App/Satpass2/FormatTime/Cldr.pm »
1 package Astro::App::Satpass2::Macro::Command;
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 parent qw{ Astro::App::Satpass2::Macro };
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 20 ▶use Astro::App::Satpass2::Utils qw{ quoter ARRAY_REF @CARP_NOT };
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 20 our $VERSION = '0.059';
13  
14 19 ▶sub execute {
Subroutine execute: called CC=5 SCAR=16.2
Pod documented
15 19 my ( $self, $name ) = @_;
16 19 ▶ $self->implements( $name )
Branch: 1 branch
BranchTrueFalseTotal
$self->implements($name) or $self->weep("'${name}' not implemented by this object") 19 0 19
17 or $self->weep( "'$name' not implemented by this object" );
18 19 my $satpass2 = $self->parent();
19 19 my $output;
20 19 foreach my $cmd ( @{ $self->{def} } ) {
21 eval {
22 19 ▶ if ( defined( my $buffer = $satpass2->execute( $cmd ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $buffer = $satpass2->execute($cmd))) 18 0 18
23 18 $output .= $buffer;
24 }
25 18 1;
26 19 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { if (defined(my $buffer = $satpass2->execute($cmd))) { $output .= $buffer; } ; 1 } } or do { $satpass2->__wail($@) } 18 1 19
27 1 $satpass2->__wail( $@ );
28 }
29 }
30 18 return $output;
31 }
32  
33 12 ▶sub completion {
Subroutine completion: called CC=4 SCAR=14.0
Pod documented
34 12 my ( $self, $text ) = @_;
35 $self->{completion}
36 12 ▶ or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"completion"} or return 3 9 12
37 3 ▶ defined $text
Branch: 1 branch
BranchTrueFalseTotal
defined $text or $text = "" 3 0 3
38 or $text = '';
39 3 ▶ my @rslt = sort( grep { ! index $_, $text } @{ $self->{completion} } )
Branch: 1 branch
BranchTrueFalseTotal
my(@rslt) = sort(grep({not index($_, $text);} @{$$self{"completion"};})) or return 3 0 3
40 or return;
41 3 return \@rslt;
42 }
43  
44 9 ▶sub def {
Subroutine def: called CC=2 SCAR=7.0
Pod documented
45 9 my ( $self ) = @_;
46 9 my @def = @{ $self->{def} };
47 9 ▶ return wantarray ? @def : \@def;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 9 0 9
48 }
49  
50 19 ▶sub init {
Subroutine init: called CC=3 SCAR=11.0
Pod documented
51 19 my ( $self ) = @_;
52 19 $self->SUPER::init();
53 ARRAY_REF eq ref $self->{def}
54 19 ▶ or $self->wail( q{Attribute 'def' must be an array reference} );
Branch: 1 branch
BranchTrueFalseTotal
"ARRAY" eq ref $self->{"def"} or $self->wail("Attribute 'def' must be an array reference") 19 0 19
55 19 $self->{implements} = { map { $_ => 1 } $self->name() };
56  
57 $self->{completion}
58 1 and @{ $self->{completion} } = map { split qr< \s+ >smx }
59 19 ▶ @{ $self->{completion} };
Branch: 1 branch
BranchTrueFalseTotal
$self->{"completion"} and @{$$self{"completion"};} = map({split(qr/ \s+ /msx, $_, 0);} @{$$self{"completion"};}) 1 18 19
60  
61 19 return;
62 }
63  
64 # Rewrite level1 macro definitions to level 2 commands. Note that this
65 # is idempotent.
66  
67 8 ▶sub __level1_rewrite { # TODO get rid of this when level1 support goes away
Subroutine __level1_rewrite: called CC=2 SCAR=7.1
68 8 my ( $self ) = @_;
69  
70 delete $self->{level1}
71 and $self->{def} = $self->parent()->__rewrite_level1_macro_def(
72 8 ▶ $self->name(), $self->{def} );
Branch: 1 branch
BranchTrueFalseTotal
delete $self->{"level1"} and $self->{"def"} = $self->parent->__rewrite_level1_macro_def($self->name, $self->{"def"}) 8 0 8
73  
74 8 return;
75 }
76  
77 20 1;
78  
79 __END__
« blib/lib/Astro/App/Satpass2/Format/Template/Provider.pm ↑ Summary blib/lib/Astro/App/Satpass2/FormatTime/Cldr.pm »