commit
d575057501
|
@ -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;
|
36
t/GUID.t
36
t/GUID.t
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue