File Coverage

blib/lib/KSx/Search/WildCardQuery.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 4 50.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 24 26 92.3


line stmt bran cond sub pod time code
1 1     1   935 use strict;
  1         2  
  1         38  
2 1     1   7 use warnings;
  1         1  
  1         51  
3              
4             package KSx::Search::WildCardQuery;
5 1     1   5 use base qw( KSx::Search::RegexpTermQuery );
  1         2  
  1         697  
6              
7             our $VERSION = '0.05';
8              
9             sub new {
10 1     1 1 5100 my($pack, %args) = @_;
11              
12 1         7 for($args{regexp} = delete $args{term}) {
13 1         4 $_ = quotemeta; # turn it into a regexp that matches a literal str
14 1         8 s/\\\*/.*/g; # convert \*’s into .*’s
15 1         3 s/(?:\.\*){2,}/.*/g; # eliminate multiple consecutive wild cards
16 1 50       10 s/^/^/ unless s/^\.\*//; # anchor the regexp to
17 1 50       9 s/\z/\\z/ unless s/\.\*\z//; # the ends of the term
18             }
19            
20 1         16 $pack->SUPER::new(%args);
21             }
22              
23             1;
24              
25             __END__