Prog/Native/InvIndex.pm

filter: Statementstmt 100% 12 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 16 / 16 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Prog/Aggregator/MailFS.pm ↑ Summary
1 package SWISH::Prog::Native::InvIndex;
2 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use base qw( SWISH::Prog::InvIndex );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 __PACKAGE__->mk_accessors(qw( file ));
7  
8 our $VERSION = '0.75';
9  
10 =head1 NAME
11  
12 SWISH::Prog::Native::InvIndex - the native Swish-e index format
13  
14 =head1 SYNOPSIS
15  
16 # see SWISH::Prog::InvIndex
17  
18 =head1 DESCRIPTION
19  
20 The Native InvIndex represents the index.swish-e files.
21  
22 =head1 METHODS
23  
24 =cut
25  
26 =head2 init
27  
28 Sets file() to default index file name C<index.swish-e> unless
29 it is already set. If already set, confirms that file() is a child
30 of path().
31  
32 =cut
33  
34 sub init {
35 my $self = shift;
36 $self->SUPER::init(@_);
37 if ( !$self->file ) {
38 $self->file( $self->path->file('index.swish-e') );
39 }
40 else {
41  
42 # TODO check that ->file is child of ->path
43  
44 }
45  
46 }
47  
48 =head2 file
49  
50 Returns a Path::Class::File object representing the main index file.
51  
52 =head2 open
53  
54 Creates path() if not already existent.
55  
56 Since the native swish-e behaviour is to always create a temp index
57 and then rename it on close(), the clobber() attribute is effectively
58 ignored (always true).
59  
60 =cut
61  
62 sub open {
63 my $self = shift;
64  
65 if ( -f $self->path ) {
66 croak $self->path . " is not a directory.";
67 }
68  
69 if ( !-d $self->path ) {
70  
71 #carp "mkpath $self->{path}";
72 $self->path->mkpath($self->verbose);
73 }
74  
75 1;
76 }
77  
78 1;
79  
80 __END__
« Prog/Aggregator/MailFS.pm ↑ Summary