Slackget/Network/Backend/Gzip.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 62 CC 7 SCAR 22.9
CC
7
Cov
0%
backend_decode
20.0
backend_encode
12.0
new
6.0
CRAP 9.9
1 package Slackware::Slackget::Network::Backend::Gzip;
2  
3 use warnings;
4 use strict;
5 require Slackware::Slackget::Network::Message ;
6 require Compress::Zlib ;
7 require IO::Uncompress::Gunzip;
8  
9 =head1 NAME
10  
11 Slackware::Slackget::Network::Backend::Gzip - Gzip (Zlib) backend for slack-get network protocol
12  
13 =head1 VERSION
14  
15 Version 0.8.0
16  
17 =cut
18  
19 our $VERSION = '0.8.1';
20  
21 =head1 SYNOPSIS
22  
23 Still to do
24  
25 =cut
26  
27 sub new
28 {
29 my ($class,%args) = @_ ;
30 my $self = {%args};
31 bless($self,$class);
32 print "[Slackware::Slackget::Network::Backend::Gzip] constructing a new object (version: $VERSION).\n" if($ENV{SG_DAEMON_DEBUG}) ;
33 return $self;
34 }
35  
36 =head1 CONSTRUCTOR
37  
38 =head2 new
39  
40 Still to do
41  
42 =head1 FUNCTIONS
43  
44 All methods return a Slackware::Slackget::Network::Message (L<Slackware::Slackget::Network::Message>) object, and if the remote slack-getd return some data they are accessibles via the data() accessor of the Slackware::Slackget::Network::Message object.
45  
46 =cut
47  
48 =head2 backend_decode
49  
50 =cut
51  
52 sub backend_decode {
53 my $self = shift;
54 my $Gzip_msg = shift;
55 print "[Slackware::Slackget::Network::Backend::Gzip] call backend_decode($Gzip_msg).\n" if($ENV{SG_DAEMON_DEBUG}) ;
56 my $raw = $Gzip_msg->data();
57 print "[Slackware::Slackget::Network::Backend::Gzip] raw data are : \n$raw.\n" if($ENV{SG_DAEMON_DEBUG}) ;
58 my $raw_bis = $raw;
59 print Compress::Zlib::memGunzip( $raw_bis );
60 my $data = Compress::Zlib::memGunzip( $raw );
61 print "[Slackware::Slackget::Network::Backend::Gzip] decoded data are :\n".$data."\n" if($ENV{SG_DAEMON_DEBUG}) ;
62 return Slackware::Slackget::Network::Message->new(raw_data => $data);
63 }
64  
65 =head2 backend_encode
66  
67 =cut
68  
69 sub backend_encode {
70 my $self = shift;
71 my $message = shift ;
72 print "[Slackware::Slackget::Network::Backend::Gzip] call backend_encode($message).\n" if($ENV{SG_DAEMON_DEBUG}) ;
73 my $raw = $message->data();
74 # my $Gzip = `gzip -c < $raw`;
75 my $Gzip = Compress::Zlib::memGzip( $raw ) ;
76 print "[Slackware::Slackget::Network::Backend::Gzip] encoded Gzip:\n$Gzip\n" if($ENV{SG_DAEMON_DEBUG});
77 return Slackware::Slackget::Network::Message->new(
78 action => $message->action,
79 action_id => $message->{action_id},
80 raw_data => $Gzip,
81 );
82 }
83  
84  
85  
86 =head1 AUTHOR
87  
88 DUPUIS Arnaud, C<< <a.dupuis@infinityperl.org> >>
89  
90 =head1 BUGS
91  
92 Please report any bugs or feature requests to
93 C<bug-Slackware-Slackget@rt.cpan.org>, or through the web interface at
94 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Slackware-Slackget>.
95 I will be notified, and then you'll automatically be notified of progress on
96 your bug as I make changes.
97  
98 =head1 SUPPORT
99  
100 You can find documentation for this module with the perldoc command.
101  
102 perldoc Slackware::Slackget
103  
104  
105 You can also look for information at:
106  
107 =over 4
108  
109 =item * Infinity Perl website
110  
111 L<http://www.infinityperl.org/category/slack-get>
112  
113 =item * slack-get specific website
114  
115 L<http://slackget.infinityperl.org>
116  
117 =item * RT: CPAN's request tracker
118  
119 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Slackware-Slackget>
120  
121 =item * AnnoCPAN: Annotated CPAN documentation
122  
123 L<http://annocpan.org/dist/Slackware-Slackget>
124  
125 =item * CPAN Ratings
126  
127 L<http://cpanratings.perl.org/d/Slackware-Slackget>
128  
129 =item * Search CPAN
130  
131 L<http://search.cpan.org/dist/Slackware-Slackget>
132  
133 =back
134  
135 =head1 ACKNOWLEDGEMENTS
136  
137 Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation.
138  
139 =head1 SEE ALSO
140  
141 L<Slackware::Slackget::Network::Message>, L<Slackware::Slackget::Status>, L<Slackware::Slackget::Network::Connection>
142  
143 =head1 COPYRIGHT & LICENSE
144  
145 Copyright 2005 DUPUIS Arnaud, All Rights Reserved.
146  
147 This program is free software; you can redistribute it and/or modify it
148 under the same terms as Perl itself.
149  
150 =cut
151  
152 1; # End of Slackware::Slackget::Network::Backend::Gzip