aboutsummaryrefslogtreecommitdiff
path: root/lib/WebCoso/Step/ReST/SplitLang.pm
diff options
context:
space:
mode:
authordakkar <dakkar@luxion>2006-12-17 12:08:23 +0000
committerdakkar <dakkar@luxion>2006-12-17 12:08:23 +0000
commitfce73c4f1cb1c3ebed4551e43108f3506bb66f51 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /lib/WebCoso/Step/ReST/SplitLang.pm
parent r1350@narval: dakkar | 2006-02-21 13:05:07 +0100 (diff)
downloadWebCoso-fce73c4f1cb1c3ebed4551e43108f3506bb66f51.tar.gz
WebCoso-fce73c4f1cb1c3ebed4551e43108f3506bb66f51.tar.bz2
WebCoso-fce73c4f1cb1c3ebed4551e43108f3506bb66f51.zip
pulizia: si ricomincia (di nuovo...)
git-svn-id: svn://luxion/repos/WebCoso/trunk@234 fcb26f47-9200-0410-b104-b98ab5b095f3
Diffstat (limited to 'lib/WebCoso/Step/ReST/SplitLang.pm')
-rw-r--r--lib/WebCoso/Step/ReST/SplitLang.pm87
1 files changed, 0 insertions, 87 deletions
diff --git a/lib/WebCoso/Step/ReST/SplitLang.pm b/lib/WebCoso/Step/ReST/SplitLang.pm
deleted file mode 100644
index cdbc109..0000000
--- a/lib/WebCoso/Step/ReST/SplitLang.pm
+++ /dev/null
@@ -1,87 +0,0 @@
-package WebCoso::Step::ReST::SplitLang;
-use strict;
-use warnings;
-use base 'WebCoso::Step';
-use Class::Std;
-
-{
-
-=head2 Che fa
-
-Prende il sorgente da {filename=>'sperosiaunosolo'}->datastream, cerca
-righe della forma
-
- ^\s*.. lang:: (\w*)
-
-raccoglie tutti i C<$1>, e quelle sono le lingue (C<''> sta per 'tutte
-le lingue')
-
-Splitta poi in {language=>'$1'}->rstdoc (stringhe)
-
-Fa tutto alla prima passata
-
-=cut
-
-my %srckey_of :ATTR(:init_arg<from> :get<srckey> :default<datastream>);
-my %dstkey_of :ATTR(:init_arg<to> :get<dstkey> :default<rstdoc>);
-
-my $lang_re=qr{^\s*\.\.\s+lang::(?:\s+(\w+))?\s*$};
-
-sub process {
- my ($self,$resource,$stage)=@_;
-
- return unless $stage eq 'meta';
-
- my $srckey=$self->get_srckey();
- my $dstkey=$self->get_dstkey();
-
- my $fh=$resource->get_property_fh($srckey);
- if (!defined $fh) {
- my ($filename)=$resource->get_axis_values('filename');
- $fh=$resource->get_property_fh({filename=>$filename},$srckey);
- }
-
- binmode $fh,':utf8';
-
- # raccolgo le lingue usate
- my %langs=(''=>undef);
- seek $fh,0,0;
- while (my $line=<$fh>) {
- if ($line =~ m{$lang_re}) {
- $langs{$1||''}=undef;
- }
- }
- delete $langs{''};
- seek $fh,0,0;
-
- if (%langs) { # multilingua: split!
- my $curlang='';my %docs=();
- while (my $line=<$fh>) {
- if ($line =~ m{$lang_re}) {
- $curlang=$1||'';
- next;
- }
- if ($curlang) {
- $docs{$curlang}.=$line;
- }
- else { # 'any', per cui scrivo su tutti
- $docs{$_}.=$line for keys %langs;
- }
- }
- # salvo
- $resource->set_property({language=>$_},$dstkey=>$docs{$_})
- for keys %langs;
- }
- else { # monolingua: passa il filehandle
- $resource->set_property($dstkey=>$fh);
- }
-
- # rimetto a posto il filehandle
- seek $fh,0,0;
-
- return;
-}
-
-}
-
-1;