Ascii plugin is ready to go

master
Josh Margolis 2012-03-30 12:30:25 -04:00
parent c13dc902b0
commit 5c70dc730f
2 changed files with 38 additions and 0 deletions

15
lib/DDG/Goodie/Ascii.pm Normal file
View File

@ -0,0 +1,15 @@
package DDG::Goodie::Ascii;
use DDG::Goodie;
zci answer_type => "ascii_conversion";
zci is_cached => 1;
triggers end => "ascii";
handle remainder => sub {
return pack("B*", $1) if /^(([0-1]{8})*)\s+(in|to)$/;
return;
}

23
t/Ascii.t Normal file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use DDG::Test::Goodie;
zci answer_type => 'ascii_conversion';
zci is_cached => 1;
ddg_goodie_test(
[qw(
DDG::Goodie::Ascii
)],
'01101010 to ascii' => test_zci('j'),
'00111001 to ascii' => test_zci('9'),
'01110100011010000110100101110011 in ascii' => test_zci('this'),
'01110100011010000110000101110100 to ascii' => test_zci('that'),
);
done_testing;