| 1 | package App::SimpleScan::Plugin::Retry; | ||||||||||
| 2 | |||||||||||
| 3 | 14 | our $VERSION = '1.02'; | |||||||||
| 4 | |||||||||||
| 5 | 14 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 14 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 14 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 14 | ▶ | use Scalar::Util qw(looks_like_number); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 14 | my ($retry); | |||||||||
| 11 | |||||||||||
| 12 | 13 | ▶ | sub import { | ||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 14 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 13 | *{caller() . '::retry'} = \&retry; | |||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | 12 | ▶ | sub retry { | ||||||||
|
Subroutine
retry: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 18 | 12 | my($self, $value) = @_; | |||||||||
| 19 | 12 | ▶ | $retry = $value if defined $value; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 12 | $retry; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 12 | ▶ | sub options { | ||||||||
|
Subroutine
options: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 24 | 12 | return ('retry=s' => \$retry, | |||||||||
| 25 | ); | ||||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 12 | ▶ | sub validate_options { | ||||||||
|
Subroutine
validate_options: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 29 | 12 | my($class, $app) = @_; | |||||||||
| 30 | 12 | ▶ | if (defined (my $count = $app->retry)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 6 | $app->pragma('retry')->($app, $count); | |||||||||
| 32 | } | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 12 | ▶ | sub pragmas { | ||||||||
|
Subroutine
pragmas: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 36 | 12 | return (['retry' => \&retry_pragma], | |||||||||
| 37 | ); | ||||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 15 | ▶ | sub retry_pragma { | ||||||||
|
Subroutine
retry_pragma: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 41 | 15 | my ($self, $args) = @_; | |||||||||
| 42 | 15 | ▶ | if (looks_like_number($args)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 13 | $args = int $args; | |||||||||
| 44 | 13 | $self->stack_code(qq(mech->retry("$args");\n)); | |||||||||
| 45 | } | ||||||||||
| 46 | else { | ||||||||||
| 47 | 2 | $self->stack_test(qq(fail "retry count '$args' is not a number";\n)); | |||||||||
| 48 | } | ||||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 14 | 1; # Magic true value required at end of module | |||||||||
| 52 | __END__ | ||||||||||