File Coverage

blib/lib/Kwiki/Search/Spotlight.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package Kwiki::Search::Spotlight;
2 1     1   1632 use Kwiki::Search -Base;
  0            
  0            
3             our $VERSION = '0.01';
4              
5             sub register {
6             super;
7             my $reg = shift;
8             $reg->add(hook => 'page:store', post => 'update_index');
9             }
10              
11             sub update_index {
12             my $search = $self->hub->search;
13             my $page_name = $self->id;
14             my $dir = $search->plugin_directory;
15             io($dir)->mkpath;
16             system "/bin/cp database/${page_name} ${dir}/${page_name}.txt";
17             }
18              
19             sub perform_search {
20             my $search = $self->cgi->search_term;
21             my $dir = io($self->plugin_directory)->absolute;
22             [ map {
23             s/$dir\///;
24             s/\.txt$//;
25             $self->hub->pages->new_page($_);
26             } split(/\n/,`/usr/bin/mdfind -onlyin $dir "$search"`)];
27             }
28              
29             __END__