Skip to content
Browse files

add attributions

  • Loading branch information...
1 parent 830c780 commit 3d56404bf55eb67129ea9004c7a0d9b28e451cfa @crazedpsyc crazedpsyc committed
Showing with 33 additions and 0 deletions.
  1. +5 −0 lib/DDG/Goodie/HTMLEntities.pm
  2. +7 −0 lib/DDG/Goodie/Spell.pm
  3. +21 −0 t/Spell.t
View
5 lib/DDG/Goodie/HTMLEntities.pm
@@ -11,6 +11,11 @@ zci is_cached => 1;
triggers query_nowhitespace => qr/^(?:html|entity|htmlentity)?(&#?\w+;?)$/i;
+attribution
+ twitter => 'crazedpsyc',
+ cpan => 'CRZEDPSYC'
+;
+
handle matches => sub {
my $entity = $_[0];
$entity =~ s/;?$/;/; # append a semicolon (some entities like &mdash do not work without one)
View
7 lib/DDG/Goodie/Spell.pm
@@ -5,10 +5,17 @@ use Text::Aspell;
triggers start => "spell", "how to spell", "how do i spell", "spellcheck";
+zci is_cached => 1;
+
my $speller = Text::Aspell->new;
$speller->set_option('lang','en_US');
$speller->set_option('sug-mode','fast');
+attribution
+ twitter => 'crazedpsyc',
+ cpan => 'CRZEDPSYC'
+;
+
handle remainder => sub {
return unless /^[\w']+$/; # only accept letters and ' (aspell handles contractions)
my $correct = $speller->check($_) ? "'\u$_' appears to be spelled right!" : "'\u$_' does not appear to be spelled correctly.";
View
21 t/Spell.t
@@ -0,0 +1,21 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More;
+use DDG::Test::Goodie;
+
+zci answer_type => 'spell';
+zci is_cached => 1;
+
+ddg_goodie_test(
+ [qw(
+ DDG::Goodie::Spell
+ )],
+ 'spell foo' => test_zci("'Foo' appears to be spelled right! Suggestions: foo, FPO, food, fool, foot, fop", html => "'Foo' appears to be spelled right!<br/>Suggestions: foo, FPO, food, fool, foot, fop"),
+ 'how do I spell foo' => test_zci("'Foo' appears to be spelled right! Suggestions: foo, FPO, food, fool, foot, fop", html => "'Foo' appears to be spelled right!<br/>Suggestions: foo, FPO, food, fool, foot, fop"),
+ 'spellcheck hllo' => test_zci("'Hllo' does not appear to be spelled correctly. Suggestions: hello, halo, halloo, hallow, hollow, Hall", html => "'Hllo' does not appear to be spelled correctly.<br/>Suggestions: hello, halo, halloo, hallow, hollow, Hall"),
+);
+
+done_testing;
+

0 comments on commit 3d56404

Please sign in to comment.
Something went wrong with that request. Please try again.