diff --git a/dist.ini b/dist.ini index 7686d585f..08e1d680c 100644 --- a/dist.ini +++ b/dist.ini @@ -24,6 +24,9 @@ Locale::SubCountry = 1.47 Unicode::Char = 0.02 Number::UN = 0.002 Locale::Language = 3.21 +Gravatar::URL = 1.06 +CGI = 3.60 +Email::Valid = 0.190 ; ParseCron Schedule::Cron::Events = 0 Convert::Color = 0.08 diff --git a/lib/DDG/Goodie/Unicornify.pm b/lib/DDG/Goodie/Unicornify.pm new file mode 100644 index 000000000..a2e1b062b --- /dev/null +++ b/lib/DDG/Goodie/Unicornify.pm @@ -0,0 +1,27 @@ +package DDG::Goodie::Unicornify; +# ABSTRACT: Return Gravatar image given an email address + +use DDG::Goodie; +use CGI qw/img/; +use Email::Valid; +use Unicornify::URL; + +triggers start => 'unicornify'; + + +handle remainder => sub { + my $link = 'http://unicornify.appspot.com/'; + if (Email::Valid->address($_)) { + s/[\s\t]+//g; # strip whitespace from the remainder, we just need the email address. + return $_ . '\'s unicorn:', + html => $_ . '\'s unicorn (Learn more at unicornify.appspot.com):' + .'
' + .''; + } + return; +}; + +zci is_cached => 1; + +1; + diff --git a/t/Gravatar.t b/t/Gravatar.t new file mode 100644 index 000000000..fe4fb9be1 --- /dev/null +++ b/t/Gravatar.t @@ -0,0 +1,17 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Test::More; +use DDG::Test::Goodie; + +zci answer_type => 'gravatar'; +zci is_cached => 1; +ddg_goodie_test( + [qw( + DDG::Goodie::Gravatar + )], + 'gravatar kumimoko.yo@gmail.com' => test_zci(''), +); + +done_testing; diff --git a/t/Unicornify.t b/t/Unicornify.t new file mode 100644 index 000000000..2438b6243 --- /dev/null +++ b/t/Unicornify.t @@ -0,0 +1,22 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Test::More; +use DDG::Test::Goodie; +use Unicornify::URL; + + +zci answer_type => 'unicornify'; +zci is_cached => 1; +ddg_goodie_test( + [qw( + DDG::Goodie::Unicornify + )], + 'unicornify bob@bob.com' => + test_zci('bob@bob.com\'s unicorn:', + html => 'bob@bob.com\'s unicorn (Learn more at unicornify.appspot.com):
' + .'' + .'')); + +done_testing;