« 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
| |||||||||||
| 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
| |||||||||||
| 23 | 18 | $output .= $buffer; | |||||||||
| 24 | } | ||||||||||
| 25 | 18 | 1; | |||||||||
| 26 | 19 | ▶ | } or do { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 37 | 3 | ▶ | defined $text | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | or $text = ''; | ||||||||||
| 39 | 3 | ▶ | my @rslt = sort( grep { ! index $_, $text } @{ $self->{completion} } ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 73 | |||||||||||
| 74 | 8 | return; | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 20 | 1; | |||||||||
| 78 | |||||||||||
| 79 | __END__ | ||||||||||