blib/lib/DBIx/Squirrel/Context.pm

filter: Statementstmt 100% 33 / 33 Branchbran 100% 6 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 11 / 11 Podpod 100% 4 / 4 totaltotal 96.6% 57 / 59 CC 5 SCAR 5.9
CC
5
Cov
98%
statement_context
3.0
result_original
3.0
BEGIN
1.0
CRAP 1.8
« blib/lib/DBIx/Squirrel/Errors.pm ↑ Summary blib/lib/DBIx/Squirrel/Results.pm »
1 31 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package DBIx::Squirrel::Context;
4  
5 31 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 31 ▶use Ref::Util qw(is_plain_hashref);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 31 ▶use DBIx::Squirrel::Errors qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 31 ▶use Ekorn::Pipeline qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 31 ▶use Ekorn::Pipeline::Context qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 31 ▶use namespace::clean -except => 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 31 our @EXPORT_OK = qw(iterator result_number result_original);
15  
16 # Croak at the line that called DBIx::Squirrel.
17 31 our @CARP_NOT = @DBIx::Squirrel::Errors::INTERNAL;
18  
19 # The iterator running the stages, set by the iterator while they run; a
20 # package variable, so the iterator's next can localise it itself,
21 # without a call for each row. The row a value came from is the run's,
22 # in the context a statement's source gives it, so it's there in any run
23 # reading a statement.
24 31 our $ITERATOR;
25  
26 # The iterator running the stage.
27 12 ▶sub iterator : prototype() () {
Subroutine iterator: called CC=1 SCAR=0.0
Pod documented
28 12 return $ITERATOR;
29 }
30  
31 # The number of the result being made, from 1: Ekorn's own sub, under our
32 # name, as every run counts its results (roadmap 2026-0032, D1), so a
33 # stage reading it pays for one call, not two. Ekorn's has an empty
34 # prototype from v0.3.12, as ours always had, so result_number + 1 adds
35 # one.
36 31 *result_number = \&Ekorn::Pipeline::Context::result_number;
37  
38 # The row the result is being made from, as it was fetched; undef for a
39 # result a flush is making, which comes from every row. Outside a run
40 # reading a statement, Ekorn's: the value the run's source gave
41 # (roadmap 2026-0032, D2).
42 34 ▶sub result_original : prototype() () {
Subroutine result_original: called CC=3 SCAR=11.0
Pod documented
43 34 my $run = statement_context();
44 34 ▶ return Ekorn::Pipeline::Context::result_original() unless $run;
Branch: 1 branch
BranchTrueFalseTotal
unless $run 5 29 34
45 29 ▶ return Ekorn::Pipeline::ending() ? undef : $run->{row};
Branch: 1 branch
BranchTrueFalseTotal
Ekorn::Pipeline::ending() ? : 4 25 29
46 }
47  
48 # For DBIx::Squirrel's stages: the context of the run, if its source is a
49 # statement, with its columns and the row it gave last; otherwise undef.
50 83 ▶sub statement_context : prototype() () {
Subroutine statement_context: called CC=3 SCAR=11.1
Pod documented
51 83 my $run = Ekorn::Pipeline::run_context();
52 return is_plain_hashref($run)
53 83 ▶ && $run->{statement} isa 'DBIx::Squirrel::st'
Branch: 1 branch
BranchTrueFalseTotal
Ref::Util::XS::is_plain_hashref($run) && $run->{'statement'} isa 'DBIx::Squirrel::st' ? : 71 12 83
Condition66%2/3
Ref::Util::XS::is_plain_hashref($run) and $run->{"statement"} isa "DBIx::Squirrel::st"
!ll&&!rl&&r
12071
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
54 ? $run
55 : undef;
56 }
57  
58 # For DBIx::Squirrel's iterators: run code with the iterator given as the
59 # one running, and return what it returns.
60 403 ▶sub within ($iterator, $code) {
Subroutine within: called CC=1 SCAR=0.0
Pod documented
61 403 local $ITERATOR = $iterator;
62 403 return $code->();
63 }
64  
65 31 1;
66 __END__
« blib/lib/DBIx/Squirrel/Errors.pm ↑ Summary blib/lib/DBIx/Squirrel/Results.pm »