blib/lib/SWISH/WebService.pm

filter: Statementstmt 65.5% 95 / 145 Branchbran 26.0% 12 / 46 Conditioncond 40.7% 11 / 27 MC/DCmcdc 11.7% 2 / 17 Subroutinesub 80.9% 17 / 21 Podpod 12.5% 1 / 8 totaltotal 52.2% 138 / 264 CC 37 SCAR 38.5
CC
37
Cov
54%
search
132.5
_init
32.4
page
6.0
CRAP 46.9
↑ Summary
1 package SWISH::WebService;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Data::Pageset;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Search::Tools;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Search::Tools::XML;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Time::HiRes qw( gettimeofday tv_interval );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use base qw( Class::Accessor::Fast );
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 our $VERSION = '0.02';
17 1 our $Props = 'swishrank,swishreccount,swishdocpath,swishtitle,swishdescription';
18 1 our $Server = 'http://localhost/swished/';
19 1 our %Headers = (); # cache from index on first connect
20 1 our $Index = 'DEFAULT';
21 1 ▶our $Debug = $ENV{PERL_DEBUG} || 0;
Condition50%1/2
$ENV{'PERL_DEBUG'} || 0
l!l
01
MC/DC0%0/1
$ENV{'PERL_DEBUG'} || 0
$ENV{'PERL_DEBUG'}
Truth table50%1/2
A
A= $ENV{'PERL_DEBUG'}
Aresult
11
00
22 1 our %Defaults = (
23 q => '',
24 o => '',
25 n => 10,
26 p => 10,
27 s => 1,
28 f => 'html',
29 );
30  
31 1 our %Content_Types = (
32 xml => 'application/xml',
33 html => 'text/html',
34 simple => 'text/plain',
35 rss => 'application/xml'
36 );
37  
38 1 our $XMLDecl = '<?xml version="1.0" encoding="UTF-8"?>';
39  
40 ##################################################################################
41 # Templates
42 # could break these into separate files but easier for maintenance to include here
43 #
44  
45 1 our %Templates = ();
46  
47 ######################## XML ##############################
48  
49 1 $Templates{xml} = <<XML;
50 $XMLDecl
51 <search>
52 <results>
53 [% count = 0;
54 WHILE (r = results.NextResult);
55 count = count + 1 %]
56 <item
57 id="[% r.Property('swishreccount') %]"
58 rank="[% r.Property('swishrank') %]">
59 <title>[% self.xml.utf8_safe( r.Property('swishtitle') ) %]</title>
60 <url>[% r.Property('swishdocpath') | uri %]</url>
61 <snip>[% self.hiliter.light(
62 self.xml.utf8_safe(
63 self.snipper.snip(
64 r.Property('swishdescription')
65 )
66 )
67 )
68 %]</snip>
69 </item>
70 [% LAST IF count == self.p %]
71 [% END %]
72 </results>
73 <stats
74 start="[% self.s %]"
75 end="[% self.s + self.p - 1 %]"
76 max="[% self.p %]"
77 total="[% results.Hits %]"
78 runtime="[% self.elapsed | format('%0.3f') %]"
79 searchtime="[% self.searchtime | format('%0.3f') %]"
80 >
81 <query>[% results.Query %]</query>
82 <stopwords>[% results.Stopwords %]</stopwords>
83 <sortedBy>[% self.o %]</sortedBy>
84 <WordCharacters>[% self.wordchars %]</WordCharacters>
85 <BeginCharacters>[% self.beginchars %]</BeginCharacters>
86 <EndCharacters>[% self.endchars %]</EndCharacters>
87 </stats>
88 <links>
89 [% UNLESS pager.current_page == pager.first_page %]
90 <prev>
91 <a href="[% self.page( pager.previous_page ); self.params %]">Prev</a>
92 </prev>
93 [% IF pager.current_page > pager.first_page %]
94 <first>
95 <a href="[% self.page( pager.first_page ); self.params %]">[% pager.first_page %]</a>
96 </first>
97 [% END %]
98 [% END %]
99 [% FOR p = pager.pages_in_set %]
100 [% IF p == pager.current_page %]
101 <page id="[% p %]" class='current'>[% p %]</page>
102 [% ELSE %]
103 <page id="[% p %]">
104 <a href="[% self.page( p ); self.params %]">[% p %]</a>
105 </page>
106 [% END %]
107 [% END %]
108 [% UNLESS pager.current_page == pager.last_page %]
109 [% IF pager.current_page < pager.last_page %]
110 <last>
111 <a href="[% self.page( pager.last_page ); self.params %]">[% pager.last_page %]</a>
112 </last>
113 [% END %]
114 <next><a href="[% self.page( pager.next_page ); self.params %]">Next</a></next>
115 [% END %]
116 </links>
117 </search>
118 XML
119  
120 ###################### HTML ###########################
121  
122 1 $Templates{html} = <<HTML;
123 <div class="search">
124 <div class="results">
125 [% count = 0;
126 WHILE (r = results.NextResult);
127 count = count + 1 %]
128 <div
129 id="item_[% r.Property('swishreccount') %]"
130 class="item" >
131 <span class="rank">[% r.Property('swishrank') %]</span>
132 <span class="title">
133 <a href="[% r.Property('swishdocpath') | uri %]">[%
134 self.xml.utf8_safe(
135 r.Property('swishtitle')
136 )
137 %]</a>
138 </span>
139 <span class="url">[% r.Property('swishdocpath') | uri %]</span>
140 <span class="snip">[% self.hiliter.light(
141 self.xml.utf8_safe(
142 self.snipper.snip(
143 r.Property('swishdescription')
144 )
145 )
146 )
147 %]</span>
148 </div>
149 [% LAST IF count == self.p %]
150 [% END %]
151 </results>
152 <div class="stats">
153 <span class="stats">
154 Results [% self.s %] - [% self.s + self.p - 1 %]
155 of [% results.Hits %]
156 </span>
157 <span class="query">for <span class="query_words">[% self.snipper.rekw.keywords.join(' ') %]</span></span>
158 [% IF results.Stopwords %]
159 <span class="stopwords">The following words were automatically removed:
160 <span class="stopwords_words">[% results.Stopwords %]</span>
161 </span>
162 [% END %]
163 [% IF self.o %]
164 <span class="sortedBy">Sorted by: <span class="sorted">[% self.o %]</span></span>
165 [% END %]
166 <span class="times">
167 Run time: [% self.elapsed | format('%0.3f') %] sec -
168 Search time: [% self.searchtime | format('%0.3f') %] sec
169 </span>
170 </stats>
171 <div class="links">
172 [% UNLESS pager.current_page == pager.first_page %]
173 <span class="prev">
174 <a href="[% self.page( pager.previous_page ); self.params %]">&#171;&nbsp;Prev</a>
175 &#183;
176 </span>
177 [% IF pager.current_page > (pager.first_page + (self.n / 2) - 1) %]
178 <span class="first">
179 <a href="[% self.page( pager.first_page ); self.params %]">[% pager.first_page %]</a>
180 [% IF pager.current_page > (pager.first_page + (self.n / 2) ) %]&nbsp;...&nbsp;[% END %]
181 </span>
182 [% END %]
183 [% END %]
184 [% FOR p = pager.pages_in_set %]
185 [% IF p == pager.current_page %]
186 <span id="page_[% p %]" class="current">[% p %]</span>
187 [% ELSE %]
188 <span id="page_[% p %]">
189 <a href="[% self.page( p ); self.params %]">[% p %]</a>
190 </span>
191 [% END %]
192 [% END %]
193 [% UNLESS pager.current_page == pager.last_page %]
194 [% IF pager.current_page < (pager.last_page - (self.n / 2)) %]
195 <span class="last">
196 [% IF pager.current_page < (pager.last_page - (self.n / 2) - 1) %]&nbsp;...&nbsp;[% END %]
197 <a href="[% self.page( pager.last_page ); self.params %]">[% pager.last_page %]</a>
198 </span>
199 [% END %]
200 <span class="next">
201 &#183;
202 <a href="[% self.page( pager.next_page ); self.params %]">Next&nbsp;&#187;</a>
203 </span>
204 [% END %]
205 </div>
206 </div>
207 HTML
208  
209 ############################ simple ##############################
210  
211 1 $Templates{simple} = <<SIMPLE;
212 [% count = 0;
213 WHILE (r = results.NextResult);
214 count = count + 1 %]
215 t:[% r.Property('swishtitle') | uri %]
216 u:[% r.Property('swishdocpath') | uri %]
217 r:[% r.Property('swishrank') %]
218 n:[% r.Property('swishreccount') %]
219 -[% LAST IF count == self.p %][% END %]
220 --
221 SIMPLE
222  
223 ############################ RSS ###################################
224  
225 1 $Templates{rss} = <<RSS;
226 $XMLDecl
227 <rss version="2.0">
228 <channel>
229 <title>[% self.xml.utf8_safe( self.rss.title ) OR self.xml.utf8_safe( self.title ) %]</title>
230 <link>[% self.rss.link || self.uri %]</link>
231 <description>[% self.xml.utf8_safe( self.rss.description ) OR self.xml.utf8_safe( self.description ) %]</description>
232 <language>[% self.rss.lang || 'en-us' %]</language>
233 <image>
234 <title>[% self.xml.utf8_safe( self.rss.img.title ) %]</title>
235 <url>[% self.rss.img.url %]</url>
236 <link>[% self.rss.img.link %]</link>
237 </image>
238 [% count = 0;
239 WHILE (r = results.NextResult);
240 count = count + 1 %]
241 <item id="[% r.Property('swishreccount') %]">
242 <title>[% self.xml.utf8_safe( r.Property('swishtitle') ) %]</title>
243 <link>[% r.Property('swishdocpath') | uri %]</link>
244 <description>[% self.hiliter.light(
245 self.xml.utf8_safe(
246 self.snipper.snip(
247 r.Property('swishdescription')
248 )
249 )
250 )
251 %]</description>
252 </item>
253 [% LAST IF count == self.p %]
254 [% END %]
255 </channel>
256 </rss>
257 RSS
258  
259 ################################################################################
260  
261 sub new
262 1 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
263 1 my $class = shift;
264 1 my $self = {};
265 1 bless($self, $class);
266  
267 1 $self->mk_accessors(
268 qw/
269 error
270 template
271 searchtime
272 query
273 stopwords
274 wordchars
275 beginchars
276 endchars
277 swish
278 templates
279 debug
280 server
281 index
282 uri
283 results
284 title
285 rss
286 hiliter
287 snipper
288 xml
289 /,
290  
291 keys %Defaults
292 );
293  
294 1 return $self->_init(@_);
295 }
296  
297 sub _init
298 1 ▶{
Subroutine _init: called CC=15 SCAR=34.8
299 1 my $self = shift;
300 1 $self->{_start} = [gettimeofday()];
301 1 ▶ if (@_ > 1)
Branch: 2 branches
BranchTrueFalseTotal
if (@_ > 1) { } 1 0 1
elsif (@_) { } 0 0 0
302 {
303 1 my %extra = @_;
304 1 @$self{keys %extra} = values %extra;
305 1 for (keys %Defaults)
306 {
307 6 ▶ $self->{$_} ||= $Defaults{$_};
Condition100%3/3
$self->{$_} ||= $SWISH::WebService::Defaults{$_}
l!l&&r!l&&!r
141
MC/DC100%2/2
$self->{$_} ||= $SWISH::WebService::Defaults{$_}
$self->{$_} $SWISH::WebService::Defaults{$_}
Truth table100%3/3
A ||= B
A= $self->{$_}B= $SWISH::WebService::Defaults{$_}
ABresult
1X1
011
000
308 }
309 }
310 elsif (@_)
311 {
312 0 for (keys %Defaults)
313 {
314 $self->$_(
315 0 ▶ defined $_[0]->param($_) ? $_[0]->param($_) : $Defaults{$_});
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0]->param($_) ? : 0 0 0
316 }
317 }
318 else
319 {
320 0 croak "need name/value pairs or a CGI object";
321 }
322  
323 # enforce max hits
324 1 ▶ if ($self->p > 100)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->p > 100) 0 1 1
325 {
326 0 $self->p(100);
327 }
328  
329 1 ▶ unless ($self->q)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->q) { } 1 0 1
330 {
331 0 $self->error('Query is required at a minimum');
332 0 return;
333 }
334 else
335 {
336  
337 # filter query to match swish convention
338 # TODO a filter() callback?
339 # TODO build this =/: opt into swish itself
340 1 my $q = $self->q;
341 1 $q =~ s,:,=,g;
342 1 $self->q($q);
343 }
344  
345 # create template object
346 1 ▶ $self->{template} ||= Template->new()
Branch: 1 branch
BranchTrueFalseTotal
$self->{"template"} ||= "Template"->new or croak($Template::ERROR) 1 0 1
Condition33%1/3
$self->{"template"} ||= "Template"->new
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->{"template"} ||= "Template"->new
$self->{"template"} "Template"->new
Truth table33%1/3
A ||= B
A= $self->{"template"}B= "Template"->new
ABresult
1X1
011
000
347 or croak $Template::ERROR;
348  
349 # shortcut to S::T::XML
350 1 $self->xml(Search::Tools::XML->new);
351  
352 # defaults
353 1 ▶ $self->{templates} ||= \%Templates;
Condition50%1/2
$self->{"templates"} ||= \%SWISH::WebService::Templates
l!l
01
MC/DC0%0/1
$self->{"templates"} ||= \%SWISH::WebService::Templates
$self->{"templates"}
Truth table50%1/2
A
A= $self->{"templates"}
Aresult
11
00
354 1 ▶ $self->{index} ||= $Index;
Condition33%1/3
$self->{"index"} ||= $SWISH::WebService::Index
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->{"index"} ||= $SWISH::WebService::Index
$self->{"index"} $SWISH::WebService::Index
Truth table33%1/3
A ||= B
A= $self->{"index"}B= $SWISH::WebService::Index
ABresult
1X1
011
000
355 1 ▶ $self->{server} ||= $Server;
Condition33%1/3
$self->{"server"} ||= $SWISH::WebService::Server
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->{"server"} ||= $SWISH::WebService::Server
$self->{"server"} $SWISH::WebService::Server
Truth table33%1/3
A ||= B
A= $self->{"server"}B= $SWISH::WebService::Server
ABresult
1X1
011
000
356 1 ▶ $self->{debug} ||= $Debug;
Condition33%1/3
$self->{"debug"} ||= $SWISH::WebService::Debug
l!l&&r!l&&!r
001
MC/DC0%0/2
$self->{"debug"} ||= $SWISH::WebService::Debug
$self->{"debug"} $SWISH::WebService::Debug
Truth table33%1/3
A ||= B
A= $self->{"debug"}B= $SWISH::WebService::Debug
ABresult
1X1
011
000
357  
358 1 return $self;
359 }
360  
361 sub params
362 0 ▶{
Subroutine params: not called CC=1 SCAR=6.9
Pod undocumented
363 0 my $self = shift;
364  
365 # this is not terribly efficient
366 # but since we can't really cache how else to do it?
367 return $self->uri . '?'
368 0 . join(';', map { $_ . '=' . uri_escape($self->$_) } sort keys %Defaults);
369 }
370  
371 sub page
372 0 ▶{
Subroutine page: not called CC=2 SCAR=17.9
Pod undocumented
373  
374 # set the correct s() value based on $page and ->p()
375 # example: $page = 3 and ->p = 10, so ->s = 31
376 0 my $self = shift;
377 0 ▶ my $page = shift || 1;
Condition0%0/2
shift() || 1
l!l
00
MC/DC0%0/1
shift() || 1
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
378  
379 0 $self->s(($page * $self->p) - $self->p + 1);
380  
381 # important to return empty string so template doesn't get value
382 0 return '';
383 }
384  
385 sub search
386 1 ▶{
Subroutine search: called CC=16 SCAR=48.9
Pod undocumented
387 1 my $self = shift;
388  
389 1 $self->{_startsearch} = [gettimeofday()];
390  
391 1 ▶ unless ($self->swish)
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->swish) 1 0 1
392 {
393 1 eval "require SWISH::API::Remote";
394 1 ▶ if ($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 1 1
395 {
396 0 eval "require SWISH::API";
397  
398 0 ▶ if ($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
399 {
400 0 croak
401 "SWISH::API::Remote or SWISH::API must be installed to use "
402 . ref $self;
403 }
404 else
405 {
406 0 $self->swish(SWISH::API->new($self->index));
407 }
408  
409 }
410 else
411 {
412 1 $self->swish(
413 SWISH::API::Remote->new(
414 $self->server, $self->index, {DEBUG => $self->debug}
415 )
416 );
417 }
418  
419 }
420  
421 1 ▶ if (ref $self->swish eq 'SWISH::API')
Branch: 2 branches
BranchTrueFalseTotal
if (ref $self->swish eq 'SWISH::API') { } 0 1 1
elsif ($self->swish->isa('SWISH::API::Remote')) { } 1 0 1
422 {
423  
424 0 my $search = $self->swish->new_search_object;
425 0 ▶ return $self->error if $self->_check_swish_err;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_check_swish_err 0 0 0
426  
427 0 ▶ $search->set_sort($self->o) if $self->o;
Branch: 1 branch
BranchTrueFalseTotal
if $self->o 0 0 0
428 0 ▶ return $self->error if $self->_check_swish_err;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_check_swish_err 0 0 0
429  
430 0 $self->results($search->execute($self->q));
431 0 ▶ return $self->error if $self->_check_swish_err;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_check_swish_err 0 0 0
432  
433 0 $self->results->seek_result($self->s - 1);
434 0 ▶ return $self->error if $self->_check_swish_err;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_check_swish_err 0 0 0
435  
436 0 ▶ if (!%Headers)
Branch: 1 branch
BranchTrueFalseTotal
unless (%SWISH::WebService::Headers) 0 0 0
437 {
438 0 my $i = ($self->swish->index_names)[0];
439 0 my @h = $self->swish->header_names;
440 0 for (@h)
441 {
442 0 $Headers{$_} = join(' ', $self->swish->header_value($i, $_));
443 }
444 }
445  
446 }
447 elsif ($self->swish->isa('SWISH::API::Remote'))
448 {
449  
450 # TODO order ?
451 1 $self->results(
452 $self->swish->Execute(
453 $self->q,
454 {
455 BEGIN => $self->s - 1, # swished is 0-based
456 PROPERTIES => $Props,
457 MAX => $self->p
458 }
459 )
460 );
461  
462 1 ▶ if ($self->results->Error())
Branch: 1 branch
BranchTrueFalseTotal
if ($self->results->Error) 1 0 1
463 {
464 1 return $self->error($self->results->ErrorString());
465 }
466  
467 0 ▶ if (!%Headers)
Branch: 1 branch
BranchTrueFalseTotal
unless (%SWISH::WebService::Headers) 0 0 0
468 {
469 0 my @h = $self->swish->HeaderList;
470 0 for (@h)
471 {
472 0 $Headers{$_->Name} = $_->Value;
473 }
474 }
475  
476 }
477  
478 0 $self->searchtime(tv_interval($self->{_startsearch}, [gettimeofday()]));
479  
480 0 $self->wordchars($Headers{WordCharacters});
481 0 $self->beginchars($Headers{BeginCharacters});
482 0 $self->endchars($Headers{EndCharacters});
483  
484 # create hiliter and snipper
485 0 my $re =
486 Search::Tools->regexp(
487 query => $self->q,
488 word_characters => $self->wordchars,
489 begin_characters => $self->beginchars,
490 end_characters => $self->endchars
491 );
492 0 $self->snipper(
493 Search::Tools->snipper(
494 query => $re,
495 context => 12,
496 occur => 2
497 )
498 );
499 0 $self->hiliter(Search::Tools->hiliter(query => $re, class => 'hilite'));
500  
501 #carp Dumper \%Headers;
502  
503 0 return $self->render;
504  
505 }
506  
507 sub _check_swish_err
508 0 ▶{
Subroutine _check_swish_err: not called CC=2 SCAR=17.9
509 0 my $self = shift;
510 0 ▶ if ($self->swish->critical_error)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->swish->critical_error) 0 0 0
511 {
512 0 $self->error(
513 $self->swish->error_string . ": " . $self->swish->last_error_msg);
514 0 return $self->error;
515 }
516 0 return 0;
517 }
518  
519 sub format
520 0 ▶{
Subroutine format: not called CC=1 SCAR=6.9
Pod undocumented
521 0 return $Content_Types{$_[0]->f} . '; charset=utf-8';
522 }
523  
524 sub elapsed
525 1 ▶{
Subroutine elapsed: called CC=1 SCAR=0.0
Pod undocumented
526 1 return tv_interval($_[0]->{_start}, [gettimeofday()]);
527 }
528  
529 # the guts
530 sub render
531 1 ▶{
Subroutine render: called CC=3 SCAR=12.0
Pod undocumented
532 1 my $self = shift;
533 1 my $method = lc($self->f);
534  
535 1 ▶ unless (exists $self->templates->{$method})
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->templates->{$method}) 0 1 1
536 {
537 0 $self->error("no Template format for " . $self->f);
538 0 return;
539 }
540  
541 1 my $response = '';
542  
543 $self->template->process(
544 1 ▶ \$self->templates->{$method},
Branch: 1 branch
BranchTrueFalseTotal
$self->template->process(\$self->templates->{$method}, {"results", $self->results, "pager", $self->pager, "self", $self}, \$response) or croak($self->template->error) 1 0 1
545 {
546 results => $self->results,
547 pager => $self->pager,
548 self => $self,
549 },
550 \$response
551 )
552 or croak $self->template->error;
553  
554 1 return $response;
555 }
556  
557 sub pager
558 1 ▶{
Subroutine pager: called CC=4 SCAR=15.5
Pod undocumented
559 1 my $self = shift;
560  
561 1 ▶ return $self->{pager} if $self->{pager};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"pager"} 0 1 1
562  
563 1 ▶ my $results = shift || $self->results;
Condition33%1/3
shift() || $self->results
l!l&&r!l&&!r
010
MC/DC0%0/2
shift() || $self->results
shift() $self->results
Truth table33%1/3
A || B
A= shift()B= $self->results
ABresult
1X1
011
000
564 1 my $this_page = (($self->s - 1) / $self->p) + 1;
565  
566 $self->{pager} ||=
567 1 ▶ Data::Pageset->new(
Condition33%1/3
$self->{"pager"} ||= "Data::Pageset"->new({"total_entries", $results->Hits, "entries_per_page", $self->p, "current_page", $this_page, "pages_per_set", $self->n, "mode", "slide"})
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->{"pager"} ||= "Data::Pageset"->new({"total_entries", $results->Hits, "entries_per_page", $self->p, "current_page", $this_page, "pages_per_set", $self->n, "mode", "slide"})
$self->{"pager"} "Data::Pageset"->new({"total_entries", $results->Hits, "entries_per_page", $self->p, "current_page", $this_page, "pages_per_set", $self->n, "mode", "slide"})
Truth table33%1/3
A ||= B
A= $self->{"pager"}B= "Data::Pageset"->new({"total_entries", $results->Hits, "entries_per_page", $self->p, "current_page", $this_page, "pages_per_set", $self->n, "mode", "slide"})
ABresult
1X1
011
000
568 {
569 total_entries => $results->Hits,
570 entries_per_page => $self->p,
571 current_page => $this_page,
572 pages_per_set => $self->n,
573 mode => 'slide',
574 }
575 );
576  
577 1 return $self->{pager};
578  
579 }
580  
581 1 1;
582  
583 __END__
↑ Summary