From f3409a40faee7576d14868621067fc3fc3561980 Mon Sep 17 00:00:00 2001 From: JoshuaRLi Date: Wed, 16 Mar 2016 17:58:22 +0000 Subject: [PATCH 1/5] added john cena --- lib/DDG/Goodie/JohnCena.pm | 44 ++++++++++++++++++++++++++++++++++++++ t/JohnCena.t | 26 ++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 lib/DDG/Goodie/JohnCena.pm create mode 100644 t/JohnCena.t diff --git a/lib/DDG/Goodie/JohnCena.pm b/lib/DDG/Goodie/JohnCena.pm new file mode 100644 index 00000000000..95bdf147985 --- /dev/null +++ b/lib/DDG/Goodie/JohnCena.pm @@ -0,0 +1,44 @@ +package DDG::Goodie::JohnCena; +# ABSTRACT: WHO IS CHAMP? A simple instant answer that informs people of who the champ really is. +# See https://duck.co/ia/view/john_cena + +use strict; +use DDG::Goodie; + +triggers start => + 'who is champ', + 'who\'s champ', + 'define champ', + 'who can\'t I see', + 'what is his name', + 'what\'s his name', + 'and his name is'; + +zci answer_type => 'john_cena'; +zci is_cached => 1; + +handle remainder => sub { + + return if $_; + + my $answer = 'JOHN CENA'; + + return $answer, + structured_answer => { + id => 'john_cena', + name => 'Answer', + data => { + title => $answer, + subtitle => 'YOUR TIME IS UP, MY TIME IS NOW' + }, + meta => { + sourceName => 'Wikipedia', + sourceUrl => 'https://en.wikipedia.org/wiki/John_Cena' + }, + templates => { + group => 'text' + } + }; +}; + +1; diff --git a/t/JohnCena.t b/t/JohnCena.t new file mode 100644 index 00000000000..76db506d3ba --- /dev/null +++ b/t/JohnCena.t @@ -0,0 +1,26 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Test::More; +use DDG::Test::Goodie; + +zci answer_type => "john_cena"; +zci is_cached => 1; + +ddg_goodie_test( + ['DDG::Goodie::JohnCena'], + + 'what is the answer to the ultimate question of life the universe and everything' => test_zci( + 'JOHN CENA', + structured_answer => { + input => [], + operation => 'YOUR TIME IS UP, MY TIME IS NOW', + result => 'JOHN CENA', + } + ), + 'who champ' => undef, + 'wrestler meme' => undef, +); + +done_testing; \ No newline at end of file From d21fe604487d79a9a5d2c3988a2c89dd38fda5e5 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Wed, 16 Mar 2016 14:09:39 -0400 Subject: [PATCH 2/5] Update JohnCena.t >_> rip in copypaste --- t/JohnCena.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/JohnCena.t b/t/JohnCena.t index 76db506d3ba..e2770123e5b 100644 --- a/t/JohnCena.t +++ b/t/JohnCena.t @@ -11,7 +11,7 @@ zci is_cached => 1; ddg_goodie_test( ['DDG::Goodie::JohnCena'], - 'what is the answer to the ultimate question of life the universe and everything' => test_zci( + 'who is champ' => test_zci( 'JOHN CENA', structured_answer => { input => [], @@ -23,4 +23,4 @@ ddg_goodie_test( 'wrestler meme' => undef, ); -done_testing; \ No newline at end of file +done_testing; From 28549c3a96de8768fae72b852d574d476f426174 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Wed, 16 Mar 2016 14:10:47 -0400 Subject: [PATCH 3/5] Update JohnCena.pm removed some bad triggers --- lib/DDG/Goodie/JohnCena.pm | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/DDG/Goodie/JohnCena.pm b/lib/DDG/Goodie/JohnCena.pm index 95bdf147985..037ca9b52a9 100644 --- a/lib/DDG/Goodie/JohnCena.pm +++ b/lib/DDG/Goodie/JohnCena.pm @@ -8,8 +8,6 @@ use DDG::Goodie; triggers start => 'who is champ', 'who\'s champ', - 'define champ', - 'who can\'t I see', 'what is his name', 'what\'s his name', 'and his name is'; From c51a6c1e2b68ae2129310da1058d071d2280c8a6 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 21 Mar 2016 20:15:21 -0400 Subject: [PATCH 4/5] Update JohnCena.pm Implemented GuiltyDolphin's suggestions and added some new start triggers. Thanks for the feedback! --- lib/DDG/Goodie/JohnCena.pm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/DDG/Goodie/JohnCena.pm b/lib/DDG/Goodie/JohnCena.pm index 037ca9b52a9..5e999e5d66a 100644 --- a/lib/DDG/Goodie/JohnCena.pm +++ b/lib/DDG/Goodie/JohnCena.pm @@ -6,11 +6,12 @@ use strict; use DDG::Goodie; triggers start => - 'who is champ', - 'who\'s champ', - 'what is his name', - 'what\'s his name', - 'and his name is'; + "who is champ", + "who's champ", + "wrestler meme", + "wwe meme", + "john cena", + "and his name is"; zci answer_type => 'john_cena'; zci is_cached => 1; @@ -36,7 +37,7 @@ handle remainder => sub { templates => { group => 'text' } - }; + }; }; 1; From 4d75f0b3cb51ac35dbb919295006d7a4ea67fe0b Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Mon, 21 Mar 2016 20:18:07 -0400 Subject: [PATCH 5/5] Update JohnCena.t Test file updated to match structured answer in .pm file. Thanks for bringing this to my attention, moollaza! --- t/JohnCena.t | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/t/JohnCena.t b/t/JohnCena.t index e2770123e5b..d49d8134d86 100644 --- a/t/JohnCena.t +++ b/t/JohnCena.t @@ -10,17 +10,26 @@ zci is_cached => 1; ddg_goodie_test( ['DDG::Goodie::JohnCena'], - 'who is champ' => test_zci( 'JOHN CENA', structured_answer => { - input => [], - operation => 'YOUR TIME IS UP, MY TIME IS NOW', - result => 'JOHN CENA', + id => 'john_cena', + name => 'Answer', + data => { + title => 'JOHN CENA', + subtitle => 'YOUR TIME IS UP, MY TIME IS NOW' + }, + meta => { + sourceName => 'Wikipedia', + sourceUrl => 'https://en.wikipedia.org/wiki/John_Cena' + }, + templates => { + group => 'text' + } } ), 'who champ' => undef, - 'wrestler meme' => undef, + 'famous wrestler' => undef, ); done_testing;