Elasticsearch/Role/Transport.pm

filter: Statementstmt 100% 42 / 42 Branchbran 90.0% 9 / 10 Conditioncond 92.3% 12 / 13 MC/DCmcdc 71.4% 5 / 7 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 92.5% 74 / 80 CC 12 SCAR 21.7
CC
12
Cov
97%
tidy_request
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 8.8
« Elasticsearch/Client/7_0/Scroll.pm ↑ Summary Elasticsearch/Role/CxnPool/Sniff.pm »
1 # Licensed to Elasticsearch B.V under one or more agreements.
2 # Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3 # See the LICENSE file in the project root for more information
4  
5 package Search::Elasticsearch::Role::Transport;
6 55 $Search::Elasticsearch::Role::Transport::VERSION = '7.30_1'; # TRIAL
7  
8 55 $Search::Elasticsearch::Role::Transport::VERSION = '7.301';
9 55 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 55 requires qw(perform_request);
12  
13 55 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 55 ▶use Search::Elasticsearch::Util qw(parse_params is_compat);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 55 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 55 has 'serializer' => ( is => 'ro', required => 1 );
18 55 has 'logger' => ( is => 'ro', required => 1 );
19 55 has 'send_get_body_as' => ( is => 'ro', default => 'GET' );
20 55 has 'cxn_pool' => ( is => 'ro', required => 1 );
21  
22 #===================================
23 sub BUILD {
24 #===================================
25 100 ▶ my $self = shift;
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
26 100 my $pool = $self->cxn_pool;
27 100 is_compat( 'cxn_pool', $self, $pool );
28 100 is_compat( 'cxn', $self, $pool->cxn_factory->cxn_class );
29 100 return $self;
30 }
31  
32 #===================================
33 sub tidy_request {
34 #===================================
35 175 ▶ my ( $self, $params ) = parse_params(@_);
Subroutine tidy_request: called CC=12 SCAR=24.9
Pod undocumented
36 175 ▶ $params->{method} ||= 'GET';
Condition100%2/2
$params->{"method"} ||= "GET"
l!l
20155
MC/DC100%1/1
$params->{"method"} ||= "GET"
$params->{"method"}
Truth table100%2/2
A
A= $params->{"method"}
Aresult
11
00
37 175 ▶ $params->{path} ||= '/';
Condition100%2/2
$params->{"path"} ||= "/"
l!l
26149
MC/DC100%1/1
$params->{"path"} ||= "/"
$params->{"path"}
Truth table100%2/2
A
A= $params->{"path"}
Aresult
11
00
38 175 ▶ $params->{qs} ||= {};
Condition100%2/2
$params->{"qs"} ||= {}
l!l
20155
MC/DC100%1/1
$params->{"qs"} ||= {}
$params->{"qs"}
Truth table100%2/2
A
A= $params->{"qs"}
Aresult
11
00
39 175 ▶ $params->{ignore} ||= [];
Condition100%2/2
$params->{"ignore"} ||= []
l!l
19156
MC/DC100%1/1
$params->{"ignore"} ||= []
$params->{"ignore"}
Truth table100%2/2
A
A= $params->{"ignore"}
Aresult
11
00
40 175 my $body = $params->{body};
41 175 ▶ return $params unless defined $body;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $body 167 8 175
42  
43 8 ▶ $params->{serialize} ||= 'std';
Condition100%2/2
$params->{"serialize"} ||= "std"
l!l
17
MC/DC100%1/1
$params->{"serialize"} ||= "std"
$params->{"serialize"}
Truth table100%2/2
A
A= $params->{"serialize"}
Aresult
11
00
44 $params->{data}
45 8 ▶ = $params->{serialize} eq 'std'
Branch: 1 branch
BranchTrueFalseTotal
$params->{'serialize'} eq 'std' ? : 7 1 8
46 ? $self->serializer->encode($body)
47 : $self->serializer->encode_bulk($body);
48  
49 8 ▶ if ( $params->{method} eq 'GET' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"method"} eq "GET") 8 0 8
50 8 my $send_as = $self->send_get_body_as;
51 8 ▶ if ( $send_as eq 'POST' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($send_as eq 'POST') { } 1 7 8
elsif ($send_as eq 'source') { } 1 6 7
52 1 $params->{method} = 'POST';
53 }
54 elsif ( $send_as eq 'source' ) {
55 1 $params->{qs}{source} = delete $params->{data};
56 1 delete $params->{body};
57 }
58 }
59  
60 8 ▶ $params->{mime_type} ||= $self->serializer->mime_type;
Condition66%2/3
$params->{"mime_type"} ||= $self->serializer->mime_type
l!l&&r!l&&!r
170
MC/DC0%0/2
$params->{"mime_type"} ||= $self->serializer->mime_type
$params->{"mime_type"} $self->serializer->mime_type
Truth table66%2/3
A ||= B
A= $params->{"mime_type"}B= $self->serializer->mime_type
ABresult
1X1
011
000
61 8 return $params;
62  
63 }
64  
65 55 1;
66  
67 #ABSTRACT: Transport role providing interface between the client class and the Elasticsearch cluster
68  
69 __END__
« Elasticsearch/Client/7_0/Scroll.pm ↑ Summary Elasticsearch/Role/CxnPool/Sniff.pm »