| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# $Id: Count.pm,v 1.17 2010-12-02 23:45:57 Martin Exp $ |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
WWW::Search::Null::Count - class for testing WWW::Search clients |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use WWW::Search; |
|
11
|
|
|
|
|
|
|
my $iCount = 4; |
|
12
|
|
|
|
|
|
|
my $oSearch = new WWW::Search('Null::Count', |
|
13
|
|
|
|
|
|
|
'_null_count' => $iCount, |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
$oSearch->native_query('Makes no difference what you search for...'); |
|
16
|
|
|
|
|
|
|
my @aoResults = $oSearch->results; |
|
17
|
|
|
|
|
|
|
# ...You get $iCount results. |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This class is a specialization of WWW::Search that returns some hits, |
|
22
|
|
|
|
|
|
|
but no error message. The number of hits returned can be controlled |
|
23
|
|
|
|
|
|
|
by adding a '_null_count' hash entry onto the call to |
|
24
|
|
|
|
|
|
|
WWW::Search::new(). The default is 5. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This module might be useful for testing a client program without |
|
27
|
|
|
|
|
|
|
actually being connected to any particular search engine. |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 AUTHOR |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Martin 'Kingpin' Thurn, C, L. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
package WWW::Search::Null::Count; |
|
36
|
|
|
|
|
|
|
|
|
37
|
3
|
|
|
3
|
|
3274
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
101
|
|
|
38
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
87
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
3
|
|
|
3
|
|
28
|
use WWW::Search; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
113
|
|
|
41
|
3
|
|
|
3
|
|
433
|
use WWW::Search::Result; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
123
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
3
|
|
|
3
|
|
20
|
use base 'WWW::Search'; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
564
|
|
|
44
|
|
|
|
|
|
|
our |
|
45
|
|
|
|
|
|
|
$VERSION = do { my @r = (q$Revision: 1.17 $ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r }; |
|
46
|
|
|
|
|
|
|
our $MAINTAINER = q{Martin Thurn }; |
|
47
|
|
|
|
|
|
|
|
|
48
|
3
|
|
|
3
|
|
25
|
use constant DEBUG_FUNC => 0; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
1615
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _native_setup_search |
|
51
|
|
|
|
|
|
|
{ |
|
52
|
5
|
|
|
5
|
|
16
|
my ($self, $native_query, $native_opt) = @_; |
|
53
|
|
|
|
|
|
|
# print STDERR " FFF ::Null::Count::_native_setup_search()\n" if (DEBUG_FUNC || $self->{_debug}); |
|
54
|
5
|
100
|
|
|
|
17
|
if (! defined $self->{_null_count}) |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
|
|
|
|
|
|
# print STDERR " + setting default _null_count to 5\n"; |
|
57
|
1
|
|
|
|
|
3
|
$self->{_null_count} = 5; |
|
58
|
|
|
|
|
|
|
} # if |
|
59
|
5
|
|
|
|
|
15
|
$self->{_allow_empty_query} = 1; |
|
60
|
|
|
|
|
|
|
} # _native_setup_search |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _native_retrieve_some |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
3
|
|
|
3
|
|
5
|
my $self = shift; |
|
66
|
|
|
|
|
|
|
# print STDERR " FFF ::Null::Count::_n_r_s()\n" if (DEBUG_FUNC || $self->{_debug}); |
|
67
|
3
|
|
|
|
|
19
|
my $response = new HTTP::Response(200, |
|
68
|
|
|
|
|
|
|
"This is a test of WWW::Search"); |
|
69
|
3
|
|
|
|
|
199
|
$self->{response} = $response; |
|
70
|
3
|
|
|
|
|
7
|
my $iCount = $self->{_null_count}; |
|
71
|
|
|
|
|
|
|
# print STDERR " + iCount is $iCount\n"; |
|
72
|
3
|
|
|
|
|
23
|
$self->_elem('approx_count', $iCount); |
|
73
|
3
|
|
|
|
|
34
|
for my $i (1..$iCount) |
|
74
|
|
|
|
|
|
|
{ |
|
75
|
53
|
|
|
|
|
146
|
my $oResult = new WWW::Search::Result; |
|
76
|
53
|
|
|
|
|
179
|
$oResult->url(qq{url$i}); |
|
77
|
53
|
|
|
|
|
179
|
$oResult->title(qq{title$i}); |
|
78
|
53
|
|
|
|
|
500
|
$oResult->description("description$i"); |
|
79
|
53
|
|
|
|
|
443
|
$oResult->change_date("yesterday"); |
|
80
|
53
|
|
|
|
|
434
|
$oResult->index_date("today"); |
|
81
|
53
|
|
|
|
|
464
|
$oResult->raw(qq{}); |
|
82
|
53
|
|
|
|
|
464
|
$oResult->score(100-$i*2); |
|
83
|
53
|
|
|
|
|
437
|
$oResult->normalized_score(1000-$i*20); |
|
84
|
53
|
|
|
|
|
535
|
$oResult->size($i*2*1024); |
|
85
|
53
|
|
|
|
|
441
|
$oResult->source('WWW::Search::Null::Count'); |
|
86
|
53
|
|
|
|
|
433
|
$oResult->company('Dub Dub Dub Search, Inc.'); |
|
87
|
53
|
|
|
|
|
438
|
$oResult->location('Ashburn, VA'); |
|
88
|
53
|
100
|
|
|
|
425
|
if ($i % 2) |
|
89
|
|
|
|
|
|
|
{ |
|
90
|
27
|
|
|
|
|
144
|
$oResult->urls("url$i", map { "url$i.$_" } (1..$iCount)); |
|
|
991
|
|
|
|
|
2164
|
|
|
91
|
27
|
|
|
|
|
130
|
$oResult->related_urls(map { "url-r$i.$_" } (1..$iCount)); |
|
|
991
|
|
|
|
|
1888
|
|
|
92
|
27
|
|
|
|
|
127
|
my @aoTitles = map { "title-r$i.$_" } (1..$iCount); |
|
|
991
|
|
|
|
|
1838
|
|
|
93
|
27
|
|
|
|
|
146
|
$oResult->related_titles(\@aoTitles); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
else |
|
96
|
|
|
|
|
|
|
{ |
|
97
|
26
|
|
|
|
|
62
|
for my $j (1..$iCount) |
|
98
|
|
|
|
|
|
|
{ |
|
99
|
986
|
|
|
|
|
2734
|
$oResult->add_url(qq{url$i.$j}); |
|
100
|
986
|
|
|
|
|
2735
|
$oResult->add_related_url(qq{url-r$j}); |
|
101
|
986
|
|
|
|
|
2286
|
$oResult->add_related_title(qq{title-r$i}); |
|
102
|
|
|
|
|
|
|
} # for $j |
|
103
|
|
|
|
|
|
|
} # else |
|
104
|
53
|
|
|
|
|
81
|
push(@{$self->{cache}}, $oResult); |
|
|
53
|
|
|
|
|
138
|
|
|
105
|
|
|
|
|
|
|
} # for $i |
|
106
|
3
|
|
|
|
|
26
|
return 0; |
|
107
|
|
|
|
|
|
|
} # _native_retrieve_some |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__END__ |