line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Iterator; |
2
|
|
|
|
|
|
|
|
3
|
65
|
|
|
65
|
|
107705
|
use Catmandu::Sane; |
|
65
|
|
|
|
|
164
|
|
|
65
|
|
|
|
|
512
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
65
|
|
|
65
|
|
21001
|
use Role::Tiny::With; |
|
65
|
|
|
|
|
12925
|
|
|
65
|
|
|
|
|
3326
|
|
8
|
65
|
|
|
65
|
|
474
|
use namespace::clean; |
|
65
|
|
|
|
|
181
|
|
|
65
|
|
|
|
|
455
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Catmandu::Iterable'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
79
|
|
|
79
|
0
|
1695
|
bless $_[1], $_[0]; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub generator { |
17
|
76
|
|
|
76
|
1
|
153
|
goto &{$_[0]}; |
|
76
|
|
|
|
|
306
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
1; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
__END__ |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=pod |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 NAME |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Catmandu::Iterator - Base class for all Catmandu iterators |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 SYNOPSIS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
package My::MockIterator; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use Catmandu; |
35
|
|
|
|
|
|
|
use Moo; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
with 'Catmandu::Iterable'; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub generator { |
40
|
|
|
|
|
|
|
sub { |
41
|
|
|
|
|
|
|
# Generator some random data |
42
|
|
|
|
|
|
|
+{ random => rand }; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
package main; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $it = My::MockIterator->new; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $first = $it->first; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$it->each(sub { |
53
|
|
|
|
|
|
|
my $item = shift; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
print $item->{random} , "\n"; |
56
|
|
|
|
|
|
|
}); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $it2 = $it->map(sub { shift->{random} * 2 }); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 METHODS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 generator |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Should return a closure that generates one Perl hash. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 INHERIT |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
If you provide a generator, then the class will generator all methods from L<Catmandu::Iterable>. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SEE ALSO |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L<Catmandu::Iterable> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |