line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Exporter::Mock; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
105802
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
17
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
16
|
use Moo; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
14
|
|
8
|
2
|
|
|
2
|
|
863
|
use namespace::clean; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
16
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Catmandu::Exporter'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has _data_ => (is => 'ro', default => sub {[]}); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub add { |
15
|
|
|
|
|
|
|
my ($self, $data) = @_; |
16
|
|
|
|
|
|
|
push @{$self->_data_}, $data; |
17
|
|
|
|
|
|
|
1; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub as_arrayref { |
21
|
2
|
|
|
2
|
0
|
1451
|
my ($self) = @_; |
22
|
2
|
|
|
|
|
26
|
return $self->_data_; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__END__ |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=pod |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 NAME |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Catmandu::Exporter::Mock - a exporter that doesn't export anything |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# From the commandline |
38
|
|
|
|
|
|
|
$ catmandu convert JSON --fix myfixes to Mock < /tmp/data.json |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# From Perl |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
use Catmandu; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Print to STDOUT |
45
|
|
|
|
|
|
|
my $exporter = Catmandu->exporter('Mock',fix => 'myfix.txt'); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$exporter->add_many($arrayref); |
48
|
|
|
|
|
|
|
$exporter->add_many($iterator); |
49
|
|
|
|
|
|
|
$exporter->add_many(sub { }); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$exporter->add($hashref); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
printf "exported %d items\n" , $exporter->count; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Get an array ref of all records exported |
56
|
|
|
|
|
|
|
my $data = $exporter->as_arrayref; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This exporter exports nothing and can be used as in situations where you e.g. export |
61
|
|
|
|
|
|
|
data from a fix. Other the Null exporter, the Mock exporter will keep an internal |
62
|
|
|
|
|
|
|
array of all the records exported which can be retrieved with the 'as_arrayref' method. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SEE ALSO |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
L<Catmandu::Exporter::Null> |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |