File Coverage

blib/lib/App/ElasticSearch/Utilities/QueryString/BareWords.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 21 21 100.0


line stmt bran cond sub pod time code
1             package App::ElasticSearch::Utilities::QueryString::BareWords;
2             # ABSTRACT: Mostly fixing case and tracking dangling words
3              
4 1     1   683 use v5.16;
  1         4  
5 1     1   6 use warnings;
  1         2  
  1         58  
6              
7             our $VERSION = '8.7'; # VERSION
8              
9 1     1   8 use CLI::Helpers qw(:output);
  1         2  
  1         7  
10 1     1   147 use namespace::autoclean;
  1         3  
  1         6  
11              
12 1     1   109 use Moo;
  1         2  
  1         6  
13             with 'App::ElasticSearch::Utilities::QueryString::Plugin';
14              
15 1     1   55 sub _build_priority { 1; }
16              
17             my %BareWords = (
18             and => { query_string => 'AND', invert => 0, dangles => 1 },
19             or => { query_string => 'OR', invert => 0, dangles => 1 },
20             not => { query_string => 'NOT', invert => 1, dangles => 1 },
21             );
22              
23              
24             sub handle_token {
25             my ($self,$token) = @_;
26              
27             debug(sprintf "%s - evaluating token '%s'", $self->name, $token);
28             return exists $BareWords{lc $token} ? [$BareWords{lc $token}] : undef;
29             }
30              
31             # Return True;
32             1;
33              
34             __END__
35              
36             =pod
37              
38             =head1 NAME
39              
40             App::ElasticSearch::Utilities::QueryString::BareWords - Mostly fixing case and tracking dangling words
41              
42             =head1 VERSION
43              
44             version 8.7
45              
46             =head1 SYNOPSIS
47              
48             =head2 App::ElasticSearch::Utilities::QueryString::Barewords
49              
50             The following barewords are transformed:
51              
52             or => OR
53             and => AND
54             not => NOT
55              
56             =for Pod::Coverage handle_token
57              
58             =head1 AUTHOR
59              
60             Brad Lhotsky <brad@divisionbyzero.net>
61              
62             =head1 COPYRIGHT AND LICENSE
63              
64             This software is Copyright (c) 2023 by Brad Lhotsky.
65              
66             This is free software, licensed under:
67              
68             The (three-clause) BSD License
69              
70             =cut