| 1 | package Search::Sitemap::Ping; | ||||||||||||||||||||||||||||
| 2 | 1 | $Search::Sitemap::Ping::VERSION = '2.13_01'; | |||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.008003; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | our $AUTHORITY = 'cpan:JASONK'; | |||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Search::Sitemap::Pinger; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Class::Trigger qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | progress success failure | ||||||||||||||||||||||||||||
| 11 | before_submit after_submit | ||||||||||||||||||||||||||||
| 12 | before_engine after_engine | ||||||||||||||||||||||||||||
| 13 | 1 | ); | |||||||||||||||||||||||||||
| 14 | 1 | ▶ | use MooseX::Types::Moose qw( ArrayRef ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use namespace::clean -except => [qw( meta add_trigger call_trigger )]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | has 'urls' => ( | ||||||||||||||||||||||||||||
| 18 | is => 'rw', | ||||||||||||||||||||||||||||
| 19 | isa => ArrayRef, | ||||||||||||||||||||||||||||
| 20 | lazy => 1, | ||||||||||||||||||||||||||||
| 21 | auto_deref => 1, | ||||||||||||||||||||||||||||
| 22 | 0 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 23 | 1 | ); | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | has 'engines' => ( | ||||||||||||||||||||||||||||
| 26 | is => 'rw', | ||||||||||||||||||||||||||||
| 27 | isa => ArrayRef['Search::Sitemap::Pinger'], | ||||||||||||||||||||||||||||
| 28 | auto_deref => 1, | ||||||||||||||||||||||||||||
| 29 | lazy => 1, | ||||||||||||||||||||||||||||
| 30 | 1 | ▶ | default => sub { [ | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 1 | map { $_->new } Search::Sitemap::Pinger->ALL_PINGERS | |||||||||||||||||||||||||||
| 32 | ] }, | ||||||||||||||||||||||||||||
| 33 | 1 | ); | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | sub BUILDARGS { | ||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 37 | 1 | my @urls = (); | |||||||||||||||||||||||||||
| 38 | 1 | ▶ | while ( @_ && $_[0] =~ m{^https?://} ) { push( @urls, shift ) } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and $_[0] =~ m[^https?://]
MC/DC50%1/2
@_ and $_[0] =~ m[^https?://]
@_
$_[0] =~ m[^https?://]
Truth table66%2/3
A and B
A= @_B= $_[0] =~ m[^https?://]
| |||||||||||||||||||||||||||||
| 39 | 1 | my $args = $class->SUPER::BUILDARGS( @_ ); | |||||||||||||||||||||||||||
| 40 | 1 | ▶ | push( @{ $args->{ 'urls' } ||= [] }, @urls ); | ||||||||||||||||||||||||||
|
Condition50%1/2
$args->{"urls"} ||= []
MC/DC0%0/1
$args->{"urls"} ||= []
$args->{"urls"}
Truth table50%1/2
A
A= $args->{"urls"}
| |||||||||||||||||||||||||||||
| 41 | 1 | return $args; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1 | ▶ | sub submit { | ||||||||||||||||||||||||||
|
Subroutine
submit: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 1 | $self->call_trigger( 'before_submit' ); | |||||||||||||||||||||||||||
| 48 | 1 | my $total = @{ $self->urls } * @{ $self->engines }; | |||||||||||||||||||||||||||
| 49 | 1 | my $attempt = 0; | |||||||||||||||||||||||||||
| 50 | 1 | my $success = 0; | |||||||||||||||||||||||||||
| 51 | 1 | my $failure = 0; | |||||||||||||||||||||||||||
| 52 | 5 | ▶ | my $progress = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | 5 | my $percent = sprintf( '%.02f', ( $attempt / $total ) * 100 ); | |||||||||||||||||||||||||||
| 54 | 5 | $self->call_trigger( 'progress', | |||||||||||||||||||||||||||
| 55 | $percent, $total, $attempt, $success, $failure | ||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||
| 57 | 1 | }; | |||||||||||||||||||||||||||
| 58 | 1 | $progress->(); | |||||||||||||||||||||||||||
| 59 | 1 | for my $engine ( $self->engines ) { | |||||||||||||||||||||||||||
| 60 | 4 | my @urls = $self->urls; | |||||||||||||||||||||||||||
| 61 | 4 | $self->call_trigger( 'before_engine', $engine, \@urls ); | |||||||||||||||||||||||||||
| 62 | 4 | ▶ | next unless @urls; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 4 | ▶ | $engine->submit( sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=17.9
| |||||||||||||||||||||||||||||
| 64 | 4 | my ( $status, $url, $msg ) = @_; | |||||||||||||||||||||||||||
| 65 | 4 | $attempt++; | |||||||||||||||||||||||||||
| 66 | 4 | ▶ | if ( $status eq 'success' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 4 | $success++; | |||||||||||||||||||||||||||
| 68 | } else { | ||||||||||||||||||||||||||||
| 69 | 0 | $failure++; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | 4 | ▶ | unless ( $progress->() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ( $status eq 'failure' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 0 | warn "Submitting $url to $engine failed: $msg\n"; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | 4 | }, @urls ); | |||||||||||||||||||||||||||
| 77 | 4 | $self->call_trigger( 'after_engine', $engine ); | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | 1 | $self->call_trigger( 'after_submit' ); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 83 | 1 | 1; | |||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||