| 1 | # E2::Search | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # Jose M. Weeks <jose@joseweeks.com> | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # 05 June 2003 | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # See bottom for pod documentation. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | package E2::Search; | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use E2::Ticker; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | our $VERSION = "0.32"; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | our @ISA = qw(E2::Ticker); | |||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | our $DEBUG; *DEBUG = *E2::Interface::DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | my $class = ref( $arg ) || $arg; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $arg || $arg
MC/DC0%0/2
ref $arg || $arg
ref $arg
$arg
Truth table0%0/3
A || B
A= ref $argB= $arg
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $self = $class->SUPER::new(); | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | bless ($self, $class); | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub search { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my $self = shift or croak "Usage: search E2SEARCH, KEYWORDS [, NODETYPE ] [, MAX_RESULTS ]"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my $keywords = shift or croak "Usage: search E2SEARCH, KEYWORDS [, NODETYPE ] [, MAX_RESULTS ]"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | my $nodetype = shift || 'e2node'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 'e2node'
MC/DC0%0/1
shift() || 'e2node'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $max_results = shift; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my @results; | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | warn "E2::Search::search\n" if $DEBUG > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my %opt = ( | |||||||||||||||||||||||||||||||||||||||||
| 41 | keywords => $keywords, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | nodetype => $nodetype | ||||||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | my $handlers = { | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | 'searchinfo/keywords' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | (my $a, my $b) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $self->{keywords} = $b->text; | |||||||||||||||||||||||||||||||||||||||||
| 49 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | 'searchinfo/search_nodetype' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | (my $a, my $b) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $self->{searchtype} = $b->text; | |||||||||||||||||||||||||||||||||||||||||
| 53 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | 'searchresults/e2link' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | (my $a, my $b) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if( !$self->{max_results} || | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $self->{"max_results"} && $self->{"results"} or $self->{"max_results"} > @results
$self->{'max_results'} && $self->{'results'}
MC/DC0%0/3
not $self->{"max_results"} && $self->{"results"} or $self->{"max_results"} > @results
$self->{'max_results'}
$self->{'results'}
$self->{"max_results"} > @results
Truth table0%0/4
not(A && B) or C
A= $self->{'max_results'}B= $self->{'results'}C= $self->{"max_results"} > @results
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | !$self->{results} || | ||||||||||||||||||||||||||||||||||||||||||
| 58 | $self->{max_results} > @results ) { | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | push @results, { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | title => $b->text, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | node_id =>$b->{att}->{node_id} | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->{keywords} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $self->{searchtype} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | return $self->parse( 'search', $handlers, \@results, %opt ); | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 76 | __END__ | ||||||||||||||||||||||||||||||||||||||||||