line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Importer::Mock; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
431251
|
use Catmandu::Sane; |
|
17
|
|
|
|
|
51
|
|
|
17
|
|
|
|
|
151
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
17
|
|
|
17
|
|
136
|
use Moo; |
|
17
|
|
|
|
|
47
|
|
|
17
|
|
|
|
|
120
|
|
8
|
17
|
|
|
17
|
|
6564
|
use namespace::clean; |
|
17
|
|
|
|
|
47
|
|
|
17
|
|
|
|
|
145
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Catmandu::Importer'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has size => (is => 'ro'); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub generator { |
15
|
|
|
|
|
|
|
my ($self) = @_; |
16
|
|
|
|
|
|
|
my $n = 0; |
17
|
|
|
|
|
|
|
sub { |
18
|
|
|
|
|
|
|
return if defined $self->size && $n == $self->size; |
19
|
|
|
|
|
|
|
return {n => $n++}; |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
1; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
__END__ |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=pod |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Catmandu::Importer::Mock - Mock importer used for testing purposes |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use Catmandu; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $importer = Catmandu->importer('Mock'); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $n = $importer->each(sub { |
40
|
|
|
|
|
|
|
my $hashref = $_[0]; |
41
|
|
|
|
|
|
|
# ... |
42
|
|
|
|
|
|
|
}); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 CONFIGURATION |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item file |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Read input from a local file given by its path. Alternatively a scalar |
51
|
|
|
|
|
|
|
reference can be passed to read from a string. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item fh |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Read input from an L<IO::Handle>. If not specified, L<Catmandu::Util::io> is used to |
56
|
|
|
|
|
|
|
create the input stream from the C<file> argument or by using STDIN. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item encoding |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Binmode of the input stream C<fh>. Set to C<:utf8> by default. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item fix |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
An ARRAY of one or more fixes or file scripts to be applied to imported items. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item size |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Number of items. If not set, an endless stream is imported. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=back |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 METHODS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Every L<Catmandu::Importer> is a L<Catmandu::Iterable> all its methods are |
75
|
|
|
|
|
|
|
inherited. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SEE ALSO |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
L<Catmandu::Exporter::Null> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |