Merge pull request #3089 from duckduckgo/mintsoft/MoonPhases
Moon Phases: Convert to structured answermaster
commit
c170b95b9e
|
@ -55,12 +55,15 @@ handle query_lc => sub {
|
|||
my $phaseUrl = $phase;
|
||||
$phaseUrl =~ s/\s+/+/g;
|
||||
|
||||
return "The current lunar phase is: $phase",
|
||||
structured_answer => {
|
||||
input => [],
|
||||
result => $phase,
|
||||
operation => 'Current lunar phase'
|
||||
};
|
||||
return "The current lunar phase is: $phase", structured_answer => {
|
||||
data => {
|
||||
title => $phase,
|
||||
subtitle => 'Current lunar phase'
|
||||
},
|
||||
templates => {
|
||||
group => 'text'
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -16,42 +16,25 @@ my $named = qr/(?:New|Full)$space_plus(?:Moon)/;
|
|||
my $phases = qr/$wax_wane|$quarter|$named/;
|
||||
|
||||
my $ascii_answer = re(qr/^The current lunar phase is: $phases$/);
|
||||
my $html_answer = re(qr%^The current lunar phase is: <a href="\?q=$phases">$phases</a>$%);
|
||||
|
||||
sub build_test {
|
||||
return test_zci($ascii_answer, structured_answer => {
|
||||
data => {
|
||||
title => re($phases),
|
||||
subtitle => 'Current lunar phase'
|
||||
},
|
||||
templates => {
|
||||
group => 'text'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw( DDG::Goodie::MoonPhases)],
|
||||
'moon phase' => test_zci(
|
||||
$ascii_answer,
|
||||
structured_answer => {
|
||||
input => [],
|
||||
operation => 'Current lunar phase',
|
||||
result => re($phases),
|
||||
}
|
||||
),
|
||||
'lunar phase' => test_zci(
|
||||
$ascii_answer,
|
||||
structured_answer => {
|
||||
input => [],
|
||||
operation => 'Current lunar phase',
|
||||
result => re($phases),
|
||||
}
|
||||
),
|
||||
'phase of the moon' => test_zci(
|
||||
$ascii_answer,
|
||||
structured_answer => {
|
||||
input => [],
|
||||
operation => 'Current lunar phase',
|
||||
result => re($phases),
|
||||
}
|
||||
),
|
||||
'what is the current lunar phase' => test_zci(
|
||||
$ascii_answer,
|
||||
structured_answer => {
|
||||
input => [],
|
||||
operation => 'Current lunar phase',
|
||||
result => re($phases),
|
||||
}
|
||||
),
|
||||
'moon phase' => build_test(),
|
||||
'lunar phase' => build_test(),
|
||||
'phase of the moon' => build_test(),
|
||||
'what is the current lunar phase' => build_test()
|
||||
);
|
||||
|
||||
done_testing;
|
||||
|
|
Loading…
Reference in New Issue