— |
{
$Treex::Block::Util::ChangeDocumentPath::VERSION = '0.08633_1' ;
}
has [ qw(file_stem path) ] => (
isa => 'Str' ,
is => 'ro' ,
documentation => 'sets the respective attribute' ,
);
has pathre => (
is => 'ro' ,
isa => 'Str' ,
documentation => 'The regular expression to apply on document path, e.g. /foo/bar/' ,
);
sub process_document {
my ( $self , $document ) = @_ ;
if ( defined $self ->pathre) {
my $p = $document ->path;
my $pathre = $self ->pathre;
eval "\$p =~ s$pathre;" ;
$document ->set_path( $p );
}
$document ->set_path( $self ->path) if defined $self ->path;
$document ->set_file_stem( $self ->file_stem) if defined $self ->file_stem;
return 1;
}
1;
|