blib/lib/DBIx/Squirrel/Context.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 4 / 4 Conditioncond 77.7% 7 / 9 MC/DCmcdc 66.6% 4 / 6 Subroutinesub 100% 11 / 11 Podpod 100% 5 / 5 totaltotal 93.7% 60 / 64 CC 6 SCAR 6.4
CC
6
Cov
95%
statement_context
3.0
result_original
3.0
result_number
2.1
CRAP 1.9
« blib/lib/DBIx/Squirrel/Errors.pm ↑ Summary blib/lib/DBIx/Squirrel/Results.pm »
1 30 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package DBIx::Squirrel::Context;
4  
5 30 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 30 ▶use Ref::Util qw(is_plain_hashref);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 30 ▶use DBIx::Squirrel::Errors qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 30 ▶use Ekorn::Pipeline qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 30 ▶use namespace::clean -except => 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 30 our @EXPORT_OK = qw(iterator result_number result_original);
14  
15 # Croak at the line that called DBIx::Squirrel.
16 30 our @CARP_NOT = @DBIx::Squirrel::Errors::INTERNAL;
17  
18 # The iterator running the stages, set by the iterator while they run,
19 # as it counts its results; a package variable, so the iterator's next
20 # can localise it itself, without a call for each row. The row a value
21 # came from is the run's, in the context a statement's source gives it,
22 # so it's there in any run reading a statement.
23 30 our $ITERATOR;
24  
25 # The iterator running the stage.
26 12 ▶sub iterator : prototype() () {
Subroutine iterator: called CC=1 SCAR=0.0
Pod documented
27 12 return $ITERATOR;
28 }
29  
30 # The number of the result being made, from 1.
31 48 ▶sub result_number : prototype() () {
Subroutine result_number: called CC=2 SCAR=7.2
Pod documented
32 48 ▶ return $ITERATOR && $ITERATOR->{produced} + 1;
Condition66%2/3
$DBIx::Squirrel::Context::ITERATOR && $DBIx::Squirrel::Context::ITERATOR->{'produced'} + 1
!ll&&!rl&&r
5043
MC/DC50%1/2
$DBIx::Squirrel::Context::ITERATOR && $DBIx::Squirrel::Context::ITERATOR->{'produced'} + 1
$DBIx::Squirrel::Context::ITERATOR $DBIx::Squirrel::Context::ITERATOR->{'produced'} + 1
Truth table66%2/3
A && B
A= $DBIx::Squirrel::Context::ITERATORB= $DBIx::Squirrel::Context::ITERATOR->{'produced'} + 1
ABresult
0X0
100
111
33 }
34  
35 # The row the result is being made from, as it was fetched; undef for a
36 # result a flush is making, which comes from every row.
37 30 ▶sub result_original : prototype() () {
Subroutine result_original: called CC=3 SCAR=11.0
Pod documented
38 30 my $run = statement_context();
39 30 ▶ return $run && !Ekorn::Pipeline::ending() ? $run->{row} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$run && !Ekorn::Pipeline::ending() ? : 25 5 30
Condition100%3/3
$run and not Ekorn::Pipeline::ending()
!ll&&!rl&&r
1425
MC/DC100%2/2
$run and not Ekorn::Pipeline::ending()
$run not Ekorn::Pipeline::ending()
Truth table100%3/3
A and not(B)
A= $runB= not Ekorn::Pipeline::ending()
ABresult
0X0
100
111
40 }
41  
42 # For DBIx::Squirrel's stages: the context of the run, if its source is a
43 # statement, with its columns and the row it gave last; otherwise undef.
44 79 ▶sub statement_context : prototype() () {
Subroutine statement_context: called CC=3 SCAR=11.1
Pod documented
45 79 my $run = Ekorn::Pipeline::run_context();
46 return is_plain_hashref($run)
47 79 ▶ && $run->{statement} isa 'DBIx::Squirrel::st'
Branch: 1 branch
BranchTrueFalseTotal
Ref::Util::XS::is_plain_hashref($run) && $run->{'statement'} isa 'DBIx::Squirrel::st' ? : 71 8 79
Condition66%2/3
Ref::Util::XS::is_plain_hashref($run) and $run->{"statement"} isa "DBIx::Squirrel::st"
!ll&&!rl&&r
8071
MC/DC50%1/2
Ref::Util::XS::is_plain_hashref($run) and $run->{"statement"} isa "DBIx::Squirrel::st"
Ref::Util::XS::is_plain_hashref($run) $run->{"statement"} isa "DBIx::Squirrel::st"
Truth table66%2/3
A and B
A= Ref::Util::XS::is_plain_hashref($run)B= $run->{"statement"} isa "DBIx::Squirrel::st"
ABresult
0X0
100
111
48 ? $run
49 : undef;
50 }
51  
52 # For DBIx::Squirrel's iterators: run code with the iterator given as the
53 # one running, and return what it returns.
54 400 ▶sub within ($iterator, $code) {
Subroutine within: called CC=1 SCAR=0.0
Pod documented
55 400 local $ITERATOR = $iterator;
56 400 return $code->();
57 }
58  
59 30 1;
60 __END__
« blib/lib/DBIx/Squirrel/Errors.pm ↑ Summary blib/lib/DBIx/Squirrel/Results.pm »