| 1 | package Iterator::Flex::Map; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Map Iterator Class | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use v5.28; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use experimental 'signatures'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 5 | our $VERSION = '0.33'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use Iterator::Flex::Utils qw( STATE THROW EXHAUSTION :IterAttrs :IterStates ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use Iterator::Flex::Factory 'to_iterator'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 5 | ▶ | use Ref::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use parent 'Iterator::Flex::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 9 | ▶ | sub new ( $class, $code, $iterable, $pars = {} ) { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | 9 | ▶ | throw_failure( parameter => q{'code' parameter is not a coderef} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | unless Ref::Util::is_coderef( $code ); | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 9 | $class->SUPER::new( { code => $code, src => $iterable }, $pars ); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | ▶ | sub construct ( $class, $state ) { | |||||||||||||||||||||||||||
|
Subroutine
construct: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 9 | ▶ | throw_failure( parameter => q{'state' parameter must be a HASH reference} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | unless Ref::Util::is_hashref( $state ); | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 9 | my ( $code, $src ) = @{$state}{qw[ code src ]}; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 9 | $src | |||||||||||||||||||||||||||
| 63 | = to_iterator( $src, { ( +EXHAUSTION ) => THROW } ); | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 9 | my @values; | |||||||||||||||||||||||||||
| 66 | my $self; | ||||||||||||||||||||||||||||
| 67 | 9 | my $iterator_state; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | return { | ||||||||||||||||||||||||||||
| 70 | ( +_NAME ) => 'imap', | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | ( +_SELF ) => \$self, | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | ( +STATE ) => \$iterator_state, | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | ( +NEXT ) => sub { | ||||||||||||||||||||||||||||
| 77 | 106 | ▶ | return $self->signal_exhaustion if $iterator_state == IterState_EXHAUSTED; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.3
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 106 | ▶ | unless ( @values ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | eval { | ||||||||||||||||||||||||||||
| 81 | 67 | my $value = $src->(); | |||||||||||||||||||||||||||
| 82 | 55 | local $_ = $value; | |||||||||||||||||||||||||||
| 83 | 55 | @values = $code->(); | |||||||||||||||||||||||||||
| 84 | 55 | 1; | |||||||||||||||||||||||||||
| 85 | 67 | ▶ | } or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 12 | ▶ | die $@ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
Ref::Util::XS::is_blessed_ref($@) and $@->isa("Iterator::Flex::Failure::Exhausted")
MC/DC0%0/2
Ref::Util::XS::is_blessed_ref($@) and $@->isa("Iterator::Flex::Failure::Exhausted")
Ref::Util::XS::is_blessed_ref($@)
$@->isa("Iterator::Flex::Failure::Exhausted")
Truth table33%1/3
A and B
A= Ref::Util::XS::is_blessed_ref($@)B= $@->isa("Iterator::Flex::Failure::Exhausted")
| |||||||||||||||||||||||||||||
| 87 | unless Ref::Util::is_blessed_ref( $@ ) | ||||||||||||||||||||||||||||
| 88 | && $@->isa( 'Iterator::Flex::Failure::Exhausted' ); | ||||||||||||||||||||||||||||
| 89 | 12 | return $self->signal_exhaustion; | |||||||||||||||||||||||||||
| 90 | }; | ||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | 94 | return shift @values; | |||||||||||||||||||||||||||
| 93 | }, | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 2 | ▶ | ( +RESET ) => sub { @values = () }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 96 | 1 | ▶ | ( +REWIND ) => sub { @values = () }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 97 | 9 | ( +_DEPENDS ) => $src, | |||||||||||||||||||||||||||
| 98 | }; | ||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 5 | __PACKAGE__->_add_roles( qw[ | |||||||||||||||||||||||||||
| 103 | State::Closure | ||||||||||||||||||||||||||||
| 104 | Next::ClosedSelf | ||||||||||||||||||||||||||||
| 105 | Reset::Closure | ||||||||||||||||||||||||||||
| 106 | Rewind::Closure | ||||||||||||||||||||||||||||
| 107 | ] ); | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 5 | 1; | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | # | ||||||||||||||||||||||||||||
| 112 | # This file is part of Iterator-Flex | ||||||||||||||||||||||||||||
| 113 | # | ||||||||||||||||||||||||||||
| 114 | # This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory. | ||||||||||||||||||||||||||||
| 115 | # | ||||||||||||||||||||||||||||
| 116 | # This is free software, licensed under: | ||||||||||||||||||||||||||||
| 117 | # | ||||||||||||||||||||||||||||
| 118 | # The GNU General Public License, Version 3, June 2007 | ||||||||||||||||||||||||||||
| 119 | # | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | __END__ | ||||||||||||||||||||||||||||