Search.pm

filter: Statementstmt 45.2% 19 / 42 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 50.0% 5 / 10 Podpod 100% 2 / 2 totaltotal 32.9% 26 / 79 CC 9 SCAR 26.4
CC
9
Cov
31%
search
30.0
__ANON__
20.0
new
6.0
CRAP 13.9
« Ticker.pm ↑ Summary Session.pm »
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
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $arg || $arg
ref $arg $arg
Truth table0%0/3
A || B
A= ref $argB= $arg
ABresult
1X1
011
000
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
BranchTrueFalseTotal
my $self = shift() or croak("Usage: search E2SEARCH, KEYWORDS [, NODETYPE ] [, MAX_RESULTS ]") 0 0 0
32 0 ▶ my $keywords = shift or croak "Usage: search E2SEARCH, KEYWORDS [, NODETYPE ] [, MAX_RESULTS ]";
Branch: 1 branch
BranchTrueFalseTotal
my $keywords = shift() or croak("Usage: search E2SEARCH, KEYWORDS [, NODETYPE ] [, MAX_RESULTS ]") 0 0 0
33 0 ▶ my $nodetype = shift || 'e2node';
Condition0%0/2
shift() || 'e2node'
l!l
00
MC/DC0%0/1
shift() || 'e2node'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
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
BranchTrueFalseTotal
if $E2::Search::DEBUG > 1 0 0 0
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
BranchTrueFalseTotal
if (not $self->{"max_results"} && $self->{"results"} or $self->{"max_results"} > @results) 0 0 0
Condition0%0/6
not $self->{"max_results"} && $self->{"results"} or $self->{"max_results"} > @results
l!l&&r!l&&!r
000
$self->{'max_results'} && $self->{'results'}
!ll&&!rl&&r
000
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
ABCresult
0XX1
10X1
1111
1100
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__
« Ticker.pm ↑ Summary Session.pm »