aboutsummaryrefslogtreecommitdiff
path: root/lib/File
diff options
context:
space:
mode:
authordakkar <dakkar@luxion>2007-09-09 09:21:10 +0000
committerdakkar <dakkar@luxion>2007-09-09 09:21:10 +0000
commit46c5091e8befe5da53574e712038cba975245f02 (patch)
tree75526ba9a3c74efaed6d294ae74630609ab2429a /lib/File
parentsymlink following, and most parsers for the test (diff)
downloadWebCoso-46c5091e8befe5da53574e712038cba975245f02.tar.gz
WebCoso-46c5091e8befe5da53574e712038cba975245f02.tar.bz2
WebCoso-46c5091e8befe5da53574e712038cba975245f02.zip
parser call on putting scalar
git-svn-id: svn://luxion/repos/WebCoso/trunk@285 fcb26f47-9200-0410-b104-b98ab5b095f3
Diffstat (limited to 'lib/File')
-rw-r--r--lib/File/Cache/Parsed.pm22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/File/Cache/Parsed.pm b/lib/File/Cache/Parsed.pm
index f6930d3..a3843d1 100644
--- a/lib/File/Cache/Parsed.pm
+++ b/lib/File/Cache/Parsed.pm
@@ -28,6 +28,9 @@ sub add_parser {
else {
push @{$self->{parsers}},[$rx,$parser];
}
+
+ $self->invalidate($rx);
+
return;
}
@@ -57,6 +60,17 @@ sub del_parser {
return;
}
+sub del_writer {
+ my ($self,$rx)=@_;
+
+ my $i=firstidx {$_->[0] eq $rx} @{$self->{writers}};
+ return if $i<0;
+
+ splice @{$self->{writers}},$i,1;
+
+ return;
+}
+
sub get {
my ($self,$filename)=@_;
@@ -86,7 +100,13 @@ sub put {
return $ww->[1]->($filename,$contents);
}
elsif (!ref($contents)) {
- $self->{cache}{$filename}=$contents;
+ my $pp=first {$filename =~ m{$_->[0]}} @{$self->{parsers}};
+ if ($pp) {
+ $self->{cache}{$filename}=$pp->[1]->($filename,$contents);
+ }
+ else {
+ $self->{cache}{$filename}=$contents;
+ }
return print {file($filename)->openw} $contents;
}
else {