/[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

Diff of /trunk/PlusPlus.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1 by dpavlin, Fri Dec 3 13:31:43 2004 UTC revision 3 by dpavlin, Fri Dec 3 15:23:23 2004 UTC
# Line 4  use 5.008004; Line 4  use 5.008004;
4  use strict;  use strict;
5  use warnings;  use warnings;
6    
7  our $VERSION = '0.01';  our $VERSION = '0.02';
8    
9  use Carp;  use Carp;
10    
# Line 20  SWISH::PlusPlus - Perl extension SWISH++ Line 20  SWISH::PlusPlus - Perl extension SWISH++
20  =head1 DESCRIPTION  =head1 DESCRIPTION
21    
22  This is perl module to use SWISH++ indexer by Paul J. Lucas. SWISH++ is  This is perl module to use SWISH++ indexer by Paul J. Lucas. SWISH++ is
23  rewrite of swish-e in C++ with blazingly fast performance, but without  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)  support for properties (which this module tries to fix).
25    
26    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  =head1 METHODS  =head1 METHODS
31    
# Line 29  support for properties (which this modul Line 33  support for properties (which this modul
33    
34  Create new indexing object.  Create new indexing object.
35    
36    my $i = new SWISH::PlusPlus(    my $i = SWISH::PlusPlus->open(
37          index => '/path/to/index',          index_dir => '/path/to/index',
38            index => 'index++',
39            search => 'search++',
40    );    );
41    
42  Options to open are following:  Options to open are following:
43    
44  =over 5  =over 5
45    
46    =item C<index_dir>
47    
48    Path to directory in which index will be created.
49    
50  =item C<index>  =item C<index>
51    
52  path to directory in which index will be created.  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    
56    =item C<search>
57    
58    Full or partial path to SWISH++ search executable. By default, it's B<search>.
59    
60  =back  =back
61    
62  =cut  =cut
63    
64  sub new {  sub open {
65          my $class = shift;          my $class = shift;
66          my $self = {@_};          my $self = {@_};
67          bless($self, $class);          bless($self, $class);
68    
69          foreach (qw(index)) {          foreach (qw(index_dir)) {
70                  croak "need $_" unless $self->{$_};                  croak "need $_" unless $self->{$_};
71          }          }
72    
73          if (! -e $self->{'index'}) {          if (! -e $self->{'index_dir'}) {
74                  mkdir $self->{'index'} || confess "can't create index ",$self->{'index'},": $!";                  mkdir $self->{'index_dir'} || confess "can't create index ",$self->{'index'},": $!";
75          }          }
76    
77            # default executables
78            $self->{'index'} ||= 'index';
79            $self->{'search'} ||= 'search';
80    
81          $self ? return $self : return undef;          $self ? return $self : return undef;
82  }  }
83    
84    
85    =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  1;  1;
125  __END__  __END__
126    
# Line 69  __END__ Line 128  __END__
128    
129  None by default.  None by default.
130    
131    =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  =head1 SEE ALSO  =head1 SEE ALSO
142    
143  Mention other useful documentation such as the documentation of  Mention other useful documentation such as the documentation of

Legend:
Removed from v.1  
changed lines
  Added in v.3

  ViewVC Help
Powered by ViewVC 1.1.26