| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catmandu::Importer::Multi; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
780
|
use Catmandu::Sane; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
10
|
use Catmandu::Util qw(is_string); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
65
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Catmandu; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
7
|
|
|
9
|
1
|
|
|
1
|
|
727
|
use Catmandu::MultiIterator; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
29
|
|
|
10
|
1
|
|
|
1
|
|
10
|
use Moo; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
15
|
|
|
11
|
1
|
|
|
1
|
|
412
|
use namespace::clean; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
4
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'Catmandu::Importer'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has importers => ( |
|
16
|
|
|
|
|
|
|
is => 'ro', |
|
17
|
|
|
|
|
|
|
default => sub {[]}, |
|
18
|
|
|
|
|
|
|
coerce => sub { |
|
19
|
|
|
|
|
|
|
my $importers = $_[0]; |
|
20
|
|
|
|
|
|
|
return [ |
|
21
|
|
|
|
|
|
|
map { |
|
22
|
|
|
|
|
|
|
if (is_string($_)) { |
|
23
|
|
|
|
|
|
|
Catmandu->importer($_); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
else { |
|
26
|
|
|
|
|
|
|
$_; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
} @$importers |
|
29
|
|
|
|
|
|
|
]; |
|
30
|
|
|
|
|
|
|
}, |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub generator { |
|
34
|
|
|
|
|
|
|
my ($self) = @_; |
|
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
|
|
|
|
|
|
|
}; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
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 |