| 1 | package Catmandu::Importer::Mock; | ||
| 2 | |||
| 3 | 15 | ▶ | use Catmandu::Sane; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 10 | our $VERSION = '1.0201_02'; | |
| 6 | |||
| 7 | 15 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 15 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 10 | with 'Catmandu::Importer'; | |
| 11 | |||
| 12 | 10 | has size => (is => 'ro'); | |
| 13 | |||
| 14 | sub generator { | ||
| 15 | 9 | ▶ | my ($self) = @_; |
|
Subroutine
generator: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 16 | 9 | my $n = 0; | |
| 17 | sub { | ||
| 18 | return if defined $self->size && $n == $self->size; | ||
| 19 | return {n => $n++}; | ||
| 20 | 9 | }; | |
| 21 | } | ||
| 22 | |||
| 23 | 10 | 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::Importer::Mock; | ||
| 36 | |||
| 37 | my $importer = Catmandu::Importer::Mock->new(); | ||
| 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 | ||