Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed pure Perl 6 version of MIME::Base64

Perl 6 version removed, i.e. MIME::Base64::Perl, as was experimental
and poorly implemented. We need to wait until we have pack/unpack
in the Perl 6 core before providing this module.
  • Loading branch information...
commit aabb5b1ca4001ca1bc185dc014872a65a653c0c5 1 parent 085e8b4
@snarkyboojum snarkyboojum authored
Showing with 4 additions and 68 deletions.
  1. +4 −10 README
  2. +0 −40 lib/MIME/Base64/Perl.pm6
  3. +0 −18 t/perl.t
View
14 README
@@ -1,26 +1,20 @@
NAME
-MIME::Base64 - A Perl6 implementation of MIME::Base64 and friends
+MIME::Base64 - A Perl6 implementation of MIME::Base64
DESCRIPTION
-Two libraries are available:
+A single module is available:
MIME::Base64
Implements encoding and decoding to and from base64 using an underlying
parrot library. This is a relatively fast implementation.
- MIME::Base64::Perl
-
- A horribly inefficient work in progress for doing the same thing as
- MIME::Base64 in pure Perl 6 (what's currently available in Rakudo anyway).
-
STATUS
-The Perl 6 version of MIME::Base64 is an experiment in Perl 6 and will
-be replaced by a correct version when pack/unpack is available in the
-Perl 6 core.
+A pure Perl 6 version of MIME::Base64 will be included pack/unpack is available
+in the Perl 6 core.
LICENSE and COPYRIGHT
View
40 lib/MIME/Base64/Perl.pm6
@@ -1,40 +0,0 @@
-class MIME::Base64::Perl {
-
- method encode_base64(Str $str) {
- return '' if $str eq '';
-
- # this should be stored at the class level
- my @table = 'A'..'Z','a'..'z',0..9,'+','/';
-
- # 6 bit packs padded with 0s at the LSB
- my $bit-string = $str.comb(/./)>>.ord>>.fmt('%08b').join();
- my $bit-padding = $bit-string.chars % 6;
- if $bit-padding != 0 {
- $bit-string ~= '0' x (6 - $bit-padding);
- }
-
- my @packs = $bit-string.comb(/....../);
-
- # build corresponding base64 characters from 6 bit packs
- my $output;
- for @packs -> $p {
- my @binary = $p.comb(/./);
- my @bases = 2 X** ((^$p.chars).reverse);
- my $index = ( [+] (@binary >>*<< @bases) );
- $output ~= @table[$index];
- }
-
- # pad with = chars if needed
- my $padding = $output.chars % 4;
- if $padding != 0 {
- $output ~= '=' x (4 - $padding);
- }
-
- return $output;
- }
-
- method decode_base64(Str $str) {
- die "Not yet implemented";
- }
-
-}
View
18 t/perl.t
@@ -1,18 +0,0 @@
-use v6;
-
-use Test;
-use MIME::Base64::Perl;
-
-plan 9;
-
-my MIME::Base64::Perl $mime .= new;
-
-is $mime.encode_base64(""), '', 'Encoding the empty string';
-is $mime.encode_base64("A"), 'QQ==', 'Encoding "A"';
-is $mime.encode_base64("Ab"), 'QWI=', 'Encoding "Ab"';
-is $mime.encode_base64("Abc"), 'QWJj', 'Encoding "Abc"';
-is $mime.encode_base64("Abcd"), 'QWJjZA==', 'Encoding "Abcd"';
-is $mime.encode_base64("Perl"), 'UGVybA==', 'Encoding "Perl"';
-is $mime.encode_base64("Perl6"), 'UGVybDY=', 'Encoding "Perl6"';
-is $mime.encode_base64("Another test!"), 'QW5vdGhlciB0ZXN0IQ==', '"Encoding "Another test!"';
-is $mime.encode_base64("username:thisisnotmypassword"), 'dXNlcm5hbWU6dGhpc2lzbm90bXlwYXNzd29yZA==', 'Encoding "username:thisisnotmypassword"';
Please sign in to comment.
Something went wrong with that request. Please try again.