Merge pull request #292 from loganom/issue32

Issue32
master
Jag Talon 2014-01-22 10:13:30 -08:00
commit d575057501
2 changed files with 37 additions and 13 deletions

View File

@ -15,7 +15,9 @@ code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DD
category 'computing_tools';
topics 'programming';
attribution twitter => 'crazedpsyc',
cpan => 'CRZEDPSYC' ;
cpan => 'CRZEDPSYC' ,
twitter => 'loganmccamon',
github => 'loganom';
my %guid = (
'guid' => 0,
@ -30,12 +32,12 @@ handle query_lc => sub {
if (my $guid = Data::GUID->new) {
if ($guid{$_}) {
$guid = lc $guid;
} else {
$guid = qq({$guid});
}
$guid .= ' (randomly generated)';
return $guid;
return answer => qq($guid),
html => qq(<input type="text" onclick='this.select();' size="45" value="$guid"/>),
heading => 'Random GUID';
}
return;
};
1;
1;

View File

@ -8,14 +8,36 @@ use DDG::Test::Goodie;
zci answer_type => 'guid';
zci is_cached => 0;
my $heading = 'Random GUID';
ddg_goodie_test(
[qw(
DDG::Goodie::GUID
)],
'guid' => test_zci(qr/ \(randomly generated\)$/),
'uuid' => test_zci(qr/ \(randomly generated\)$/),
'globally unique identifier' => test_zci(qr/ \(randomly generated\)$/),
'rfc 4122' => test_zci(qr/ \(randomly generated\)$/),
[qw(
DDG::Goodie::GUID
)],
# Check that the trigger kicks in.
'guid' => test_zci(qr/^([a-zA-Z]|\d){8}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){12}$/,
html => qr/./,
heading => $heading
),
'uuid' => test_zci(qr/^([a-zA-Z]|\d){8}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){12}$/,
html => qr/./,
heading => $heading
),
'globally unique identifier' => test_zci(qr/^([a-zA-Z]|\d){8}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){12}$/,
html => qr/./,
heading => $heading
),
'rfc 4122' => test_zci(qr/^([a-zA-Z]|\d){8}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){12}$/,
html => qr/./,
heading => $heading
),
# Check the HTML. Just once.
'guid' => test_zci(qr/^([a-zA-Z]|\d){8}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){12}$/,
html => qr/^<input type="text" onclick='this.select\(\);' size="45" value="([a-zA-Z]|\d){8}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){4}-([a-zA-Z]|\d){12}"\/>$/,
heading => $heading
),
);
done_testing;