line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Record::Serialize::Encode::ddump; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: encoded a record using Data::Dumper |
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
3634
|
use v5.12; |
|
6
|
|
|
|
|
26
|
|
6
|
6
|
|
|
6
|
|
40
|
use Moo::Role; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
53
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.05'; |
9
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
|
3002
|
use Scalar::Util; |
|
6
|
|
|
|
|
23
|
|
|
6
|
|
|
|
|
338
|
|
11
|
6
|
|
|
6
|
|
2070
|
use Data::Dumper; |
|
6
|
|
|
|
|
20612
|
|
|
6
|
|
|
|
|
497
|
|
12
|
6
|
|
|
6
|
|
51
|
use Data::Record::Serialize::Error { errors => ['::parameter'] }, -all; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
118
|
|
13
|
6
|
|
|
6
|
|
1135
|
use namespace::clean; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
70
|
|
14
|
|
|
|
|
|
|
|
15
|
28
|
|
|
28
|
|
190
|
sub _needs_eol { 1 } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has ddump => ( |
25
|
|
|
|
|
|
|
is => 'lazy', |
26
|
|
|
|
|
|
|
isa => sub { Scalar::Util::blessed $_[0] && $_[0]->isa( 'Data::Dumper' ) }, |
27
|
|
|
|
|
|
|
builder => sub { |
28
|
18
|
|
|
18
|
|
334
|
Data::Dumper->new( [] ); |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has dd_config => ( |
45
|
|
|
|
|
|
|
is => 'ro', |
46
|
|
|
|
|
|
|
isa => sub { |
47
|
|
|
|
|
|
|
ref $_[0] eq 'HASH' |
48
|
|
|
|
|
|
|
or error( '::parameter' => q{'config' parameter must be a hashref'} ); |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
default => sub { {} }, |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub encode { |
59
|
28
|
|
|
28
|
0
|
63
|
my $self = shift; |
60
|
28
|
|
|
|
|
487
|
$self->ddump->Values( \@_ )->Dump . q{,}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
around BUILD => sub { |
64
|
|
|
|
|
|
|
my ( $orig, $self ) = ( shift, shift ); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$orig->( $self, @_ ); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $ddump = $self->ddump; |
69
|
|
|
|
|
|
|
my %config = ( |
70
|
|
|
|
|
|
|
%{ $self->dd_config }, |
71
|
|
|
|
|
|
|
Terse => 1, |
72
|
|
|
|
|
|
|
Trailingcomma => 1, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
for my $mth ( keys %config ) { |
76
|
|
|
|
|
|
|
my $code = $ddump->can( $mth ) |
77
|
|
|
|
|
|
|
or error( '::parameter', "$mth is not a Data::Dumper configuration variable" ); |
78
|
|
|
|
|
|
|
$code->( $ddump, $config{$mth} ); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
return; |
81
|
|
|
|
|
|
|
}; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
with 'Data::Record::Serialize::Role::Encode'; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# |
95
|
|
|
|
|
|
|
# This file is part of Data-Record-Serialize |
96
|
|
|
|
|
|
|
# |
97
|
|
|
|
|
|
|
# This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory. |
98
|
|
|
|
|
|
|
# |
99
|
|
|
|
|
|
|
# This is free software, licensed under: |
100
|
|
|
|
|
|
|
# |
101
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
102
|
|
|
|
|
|
|
# |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=pod |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=for :stopwords Diab Jerius Smithsonian Astrophysical Observatory Trailingcomma |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 NAME |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Data::Record::Serialize::Encode::ddump - encoded a record using Data::Dumper |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 VERSION |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
version 1.05 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SYNOPSIS |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
use Data::Record::Serialize; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my $s = Data::Record::Serialize->new( encode => 'ddump', ... ); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$s->send( \%record ); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 DESCRIPTION |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
B<Data::Record::Serialize::Encode::ddump> encodes a record using |
129
|
|
|
|
|
|
|
L<Data::Dumper>. The resultant encoding may be decoded via |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
@data = eval $buf; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
It performs the L<Data::Record::Serialize::Role::Encode> role. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 OBJECT ATTRIBUTES |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 ddump |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
The L<Data::Dumper> object. It will be constructed if not provided to |
140
|
|
|
|
|
|
|
the constructor. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 dd_config |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Configuration data for the L<Data::Dumper> object stored in L</ddump>. |
145
|
|
|
|
|
|
|
Hash keys are the names of L<Data::Dumper> configuration variables, |
146
|
|
|
|
|
|
|
without the preceding C<Data::Dumper::> prefix. Be careful to ensure |
147
|
|
|
|
|
|
|
that the resultant output is a (comma separated) list of structures |
148
|
|
|
|
|
|
|
which can be C<eval>'ed. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
B<Terse> and B<Trailingcomma> are always set. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 CLASS METHODS |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 new |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This role adds two named arguments to the constructor, L</ddump> and |
157
|
|
|
|
|
|
|
L</config>, which mirror the added object attributes. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 INTERNALS |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=for Pod::Coverage encode |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 SUPPORT |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 Bugs |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
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> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 Source |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Source is available at |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
https://gitlab.com/djerius/data-record-serialize |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
and may be cloned from |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
https://gitlab.com/djerius/data-record-serialize.git |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 SEE ALSO |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Please see those modules/websites for more information related to this module. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=over 4 |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item * |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
L<Data::Record::Serialize|Data::Record::Serialize> |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=back |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 AUTHOR |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Diab Jerius <djerius@cpan.org> |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This is free software, licensed under: |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=cut |