Permalink
Browse files

Rename `path` to `doc_root` and document it.

The new name brings it in line with the same accessor on PGXN::API.
  • Loading branch information...
1 parent 697439d commit 257aae7ce89194d031f31b45c284b41535fb3de4 @theory theory committed Apr 1, 2011
Showing with 12 additions and 11 deletions.
  1. +2 −0 Changes
  2. +8 −9 lib/PGXN/API/Searcher.pm
  3. +2 −2 t/base.t
View
@@ -8,6 +8,8 @@ Revision history for Perl extension PGXN-API-Searcher.
than just once in `new()`. Parsers are cached from `new()` on,
however. This means that consumers can keep a PGXN::API::Searcher
object persistent in memory without worrying about index invalidation.
+ - The API document root path passed to `new()` is now retained and
+ accessible via thew `doc_root()` accessor.
0.7.0 2011-03-31T20:55:51
- Augmented the docs a bit.
View
@@ -33,13 +33,13 @@ sub new {
);
}
bless {
- path => $path,
- parsers => \%parsers,
+ doc_root => $path,
+ parsers => \%parsers,
} => $class;
}
-sub path { shift->{path} }
-sub parsers { shift->{parsers} }
+sub doc_root { shift->{doc_root} }
+sub parsers { shift->{parsers} }
my %highlightable = (
docs => 'body',
@@ -63,7 +63,7 @@ sub search {
my $query = $self->{parsers}{$iname}->parse($params{query})->as_ks_query;
my $limit = ($params{limit} ||= 50) < 1024 ? $params{limit} : 50;
my $searcher = KinoSearch::Search::IndexSearcher->new(
- index => File::Spec->catdir($self->path, '_index', $iname)
+ index => File::Spec->catdir($self->doc_root, '_index', $iname)
);
my $hits = $searcher->hits(
@@ -153,12 +153,11 @@ directory.
=head2 Accessors
-=head3 C<searchers>
+=head3 C<doc_root>
- my $doc_searcher = $search->searchers->{doc};
+ my $doc_root = $search->doc_root;
-Returns a hash reference of index search objects. The keys are the names of
-the indexes, and the values are L<KinoSearch::Search::IndexSearcher> objects.
+Returns the path to the document root passed to C<new()>.
=head3 C<parsers>
View
@@ -21,7 +21,7 @@ BEGIN {
can_ok $CLASS => qw(
new
- path
+ doc_root
parsers
search
);
@@ -263,7 +263,7 @@ $_->commit for values %indexers;
# Okay, do some searches!
my $search = new_ok $CLASS, ['t'], 'Instance';
-is $search->path, 't', 'Path should be set';
+is $search->doc_root, 't', 'Doc root should be set';
ok my $res = $search->search(query => 'ordered pair', in => 'dists'),
'Search docs for "ordered pair"';
is_deeply $res, {

0 comments on commit 257aae7

Please sign in to comment.