File Coverage

blib/lib/Data/Record/Serialize/Encode/csv.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 14 15 93.3


line stmt bran cond sub pod time code
1              
2             # ABSTRACT: encode a record as csv
3              
4             use Moo::Role;
5 1     1   272185  
  1         3  
  1         7  
6             use namespace::clean;
7 1     1   389  
  1         3  
  1         11  
8             our $VERSION = '0.02';
9              
10             with 'Data::Record::Serialize::Role::Encode::CSV';
11              
12             my $self = shift;
13             $self->_csv->combine( @{ $_[0] }{ @{ $self->output_fields } } );
14 3     3 0 28 $self->_csv->string;
15 3         43 }
  3         29  
  3         53  
16 3         85  
17              
18              
19              
20              
21              
22             with 'Data::Record::Serialize::Role::Encode';
23              
24             1;
25              
26             #
27             # This file is part of Data-Record-Serialize-Encode-csv
28             #
29             # This software is Copyright (c) 2022 by Smithsonian Astrophysical Observatory.
30             #
31             # This is free software, licensed under:
32             #
33             # The GNU General Public License, Version 3, June 2007
34             #
35              
36              
37             =pod
38              
39             =for :stopwords Diab Jerius Smithsonian Astrophysical Observatory
40              
41             =head1 NAME
42              
43             Data::Record::Serialize::Encode::csv - encode a record as csv
44              
45             =head1 VERSION
46              
47             version 0.02
48              
49             =head1 SYNOPSIS
50              
51             use Data::Record::Serialize;
52              
53             my $s = Data::Record::Serialize->new( encode => 'csv', ... );
54              
55             $s->send( \%record );
56              
57             =head1 DESCRIPTION
58              
59             B<Data::Record::Serialize::Encode::csv> encodes a record as CSV (well
60             anything that L<Text::CSV> can write).
61              
62             It performs the L<Data::Record::Serialize::Role::Encode> role. If the data sink
63             is a stream, try L<Data::Record::Serialize::Encode::csv_stream|csv_stream>; it
64             provides better performance using L<Text::CSV>'s native output to filehandles.
65              
66             =for Pod::Coverage encode
67              
68             =head1 CONSTRUCTOR OPTIONS
69              
70             =head2 Text::CSV Options
71              
72             Please see L<Data::Record::Serialize::Role::Encode::CSV>.
73              
74             =head1 SUPPORT
75              
76             =head2 Bugs
77              
78             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
79              
80             =head2 Source
81              
82             Source is available at
83              
84             https://gitlab.com/djerius/data-record-serialize-encode-csv
85              
86             and may be cloned from
87              
88             https://gitlab.com/djerius/data-record-serialize-encode-csv.git
89              
90             =head1 AUTHOR
91              
92             Diab Jerius <djerius@cpan.org>
93              
94             =head1 COPYRIGHT AND LICENSE
95              
96             This software is Copyright (c) 2022 by Smithsonian Astrophysical Observatory.
97              
98             This is free software, licensed under:
99              
100             The GNU General Public License, Version 3, June 2007
101              
102             =cut