« blib/lib/Astro/App/Satpass2/FormatTime/POSIX/Strftime.pm
↑ Summary
blib/lib/Astro/App/Satpass2/Macro.pm »
| 1 | package Astro::App::Satpass2::Warner; | ||||||||||
| 2 | |||||||||||
| 3 | 21 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 21 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 21 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 21 | ▶ | use Astro::App::Satpass2::Locale qw{ __message }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 21 | ▶ | use Astro::App::Satpass2::Utils qw{ @CARP_NOT }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 21 | our $VERSION = '0.059'; | |||||||||
| 12 | |||||||||||
| 13 | 26 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||
| 14 | 26 | my ( $class, @arg ) = @_; | |||||||||
| 15 | 26 | ▶ | ref $class and $class = ref $class; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 26 | my $self = {}; | |||||||||
| 17 | 26 | bless $self, $class; | |||||||||
| 18 | 26 | ▶ | while ( @arg ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 7 | my ( $name, $value ) = splice @arg, 0, 2; | |||||||||
| 20 | 7 | ▶ | my $code = $self->can( $name ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | or $self->wail( "Warner has no such method as $name" ); | ||||||||||
| 22 | 7 | $code->( $self, $value ); | |||||||||
| 23 | } | ||||||||||
| 24 | 26 | return $self; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 22 | ▶ | sub wail { | ||||||||
|
Subroutine
wail: called CC=5 SCAR=20.4
Pod
documented
| |||||||||||
| 28 | 22 | my ($self, @args) = @_; | |||||||||
| 29 | 22 | my $msg = __message( @args ); | |||||||||
| 30 | 22 | ▶ | ref $msg | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | and die $msg; | ||||||||||
| 32 | 21 | chomp $msg; | |||||||||
| 33 | 21 | ▶ | if ($self->warning()) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | ▶ | if ( $Carp::Verbose ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | require Carp; # Paranoia | |||||||||
| 36 | 0 | Carp::confess( $msg ); | |||||||||
| 37 | } | ||||||||||
| 38 | 0 | ▶ | $msg =~ m/[.?!]\z/msx or $msg .= '.'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | die $msg, "\n"; | |||||||||
| 40 | } else { | ||||||||||
| 41 | 21 | $msg =~ s/[.?!]\z//msx; | |||||||||
| 42 | 21 | require Carp; | |||||||||
| 43 | 21 | Carp::croak( $msg ); | |||||||||
| 44 | } | ||||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 32 | ▶ | sub warning { | ||||||||
|
Subroutine
warning: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 48 | 32 | my ( $self, @arg ) = @_; | |||||||||
| 49 | 32 | ▶ | if ( @arg ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 7 | $self->{warning} = shift @arg; | |||||||||
| 51 | 7 | return $self; | |||||||||
| 52 | } else { | ||||||||||
| 53 | 25 | return $self->{warning}; | |||||||||
| 54 | } | ||||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 1 | ▶ | sub weep { | ||||||||
|
Subroutine
weep: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 58 | 1 | my ( undef, @args ) = @_; # Invocant unused | |||||||||
| 59 | 1 | my $msg = join ' ', __message( 'Programming Error -' ), __message( @args ); | |||||||||
| 60 | 1 | chomp $msg; | |||||||||
| 61 | 1 | require Carp; | |||||||||
| 62 | 1 | Carp::confess( $msg ); | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 4 | ▶ | sub whinge { | ||||||||
|
Subroutine
whinge: called CC=4 SCAR=16.5
Pod
documented
| |||||||||||
| 66 | 4 | my ($self, @args) = @_; | |||||||||
| 67 | 4 | my $msg = __message( @args ); | |||||||||
| 68 | ref $msg | ||||||||||
| 69 | 4 | ▶ | and do { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | 0 | warn $msg; | |||||||||
| 71 | 0 | return; | |||||||||
| 72 | }; | ||||||||||
| 73 | 4 | chomp $msg; | |||||||||
| 74 | 4 | ▶ | if ($self->warning()) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | 0 | ▶ | $msg =~ m/ [.?!] \z /msx or $msg .= '.'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 76 | 0 | warn $msg, "\n"; | |||||||||
| 77 | } else { | ||||||||||
| 78 | 4 | $msg =~ s/ [.?!] \z //msx; | |||||||||
| 79 | 4 | require Carp; | |||||||||
| 80 | 4 | Carp::carp( $msg ); | |||||||||
| 81 | } | ||||||||||
| 82 | 4 | return; | |||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | 21 | 1; | |||||||||
| 86 | |||||||||||
| 87 | __END__ | ||||||||||