blib/lib/Kubernetes/Comb/Upstream/Static.pm

filter: Statementstmt 100% 44 / 44 Branchbran 100% 8 / 8 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 14 / 14 Podpod 75.0% 3 / 4 totaltotal 93.5% 73 / 78 CC 7 SCAR 8.4
CC
7
Cov
96%
_build__offered
5.1
status
3.0
BEGIN
1.0
CRAP 2.3
« blib/lib/Kubernetes/Comb/Endpoint.pm ↑ Summary examples/lib/Example/Comb/DB.pm »
1 package Kubernetes::Comb::Upstream::Static;
2 # ABSTRACT: An upstream with fixed endpoints and no cluster behind it
3 4 our $VERSION = '0.002';
4  
5 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 with 'Kubernetes::Comb::Role::Upstream';
7  
8 4 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Future;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Types::Standard qw( ArrayRef Bool InstanceOf Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Kubernetes::Comb::Endpoint;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 has _given => (
17 is => 'ro',
18 isa => ArrayRef,
19 init_arg => 'endpoints',
20 5 ▶ default => sub { [] }
Subroutine __ANON__: called CC=1 SCAR=0.0
21 4 );
22  
23 4 has _offered => (
24 is => 'lazy',
25 isa => ArrayRef[ InstanceOf['Kubernetes::Comb::Endpoint'] ],
26 init_arg => undef
27 );
28  
29 51 ▶sub _build__offered {
Subroutine _build__offered: called CC=5 SCAR=16.3
30 51 my ( $self ) = @_;
31 return [ map {
32 47 ▶ blessed $_ && $_->isa('Kubernetes::Comb::Endpoint') ? $_
Branch: 2 branches
BranchTrueFalseTotal
builtin::blessed($_) && $_->isa('Kubernetes::Comb::Endpoint') ? : 1 46 47
ref $_ eq 'HASH' ? : 45 1 46
Condition60%3/5
builtin::blessed($_) and $_->isa("Kubernetes::Comb::Endpoint")
!ll&&!rl&&r
4601
ref $_ || 'a plain scalar'
l!l
01
MC/DC50%1/2
builtin::blessed($_) and $_->isa("Kubernetes::Comb::Endpoint")
builtin::blessed($_) $_->isa("Kubernetes::Comb::Endpoint")
MC/DC0%0/1
ref $_ || 'a plain scalar'
ref $_
Truth table66%2/3
A and B
A= builtin::blessed($_)B= $_->isa("Kubernetes::Comb::Endpoint")
ABresult
0X0
100
111
Truth table50%1/2
A
A= ref $_
Aresult
11
00
33 : ref $_ eq 'HASH' ? $self->endpoint_class->new(%$_)
34 : croak ref($self).': an endpoint is a hashref or a Kubernetes::Comb::Endpoint, got '
35 .( ref $_ || 'a plain scalar' );
36 51 } @{ $self->_given } ];
37 }
38  
39  
40 4 has phase => ( is => 'ro', isa => Str, default => 'Running' );
41  
42  
43 18 ▶has via => ( is => 'ro', isa => ArrayRef[Str], default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
44  
45  
46 4 has reachable => ( is => 'ro', isa => Bool, coerce => 1, default => 1 );
47  
48  
49 4 has message => ( is => 'ro', isa => Str, predicate => 1 );
50  
51  
52 51 ▶sub BUILD { $_[0]->_offered }
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
53  
54 45 ▶sub endpoint_class { 'Kubernetes::Comb::Endpoint' }
Subroutine endpoint_class: called CC=1 SCAR=0.0
Pod documented
55  
56  
57 44 ▶sub status {
Subroutine status: called CC=3 SCAR=11.0
Pod documented
58 44 my ( $self, $comb ) = @_;
59 return Future->done( {
60 reachable => $self->reachable ? 1 : 0,
61 phase => $self->phase,
62 44 ▶ via => [ @{ $self->via } ],
Branch: 2 branches
BranchTrueFalseTotal
$self->reachable ? : 39 5 44
$self->has_message ? : 9 35 44
63 ( $self->has_message ? ( message => $self->message ) : () )
64 } );
65 }
66  
67  
68 41 ▶sub endpoints {
Subroutine endpoints: called CC=1 SCAR=0.0
Pod documented
69 41 my ( $self, $comb ) = @_;
70 41 return Future->done( [ @{ $self->_offered } ] );
71 }
72  
73  
74 4 1;
75  
76 __END__
« blib/lib/Kubernetes/Comb/Endpoint.pm ↑ Summary examples/lib/Example/Comb/DB.pm »