blib/lib/Penguin/Easy.pm untested

filter: Statementstmt 0.0% 0 / 47 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 70 CC 2 SCAR 10.0
CC
2
Cov
0%
run
6.0
new
2.0
BEGIN
2.0
CRAP 2.7
1 =head1 NAME
2  
3 Penguin::Easy -- provides easy access to Penguin module.
4  
5  
6 =head1 SYNOPSIS
7  
8 use Penguin::Easy;
9 my $ep = new Penguin::Easy Title => 'Easy Program',
10 Name => 'James Duncan',
11 Sig => $my_pgp_sig,
12 Code => $my_perl_code;
13 $results = $ep->run;
14 print "$results\n";
15  
16  
17 =head1 DESCRIPTION
18  
19 C<Penguin::Easy> is an OO module, that provides quick-and-dirty access to the
20 penguin module for those not wanting to learn the nittygrittys about it. The
21 C<Easy> module provides transparent access to the C<Penguin> module, even to
22 the extent of deciding whether the Penguin code should be transparently wrapped,
23 or PGP wrapped (if you include a sig in the call to the C<new> method, it
24 will use PGP).
25  
26  
27 =head1 NOTES
28  
29 While writing this little module, I've decided that C<Wrapper> is perhaps one
30 of the funniest words I have ever seen. It has completly lost all meaning.
31  
32  
33 =cut
34  
35  
36 package Penguin::Easy;
37  
38 $VERSION = 1.1;
39  
40 use Penguin;
41 use Penguin::Rights;
42 use Penguin::Frame::Code;
43 use Penguin::Frame::Data;
44 use Penguin::Compartment;
45 use Penguin::Channel::TCP::Client;
46  
47  
48 sub new {
49 my ($class, %args) = @_;
50 my $self = {};
51 $self->{'Port'} = $args{'Port'} or 8118;
52 $self->{'Title'} = $args{'Title'} or 'Untitled Program';
53 $self->{'Name'} = $args{'Name'} or 'Just another Penguin';
54 $self->{'PGP'} = $args{'Sig'};
55 $self->{'Text'} = $args{'Code'};
56 bless $self, $class;
57 }
58  
59 sub run {
60 my ($self, %args) = @_;
61 my $channel = new Penguin::Channel::TCP::Client Peer => $args{'Host'},
62 Port => $self->{'Port'};
63 $channel->open();
64 my $frame = '';
65 my $wrapper = '';
66 if($self->{'PGP'}) {
67 use Penguin::Wrapper::PGP;
68 $wrapper = 'Penguin::Wrapper::PGP';
69 }
70 else {
71 use Penguin::Wrapper::Transparent;
72 $wrapper = 'Penguin::Wrapper::Transparent';
73 }
74 $frame = new Penguin::Frame::Code Wrapper => $wrapper;
75 assemble $frame Password => $self->{'PGP'},
76 Text => $self->{'Text'},
77 Title => $self->{'Title'},
78 Name => $self->{'Name'};
79 putframe $channel Frame => $frame;
80 my $outframe = getframe $channel;
81 $results = $outframe->disassemble(Password => $pgpsig);
82 return $results;
83 }
84  
85  
86 1;
87  
88  
89  
90  
91  
92  
93  
94  
95