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 2     2   279155 use v5.16;
  2         9  
5 2     2   14 use warnings;
  2         5  
  2         232  
6              
7             our $VERSION = '8.8'; # VERSION
8              
9 2     2   761 use CLI::Helpers qw(:output);
  2         105564  
  2         20  
10 2     2   911 use namespace::autoclean;
  2         16877  
  2         19  
11              
12 2     2   841 use Moo;
  2         10268  
  2         13  
13             with 'App::ElasticSearch::Utilities::QueryString::Plugin';
14              
15 1     1   35 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.8
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) 2024 by Brad Lhotsky.
65              
66             This is free software, licensed under:
67              
68             The (three-clause) BSD License
69              
70             =cut