| 1 | 13 | ▶ | use v5.36; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | |||||||||||
| 3 | package Ekorn::Pipeline::Source; | ||||||||||
| 4 | |||||||||||
| 5 | 13 | ▶ | use parent 'Ekorn::Pipeline::Element'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 13 | ▶ | use Ref::Util qw(is_coderef); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 13 | ▶ | use Ekorn::Pipeline::Errors qw(croakf); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 13 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | # Croak at the line that called Ekorn::Pipeline. | ||||||||||
| 12 | 13 | our @CARP_NOT = @Ekorn::Pipeline::Errors::INTERNAL; | |||||||||
| 13 | |||||||||||
| 14 | # Return a source made afresh for each run by the set-up given, which | ||||||||||
| 15 | # returns the source's step and, optionally, its end and a context for | ||||||||||
| 16 | # the run. Called directly, it croaks: a run of its own would never be | ||||||||||
| 17 | # ended, so what it opened would stay open. | ||||||||||
| 18 | 290 | ▶ | sub new ($class, $setup) { | ||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 19 | 290 | ▶ | croakf 'Expected a code reference' unless is_coderef($setup); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | return bless { | ||||||||||
| 21 | setup => $setup, | ||||||||||
| 22 | 1 | ▶ | call => sub { croakf 'Expected a source to be read through iterator' }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 288 | }, $class; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | # Return what the set-up returns for a new run: the step, and | ||||||||||
| 28 | # optionally the end and a context. | ||||||||||
| 29 | 283 | ▶ | sub EKORN_SOURCE ($self) { | ||||||||
|
Subroutine
EKORN_SOURCE: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 30 | 283 | return $self->{setup}->(); | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 13 | 1; | |||||||||
| 34 | |||||||||||
| 35 | __END__ | ||||||||||