1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
package Catmandu::Importer::Null;
use Catmandu::Sane;
our $VERSION = '1.2024';
use Moo;
use namespace::clean;
with 'Catmandu::Importer';
sub generator {
my ($self) = @_;
my $n = 0;
sub {
return undef if $n++;
+{};
};
}
1;
__END__
=pod
=head1 NAME
Catmandu::Importer::Null - Null importer used for testing purposes
=head1 SYNOPSIS
# From the command line
catmandu convert Null --fix 'add_field(foo,bar)'
# creates { "foo": "bar" }
# In a Perl script
use Catmandu;
my $importer = Catmandu->importer('Null');
my $n = $importer->each(sub {
my $hashref = $_[0];
# ...
});
=head1 DESCRIPTION
The importer generates one empty record and then exists. This importer can be used to
test fix functions, generating a single record.
=head1 METHODS
Every L<Catmandu::Importer> is a L<Catmandu::Iterable> all its methods are
inherited.
=head1 SEE ALSO
L<Catmandu::Exporter::Null>
=cut
|