Juno/Check/HTTP.pm

filter: Statementstmt 58.9% 23 / 39 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 6 / 10 Podpod 100% 1 / 1 totaltotal 50.0% 30 / 60 CC 7 SCAR 25.1
CC
7
Cov
47%
__ANON__
30.0
check
12.0
__ANON__
2.0
CRAP 12.2
↑ Summary Juno/Check/TCP.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Juno::Check::HTTP;
4 # ABSTRACT: An HTTP check for Juno
5 1 $Juno::Check::HTTP::VERSION = '0.010';
6 1 ▶use AnyEvent::HTTP;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use MooX::Types::MooseLike::Base qw<Str HashRef>;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 with 'Juno::Role::Check';
12  
13 has path => (
14 is => 'ro',
15 isa => Str,
16 0 ▶ default => sub {'/'},
Subroutine __ANON__: not called CC=1 SCAR=6.9
17 1 );
18  
19 has headers => (
20 is => 'ro',
21 isa => HashRef,
22 0 ▶ default => sub { {} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 1 );
24  
25 0 ▶sub check {
Subroutine check: not called CC=3 SCAR=24.8
Pod documented
26 0 my $self = shift;
27 0 my @hosts = @{ $self->hosts };
28 0 my $path = $self->path;
29  
30 0 foreach my $host (@hosts) {
31 0 my $url = "http://$host" . $path;
32  
33 0 ▶ $self->has_on_before
Branch: 1 branch
BranchTrueFalseTotal
$self->has_on_before and $self->on_before->($self, $host) 0 0 0
34 and $self->on_before->( $self, $host );
35  
36 0 ▶ http_get $url, $self->headers, sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
37 0 my ( $body, $headers ) = @_;
38  
39 0 ▶ $self->has_on_result
Branch: 1 branch
BranchTrueFalseTotal
$self->has_on_result and $self->on_result->($self, $host, $body, $headers) 0 0 0
40 and $self->on_result->( $self, $host, $body, $headers );
41  
42 0 ▶ if ( $headers->{'Status'} =~ /^2/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headers->{'Status'} =~ /^2/) { } 0 0 0
43 0 ▶ $self->has_on_success
Branch: 1 branch
BranchTrueFalseTotal
$self->has_on_success and $self->on_success->($self, $host, $body, $headers) 0 0 0
44 and $self->on_success->( $self, $host, $body, $headers );
45 } else {
46 0 ▶ $self->has_on_fail
Branch: 1 branch
BranchTrueFalseTotal
$self->has_on_fail and $self->on_fail->($self, $host, $body, $headers) 0 0 0
47 and $self->on_fail->( $self, $host, $body, $headers );
48 }
49 0 };
50 }
51  
52 0 return 0;
53 }
54  
55 1 1;
56  
57 __END__
↑ Summary Juno/Check/TCP.pm »