blib/lib/Catmandu/Importer/Multi.pm

filter: Statementstmt 93.3% 28 / 30 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 1 totaltotal 88.1% 37 / 42 CC 2 SCAR 2.8
CC
2
Cov
91%
__ANON__
2.1
__ANON__
2.0
BEGIN
1.0
CRAP 1.3
« blib/lib/Catmandu/Fix/Condition/is_true.pm ↑ Summary blib/lib/Catmandu/Fix/perlcode.pm »
1 package Catmandu::Importer::Multi;
2  
3 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '1.0201_02';
6  
7 1 ▶use Catmandu::Util qw(is_string);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Catmandu;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Catmandu::MultiIterator;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 with 'Catmandu::Importer';
14  
15 has importers => (
16 is => 'ro',
17 0 ▶ default => sub {[]},
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 coerce => sub {
19 1 ▶ my $importers = $_[0];
Subroutine __ANON__: called CC=2 SCAR=7.4
20 return [
21 map {
22 1 ▶ if (is_string($_)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_string($_)) { } 0 2 2
23 0 Catmandu->importer($_);
24 }
25 else {
26 2 $_;
27 }
28 } @$importers
29 ];
30 },
31 1 );
32  
33 sub generator {
34 1 ▶ my ($self) = @_;
Subroutine generator: called CC=1 SCAR=0.0
Pod undocumented
35 sub {
36 state $generators = [map {$_->generator} @{$self->importers}];
37 while (@$generators) {
38 my $data = $generators->[0]->();
39 return $data if defined $data;
40 shift @$generators;
41 }
42 return;
43 1 };
44 }
45  
46 1 1;
47  
48 __END__
49  
50 =pod
51  
52 =head1 NAME
53  
54 Catmandu::Importer::Multi - Chain multiple importers together
55  
56 =head1 SYNOPSIS
57  
58 use Catmandu::Importer::Multi;
59  
60 my $importer = Catmandu::Importer::Multi->new(importers => [
61 Catmandu::Importer::Mock->new,
62 Catmandu::Importer::Mock->new,
63 ]);
64  
65 my $importer = Catmandu::Importer::Multi->new(
66 'importer1',
67 'importer2',
68 );
69  
70 # return all the items of each importer in turn
71 $importer->each(sub {
72 # ...
73 });
74  
75 =head1 METHODS
76  
77 Every L<Catmandu::Importer> is a L<Catmandu::Iterable> all its methods are
78 inherited.
79  
80 =cut
« blib/lib/Catmandu/Fix/Condition/is_true.pm ↑ Summary blib/lib/Catmandu/Fix/perlcode.pm »