blib/lib/JQ/Lite/Runtime.pm

filter: Statementstmt 97.4% 38 / 39 Branchbran 75.0% 6 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 84.1% 53 / 63 CC 7 SCAR 9.1
CC
7
Cov
90%
decode_input
4.1
evaluate_filter
3.0
new
2.0
CRAP 2.5
« blib/lib/JQ/Lite/Builtin.pm ↑ Summary blib/lib/JQ/Lite/Builtin/Object.pm »
1 package JQ::Lite::Runtime;
2  
3 182 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 182 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 182 ▶use JQ::Lite::Error ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 182 ▶use JQ::Lite::Filters ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 182 ▶use JQ::Lite::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 6053 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
11 6053 my ($class, %opts) = @_;
12 6053 ▶ die 'runtime owner is required' unless $opts{owner};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"owner"} 0 6053 6053
13 6053 return bless { owner => $opts{owner} }, $class;
14 }
15  
16 6053 ▶sub decode_input {
Subroutine decode_input: called CC=4 SCAR=14.2
Pod undocumented
17 6053 my ($self, $json_text) = @_;
18  
19 6053 my ($value, $ok, $error);
20 {
21 6053 local $@;
22 6053 $ok = eval {
23 6053 $value = JQ::Lite::Util::_decode_json($json_text);
24 6052 1;
25 };
26 6053 $error = $@;
27 }
28  
29 6053 ▶ return $value if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 6052 1 6053
30 0 ▶ die $error if ref($error) && eval { $error->isa('JQ::Lite::Error') };
Branch: 1 branch
BranchTrueFalseTotal
if ref $error and eval { do { $error->isa("JQ::Lite::Error") } } 0 1 1
Condition33%1/3
ref $error and eval { do { $error->isa("JQ::Lite::Error") } }
!ll&&!rl&&r
100
MC/DC0%0/2
ref $error and eval { do { $error->isa("JQ::Lite::Error") } }
ref $error eval { do { $error->isa("JQ::Lite::Error") } }
Truth table33%1/3
A and B
A= ref $errorB= eval { do { $error->isa("JQ::Lite::Error") } }
ABresult
0X0
100
111
31 1 die JQ::Lite::Error::Input->new(message => $error);
32 }
33  
34 1528 ▶sub evaluate_filter {
Subroutine evaluate_filter: called CC=3 SCAR=11.0
Pod undocumented
35 1528 my ($self, $filter, $inputs) = @_;
36  
37 1528 my @outputs;
38 1528 ▶ if (JQ::Lite::Filters::apply(
Branch: 1 branch
BranchTrueFalseTotal
if (JQ::Lite::Filters::apply($self->{"owner"}, $filter->source, $inputs, \@outputs)) 957 508 1465
39 $self->{owner}, $filter->source, $inputs, \@outputs
40 ))
41 {
42 957 return @outputs;
43 }
44  
45 508 for my $input (@{$inputs}) {
46 527 push @outputs, JQ::Lite::Util::_traverse($input, $filter->source);
47 }
48  
49 505 return @outputs;
50 }
51  
52 182 1;
« blib/lib/JQ/Lite/Builtin.pm ↑ Summary blib/lib/JQ/Lite/Builtin/Object.pm »