File Coverage

blib/lib/Search/Query.pm
Criterion Covered Total %
statement 34 35 97.1
branch 6 8 75.0
condition n/a
subroutine 10 10 100.0
pod 2 2 100.0
total 52 55 94.5


line stmt bran cond sub pod time code
1             package Search::Query;
2              
3 9     9   18328 use warnings;
  9         14  
  9         303  
4 9     9   44 use strict;
  9         10  
  9         158  
5 9     9   3585 use Search::Query::Parser;
  9         23  
  9         306  
6 9     9   51 use Carp;
  9         12  
  9         507  
7 9     9   37 use File::Find;
  9         10  
  9         451  
8 9     9   36 use File::Spec;
  9         13  
  9         229  
9 9     9   29 use Data::Dump qw( dump );
  9         15  
  9         448  
10             use Module::Pluggable
11 9         81 search_path => ['Search::Query::Dialect'],
12 9     9   5133 sub_name => 'dialects';
  9         71953  
13              
14             our $VERSION = '0.307';
15              
16             =head1 NAME
17              
18             Search::Query - polyglot query parsing
19              
20             =head1 SYNOPSIS
21              
22             use Search::Query;
23            
24             my $parser = Search::Query->parser();
25             my $query = $parser->parse('+hello -world now');
26             print $query; # same as print $query->stringify;
27              
28             =cut
29              
30             =head1 DESCRIPTION
31              
32             This class provides documentation and class methods.
33              
34             Search::Query started as a fork of the excellent Search::QueryParser module
35             and was then rewritten to provide support for alternate query dialects.
36              
37             =head1 METHODS
38              
39             =head2 parser
40              
41             Returns a Search::Query::Parser object. See the documentation
42             for L for supported query syntax and how
43             to customize the Parser.
44              
45             =cut
46              
47             sub parser {
48 9     9 1 5153 my $class = shift;
49 9         180 return Search::Query::Parser->new(@_);
50             }
51              
52             =head2 get_query_class( I )
53              
54             Returns a Search::Query::Dialect-based class name corresponding
55             to I. I defaults to 'Native'.
56              
57             =cut
58              
59             sub get_query_class {
60 31     31 1 40 my $class = shift;
61 31 50       110 my $name = shift or croak "query_class name required";
62              
63 31 100       115 return $name if $name =~ m/^Search::Query::Dialect::/;
64              
65 20         103 for my $dialect ( $class->dialects ) {
66 52 100       54147 if ( $dialect =~ m/::$name$/i ) {
67 20         1276 eval "require $dialect";
68 20 50       86 croak $@ if $@;
69 20         110 return $dialect;
70             }
71             }
72              
73 0           croak "No such Dialect available: $name";
74             }
75              
76             =head2 get_dialect( I )
77              
78             Alias for get_query_class().
79              
80             =cut
81              
82             *get_dialect = \&get_query_class;
83              
84             =head1 AUTHOR
85              
86             Peter Karman, C<< >>
87              
88             =head1 BUGS
89              
90             Please report any bugs or feature requests to C, or through
91             the web interface at L. I will be notified, and then you'll
92             automatically be notified of progress on your bug as I make changes.
93              
94             =head1 SUPPORT
95              
96             You can find documentation for this module with the perldoc command.
97              
98             perldoc Search::Query
99              
100              
101             You can also look for information at:
102              
103             =over 4
104              
105             =item * RT: CPAN's request tracker
106              
107             L
108              
109             =item * AnnoCPAN: Annotated CPAN documentation
110              
111             L
112              
113             =item * CPAN Ratings
114              
115             L
116              
117             =item * Search CPAN
118              
119             L
120              
121             =back
122              
123              
124             =head1 ACKNOWLEDGEMENTS
125              
126             This module started as a fork of Search::QueryParser by
127             Laurent Dami.
128              
129             =head1 COPYRIGHT & LICENSE
130              
131             Copyright 2010 Peter Karman.
132              
133             This program is free software; you can redistribute it and/or modify it
134             under the terms of either: the GNU General Public License as published
135             by the Free Software Foundation; or the Artistic License.
136              
137             See http://dev.perl.org/licenses/ for more information.
138              
139             =cut
140              
141             1; # End of Search::Query