| 1 | package Treex::Block::Util::ChangeDocumentPath; | ||||||||||
| 2 | { | ||||||||||
| 3 | 1 | $Treex::Block::Util::ChangeDocumentPath::VERSION = '0.08633_1'; | |||||||||
| 4 | } | ||||||||||
| 5 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Treex::Core::Common; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | extends 'Treex::Core::Block'; | |||||||||
| 8 | |||||||||||
| 9 | 1 | has [qw(file_stem path)] => ( | |||||||||
| 10 | isa => 'Str', | ||||||||||
| 11 | is => 'ro', | ||||||||||
| 12 | documentation => 'sets the respective attribute', | ||||||||||
| 13 | ); | ||||||||||
| 14 | |||||||||||
| 15 | 1 | has pathre => ( | |||||||||
| 16 | is => 'ro', | ||||||||||
| 17 | isa => 'Str', | ||||||||||
| 18 | documentation => 'The regular expression to apply on document path, e.g. /foo/bar/', | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | sub process_document { | ||||||||||
| 23 | 0 | ▶ | my ( $self, $document ) = @_; | ||||||||
|
Subroutine
process_document: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | if (defined $self->pathre) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | my $p = $document->path; | |||||||||
| 27 | 0 | my $pathre = $self->pathre; | |||||||||
| 28 | 0 | eval "\$p =~ s$pathre;"; | |||||||||
| 29 | 0 | $document->set_path($p); | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | $document->set_path($self->path) if defined $self->path; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | ▶ | $document->set_file_stem($self->file_stem) if defined $self->file_stem; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | 0 | return 1; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 1 | 1; | |||||||||
| 39 | |||||||||||
| 40 | __END__ | ||||||||||
| 41 | |||||||||||
| 42 | =head1 NAME | ||||||||||
| 43 | |||||||||||
| 44 | Treex::Block::Util::ChangeDocumentPath | ||||||||||
| 45 | |||||||||||
| 46 | =head1 VERSION | ||||||||||
| 47 | |||||||||||
| 48 | version 0.08633_1 | ||||||||||
| 49 | |||||||||||
| 50 | =head1 DESCRIPTION | ||||||||||
| 51 | |||||||||||
| 52 | Modifies the document meta-information on filename. Useful before various | ||||||||||
| 53 | Writers. | ||||||||||
| 54 | |||||||||||
| 55 | Util::ChangeDocumentPath pathre=/foo/bar/ | ||||||||||
| 56 | |||||||||||
| 57 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 58 | |||||||||||
| 59 | Copyright © 2011 by Institute of Formal and Applied Linguistics, Charles University in Prague | ||||||||||
| 60 | |||||||||||
| 61 | This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||