File Coverage

blib/lib/Data/Record/Serialize/Sink/array.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 2 0.0
total 23 25 92.0


line stmt bran cond sub pod time code
1             package Data::Record::Serialize::Sink::array;
2              
3             # ABSTRACT: append encoded data to an array.
4              
5 2     2   1289 use v5.12;
  2         8  
6 2     2   12 use Moo::Role;
  2         6  
  2         18  
7              
8 2     2   926 use Data::Record::Serialize::Error { errors => ['::create'] }, -all;
  2         7  
  2         33  
9              
10             our $VERSION = '1.05';
11              
12 2     2   1314 use IO::File;
  2         4130  
  2         285  
13              
14 2     2   16 use namespace::clean;
  2         6  
  2         19  
15              
16              
17              
18              
19              
20              
21              
22              
23              
24              
25              
26             has output => (
27             is => 'ro',
28             clearer => 1,
29             default => sub { [] },
30             );
31              
32              
33              
34              
35              
36              
37              
38              
39 4     4 0 41 sub print { push @{ shift->{output} }, @_ }
  4         22  
40             *say = \&print;
41       2 0   sub close { }
42              
43             with 'Data::Record::Serialize::Role::Sink';
44              
45             1;
46              
47             #
48             # This file is part of Data-Record-Serialize
49             #
50             # This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory.
51             #
52             # This is free software, licensed under:
53             #
54             # The GNU General Public License, Version 3, June 2007
55             #
56              
57             __END__
58              
59             =pod
60              
61             =for :stopwords Diab Jerius Smithsonian Astrophysical Observatory
62              
63             =head1 NAME
64              
65             Data::Record::Serialize::Sink::array - append encoded data to an array.
66              
67             =head1 VERSION
68              
69             version 1.05
70              
71             =head1 SYNOPSIS
72              
73             use Data::Record::Serialize;
74              
75             my $s = Data::Record::Serialize->new( sink => 'array', ?(output => \@output), ... );
76              
77             $s->send( \%record );
78              
79             # last encoded record is here
80             $encoded = $s->output->[-1];
81              
82             =head1 DESCRIPTION
83              
84             B<Data::Record::Serialize::Sink::sink> appends encoded data to an array.
85              
86             It performs the L<Data::Record::Serialize::Role::Sink> role.
87              
88             =head1 OBJECT ATTRIBUTES
89              
90             =head2 output
91              
92             $array = $s->output;
93              
94             The array into which the encoded record is stored. The last record sent is at
95              
96             $s->output->[-1]
97              
98             =head1 INTERNALS
99              
100             =for Pod::Coverage print
101             say
102             close
103              
104             =head1 CONSTRUCTOR OPTIONS
105              
106             =over
107              
108             =item output => I<arrayref>
109              
110             Optional. Where to write the data. An arrayref is provided if not specified.
111              
112             =back
113              
114             =head1 SUPPORT
115              
116             =head2 Bugs
117              
118             Please report any bugs or feature requests to bug-data-record-serialize@rt.cpan.org or through the web interface at: L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Record-Serialize>
119              
120             =head2 Source
121              
122             Source is available at
123              
124             https://gitlab.com/djerius/data-record-serialize
125              
126             and may be cloned from
127              
128             https://gitlab.com/djerius/data-record-serialize.git
129              
130             =head1 SEE ALSO
131              
132             Please see those modules/websites for more information related to this module.
133              
134             =over 4
135              
136             =item *
137              
138             L<Data::Record::Serialize|Data::Record::Serialize>
139              
140             =back
141              
142             =head1 AUTHOR
143              
144             Diab Jerius <djerius@cpan.org>
145              
146             =head1 COPYRIGHT AND LICENSE
147              
148             This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory.
149              
150             This is free software, licensed under:
151              
152             The GNU General Public License, Version 3, June 2007
153              
154             =cut