| 1 | package Search::Query; | ||||||||||
| 2 | |||||||||||
| 3 | 9 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 9 | ▶ | use Search::Query::Parser; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 9 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 9 | ▶ | use File::Find; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 9 | ▶ | use File::Spec; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 9 | ▶ | use Data::Dump qw( dump ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | use Module::Pluggable | ||||||||||
| 11 | 9 | search_path => ['Search::Query::Dialect'], | |||||||||
| 12 | 9 | ▶ | sub_name => 'dialects'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 9 | our $VERSION = '0.306'; | |||||||||
| 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<Search::Query::Parser> for supported query syntax and how | ||||||||||
| 43 | to customize the Parser. | ||||||||||
| 44 | |||||||||||
| 45 | =cut | ||||||||||
| 46 | |||||||||||
| 47 | sub parser { | ||||||||||
| 48 | 6 | ▶ | my $class = shift; | ||||||||
|
Subroutine
parser: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 49 | 6 | return Search::Query::Parser->new(@_); | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | =head2 get_query_class( I<name> ) | ||||||||||
| 53 | |||||||||||
| 54 | Returns a Search::Query::Dialect-based class name corresponding | ||||||||||
| 55 | to I<name>. I<name> defaults to 'Native'. | ||||||||||
| 56 | |||||||||||
| 57 | =cut | ||||||||||
| 58 | |||||||||||
| 59 | sub get_query_class { | ||||||||||
| 60 | 28 | ▶ | my $class = shift; | ||||||||
|
Subroutine
get_query_class: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||
| 61 | 28 | ▶ | my $name = shift or croak "query_class name required"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | |||||||||||
| 63 | 28 | ▶ | return $name if $name =~ m/^Search::Query::Dialect::/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | |||||||||||
| 65 | 18 | for my $dialect ( $class->dialects ) { | |||||||||
| 66 | 46 | ▶ | if ( $dialect =~ m/::$name$/i ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 18 | eval "require $dialect"; | |||||||||
| 68 | 18 | ▶ | croak $@ if $@; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | 18 | return $dialect; | |||||||||
| 70 | } | ||||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | 0 | croak "No such Dialect available: $name"; | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | =head2 get_dialect( I<name> ) | ||||||||||
| 77 | |||||||||||
| 78 | Alias for get_query_class(). | ||||||||||
| 79 | |||||||||||
| 80 | =cut | ||||||||||
| 81 | |||||||||||
| 82 | 9 | *get_dialect = \&get_query_class; | |||||||||
| 83 | |||||||||||
| 84 | =head1 AUTHOR | ||||||||||
| 85 | |||||||||||
| 86 | Peter Karman, C<< <karman at cpan.org> >> | ||||||||||
| 87 | |||||||||||
| 88 | =head1 BUGS | ||||||||||
| 89 | |||||||||||
| 90 | Please report any bugs or feature requests to C<bug-search-query at rt.cpan.org>, or through | ||||||||||
| 91 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Search-Query>. 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<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Search-Query> | ||||||||||
| 108 | |||||||||||
| 109 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||
| 110 | |||||||||||
| 111 | L<http://annocpan.org/dist/Search-Query> | ||||||||||
| 112 | |||||||||||
| 113 | =item * CPAN Ratings | ||||||||||
| 114 | |||||||||||
| 115 | L<http://cpanratings.perl.org/d/Search-Query> | ||||||||||
| 116 | |||||||||||
| 117 | =item * Search CPAN | ||||||||||
| 118 | |||||||||||
| 119 | L<http://search.cpan.org/dist/Search-Query/> | ||||||||||
| 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 | 9 | 1; # End of Search::Query | |||||||||