String/Base64.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« String/Ascii.pm ↑ Summary String/Compress.pm »
1 #
2 # $Id$
3 #
4 # string::base64 Brik
5 #
6 package Metabrik::String::Base64;
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use base qw(Metabrik);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub brik_properties {
13 return {
14 revision => '$Revision$',
15 tags => [ qw(unstable encode decode) ],
16 author => 'GomoR <GomoR[at]metabrik.org>',
17 license => 'http://opensource.org/licenses/BSD-3-Clause',
18 commands => {
19 encode => [ qw($data) ],
20 decode => [ qw($data) ],
21 },
22 require_modules => {
23 'MIME::Base64' => [ ],
24 },
25 };
26 }
27  
28 sub encode {
29 my $self = shift;
30 my ($data) = @_;
31  
32 $self->brik_help_run_undef_arg('encode', $data) or return;
33  
34 my $encoded = MIME::Base64::encode_base64($data, '');
35 chomp($encoded);
36  
37 return $encoded;
38 }
39  
40 sub decode {
41 my $self = shift;
42 my ($data) = @_;
43  
44 $self->brik_help_run_undef_arg('decode', $data) or return;
45  
46 my $decoded = MIME::Base64::decode_base64($data);
47 chomp($decoded);
48  
49 return $decoded;
50 }
51  
52 1;
53  
54 __END__
« String/Ascii.pm ↑ Summary String/Compress.pm »