/[SWISH-PlusPlus]/trunk/PlusPlus.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/PlusPlus.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (hide annotations)
Fri Dec 3 15:23:23 2004 UTC (16 years, 3 months ago) by dpavlin
File size: 3579 byte(s)
- API change to be more line Plucene::Simple
- check_bin method to find and verify swish++ binaries
- make html target

1 dpavlin 1 package SWISH::PlusPlus;
2    
3     use 5.008004;
4     use strict;
5     use warnings;
6    
7 dpavlin 3 our $VERSION = '0.02';
8 dpavlin 1
9     use Carp;
10    
11     =head1 NAME
12    
13     SWISH::PlusPlus - Perl extension SWISH++
14    
15     =head1 SYNOPSIS
16    
17     use SWISH::PlusPlus;
18     blah blah blah
19    
20     =head1 DESCRIPTION
21    
22     This is perl module to use SWISH++ indexer by Paul J. Lucas. SWISH++ is
23 dpavlin 3 rewrite of swish-e in C++ which is extremly fast (thank to mmap), but without
24     support for properties (which this module tries to fix).
25 dpavlin 1
26 dpavlin 3 Implementation of this module is crafted after L<Plucene::Simple> and it
27     should be easy to replace Plucene with this module for increased
28     performance. However, this module is not plug-in replacement.
29    
30 dpavlin 1 =head1 METHODS
31    
32     =head2 open
33    
34     Create new indexing object.
35    
36 dpavlin 3 my $i = SWISH::PlusPlus->open(
37     index_dir => '/path/to/index',
38     index => 'index++',
39     search => 'search++',
40 dpavlin 1 );
41    
42     Options to open are following:
43    
44     =over 5
45    
46 dpavlin 3 =item C<index_dir>
47    
48     Path to directory in which index will be created.
49    
50 dpavlin 1 =item C<index>
51    
52 dpavlin 3 Full or partial path to SWISH++ index executable. By default, it's B<index>
53     for self-compiled version. If you use Debian GNU/Linux package specify
54     B<index++>. See C<Debian>.
55 dpavlin 1
56 dpavlin 3 =item C<search>
57    
58     Full or partial path to SWISH++ search executable. By default, it's B<search>.
59    
60 dpavlin 1 =back
61    
62     =cut
63    
64 dpavlin 3 sub open {
65 dpavlin 1 my $class = shift;
66     my $self = {@_};
67     bless($self, $class);
68    
69 dpavlin 3 foreach (qw(index_dir)) {
70 dpavlin 1 croak "need $_" unless $self->{$_};
71     }
72    
73 dpavlin 3 if (! -e $self->{'index_dir'}) {
74     mkdir $self->{'index_dir'} || confess "can't create index ",$self->{'index'},": $!";
75 dpavlin 1 }
76    
77 dpavlin 3 # default executables
78     $self->{'index'} ||= 'index';
79     $self->{'search'} ||= 'search';
80    
81 dpavlin 1 $self ? return $self : return undef;
82     }
83    
84    
85 dpavlin 3 =head2 check_bin
86    
87     Check if swish++ binaries specified in L<open> are available and verify
88     version signature.
89    
90     if ($i->check_bin) {
91     print "swish++ binaries found\n";
92     };
93    
94     It will also setup property
95    
96     $i->{'version'}
97    
98     which you can examine to see version.
99    
100     =cut
101    
102     sub check_bin {
103     my $self = shift;
104    
105     my $i = `$self->{'index'} -V 2>&1` || confess "can't find '",$self->{'index'},"' binary";
106     my $s = `$self->{'search'} -V 2>&1` || confess "can't find '",$self->{'search'},"' binary";
107    
108     chomp $i;
109     chomp $s;
110    
111     confess $self->{'index'}," binary is not SWISH++" unless ($i =~ m/^SWISH\+\+/);
112     confess $self->{'search'}," binary is not SWISH++" unless ($s =~ m/^SWISH\+\+/);
113    
114     if ($i eq $s) {
115     $self->{'version'} = $i;
116     return 1;
117     } else {
118     carp "version difference: index is $i while search is $s";
119     return;
120     }
121    
122     }
123    
124 dpavlin 1 1;
125     __END__
126    
127     =head2 EXPORT
128    
129     None by default.
130    
131 dpavlin 3 =head1 RELATED
132    
133     =head2 Debian
134    
135     Debian version of swish++ is often old (version 5 at moment of this writing
136     while version 6 is available in source code), so this module by default
137     uses executable names B<index> and B<search> for self-compiled version
138     instead of one from Debian package. See L<open> how to specify Debian
139     default binaries B<index++> and B<search++>.
140    
141 dpavlin 1 =head1 SEE ALSO
142    
143     Mention other useful documentation such as the documentation of
144     related modules or operating system documentation (such as man pages
145     in UNIX), or any relevant external documentation such as RFCs or
146     standards.
147    
148     If you have a mailing list set up for your module, mention it here.
149    
150     If you have a web site set up for your module, mention it here.
151    
152     =head1 AUTHOR
153    
154     Dobrica Pavlinusic, E<lt>dpavlin@E<gt>
155    
156     =head1 COPYRIGHT AND LICENSE
157    
158     Copyright (C) 2004 by Dobrica Pavlinusic
159    
160     This library is free software; you can redistribute it and/or modify
161     it under the same terms as Perl itself, either Perl version 5.8.4 or,
162     at your option, any later version of Perl 5 you may have available.
163    
164    
165     =cut

  ViewVC Help
Powered by ViewVC 1.1.26