| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
79810
|
use strict; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
118
|
|
|
2
|
2
|
|
|
2
|
|
15
|
use warnings; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
203
|
|
|
3
|
|
|
|
|
|
|
package Dancer::Serializer::UUEncode; |
|
4
|
|
|
|
|
|
|
BEGIN { |
|
5
|
2
|
|
|
2
|
|
47
|
$Dancer::Serializer::UUEncode::VERSION = '0.02'; |
|
6
|
|
|
|
|
|
|
} |
|
7
|
|
|
|
|
|
|
# ABSTRACT: UU Encoding serializer for Dancer |
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
16
|
use Carp; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
231
|
|
|
10
|
2
|
|
|
2
|
|
16
|
use base 'Dancer::Serializer::Abstract'; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
7653
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub init { |
|
13
|
|
|
|
|
|
|
my ($self) = @_; |
|
14
|
|
|
|
|
|
|
$self->loaded; |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub loaded { |
|
18
|
|
|
|
|
|
|
require Storable; |
|
19
|
|
|
|
|
|
|
Storable->import( qw/ nfreeze thaw / ); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub serialize { |
|
23
|
|
|
|
|
|
|
my ( $self, $entity ) = @_; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return pack( 'u', nfreeze($entity) ); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub deserialize { |
|
29
|
|
|
|
|
|
|
my ( $self, $content ) = @_; |
|
30
|
|
|
|
|
|
|
my $data = thaw( unpack( 'u', $content ) ); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
defined $data or croak "Couldn't thaw unpacked content '$content'"; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
return $data; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub content_type {'text/uuencode'} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# helpers |
|
40
|
|
|
|
|
|
|
sub from_uuencode { |
|
41
|
|
|
|
|
|
|
my ($uuencode) = @_; |
|
42
|
|
|
|
|
|
|
my $s = Dancer::Serializer::UUEncode->new; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return $s->deserialize($uuencode); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub to_uuencode { |
|
48
|
|
|
|
|
|
|
my ($data) = @_; |
|
49
|
|
|
|
|
|
|
my $s = Dancer::Serializer::UUEncode->new; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return $s->serialize($data); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=pod |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 NAME |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Dancer::Serializer::UUEncode - UU Encoding serializer for Dancer |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 VERSION |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
version 0.02 |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# in your Dancer app: |
|
71
|
|
|
|
|
|
|
setting serializer => 'UUEncode'; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# or in your Dancer config file: |
|
74
|
|
|
|
|
|
|
serializer: 'UUEncode' |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This serializer serializes your data structure to UU Encoding. Since UU Encoding |
|
79
|
|
|
|
|
|
|
is just encoding and not a serialization format, it first freezes it using |
|
80
|
|
|
|
|
|
|
L and only then serializes it. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
It uses L's C and C functions. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 init |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
An initializer that is called automatically by Dancer. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Runs C. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 loaded |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Lazily loads Storable and imports the appropriate functions. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 serialize |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Serializes a given data to UU encoding after freezing it with L. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 deserialize |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Deserializes a given data from UU encoding after thawing it with L. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 from_uuencode |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Helper function to create a new L object and run |
|
107
|
|
|
|
|
|
|
C. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 to_uuencode |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Helper function to create a new L object and run |
|
112
|
|
|
|
|
|
|
C. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 content_type |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Returns the content type of UU encode which is B. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
The Dancer Advent Calendar 2010. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHOR |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Sawyer X |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Sawyer X. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
131
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
__END__ |