| 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
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
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
$run and not Ekorn::Pipeline::ending()
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()
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
Ref::Util::XS::is_plain_hashref($run) and $run->{"statement"} isa "DBIx::Squirrel::st"
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"
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||