File Coverage

blib/lib/Data/Record/Serialize/Encode/csv_stream.pm
Criterion Covered Total %
statement 10 10 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 13 14 92.8


line stmt bran cond sub pod time code
1              
2             # ABSTRACT: encode a record as csv
3              
4             use Moo::Role;
5 1     1   285379  
  1         3  
  1         7  
6             use namespace::clean;
7 1     1   435  
  1         2  
  1         8  
8             our $VERSION = '0.02';
9              
10              
11             my $self = shift;
12             $self->_csv->say( $self->fh, [ @{ $_[0] }{ @{ $self->output_fields } } ]);
13 3     3 0 2897 }
14 3         44  
  3         30  
  3         99  
15             with 'Data::Record::Serialize::Role::Encode::CSV';
16             with 'Data::Record::Serialize::Role::Sink::Stream';
17              
18              
19              
20              
21              
22              
23              
24             with 'Data::Record::Serialize::Role::EncodeAndSink';
25              
26             1;
27              
28             #
29             # This file is part of Data-Record-Serialize-Encode-csv
30             #
31             # This software is Copyright (c) 2022 by Smithsonian Astrophysical Observatory.
32             #
33             # This is free software, licensed under:
34             #
35             # The GNU General Public License, Version 3, June 2007
36             #
37              
38              
39             =pod
40              
41             =for :stopwords Diab Jerius Smithsonian Astrophysical Observatory
42              
43             =head1 NAME
44              
45             Data::Record::Serialize::Encode::csv_stream - encode a record as csv
46              
47             =head1 VERSION
48              
49             version 0.02
50              
51             =head1 SYNOPSIS
52              
53             use Data::Record::Serialize;
54              
55             my $s = Data::Record::Serialize->new( encode => 'csv_stream', ... );
56              
57             $s->send( \%record );
58              
59             =head1 DESCRIPTION
60              
61             B<Data::Record::Serialize::Encode::csv_stream> encodes a record as CSV (well
62             anything that L<Text::CSV> can write) and writes it to a stream.
63              
64             It performs both the L<Data::Record::Serialize::Role::Encode> and
65             L<Data::Record::Serialize::Role::Sink> roles.
66              
67             It is more efficient than coupling the L<Data::Record::Serialize::Encode::csv|csv>
68             encoder with the B<Data::Record::Serialize::Sink::stream|stream> sink.
69              
70             =for Pod::Coverage encode
71             send
72              
73             =head1 CONSTRUCTOR OPTIONS
74              
75             =head2 Text::CSV Options
76              
77             Please see L<Data::Record::Serialize::Role::Encode::CSV>.
78              
79             =head2 Stream Options
80              
81             Please see L<Data::Record::Serialize::Role::Sink::Stream>.
82              
83             =head1 SUPPORT
84              
85             =head2 Bugs
86              
87             Please report any bugs or feature requests to bug-data-record-serialize-encode-csv@rt.cpan.org or through the web interface at: https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Record-Serialize-Encode-csv
88              
89             =head2 Source
90              
91             Source is available at
92              
93             https://gitlab.com/djerius/data-record-serialize-encode-csv
94              
95             and may be cloned from
96              
97             https://gitlab.com/djerius/data-record-serialize-encode-csv.git
98              
99             =head1 SEE ALSO
100              
101             Please see those modules/websites for more information related to this module.
102              
103             =over 4
104              
105             =item *
106              
107             L<Data::Record::Serialize::Encode::csv|Data::Record::Serialize::Encode::csv>
108              
109             =back
110              
111             =head1 AUTHOR
112              
113             Diab Jerius <djerius@cpan.org>
114              
115             =head1 COPYRIGHT AND LICENSE
116              
117             This software is Copyright (c) 2022 by Smithsonian Astrophysical Observatory.
118              
119             This is free software, licensed under:
120              
121             The GNU General Public License, Version 3, June 2007
122              
123             =cut