summaryrefslogtreecommitdiff
path: root/lib/Event/File.pm
diff options
context:
space:
mode:
authorAndreas Brachold <vdr07@deltab.de>2007-08-13 18:41:27 +0000
committerAndreas Brachold <vdr07@deltab.de>2007-08-13 18:41:27 +0000
commitbcbf441e09fb502cf64924ff2530fa144bdf52c5 (patch)
treef377707a2dac078db8cd0c7d7abfe69ac1006d71 /lib/Event/File.pm
downloadxxv-bcbf441e09fb502cf64924ff2530fa144bdf52c5.tar.gz
xxv-bcbf441e09fb502cf64924ff2530fa144bdf52c5.tar.bz2
* Move files to trunk
Diffstat (limited to 'lib/Event/File.pm')
-rw-r--r--lib/Event/File.pm92
1 files changed, 92 insertions, 0 deletions
diff --git a/lib/Event/File.pm b/lib/Event/File.pm
new file mode 100644
index 0000000..f5f7ad5
--- /dev/null
+++ b/lib/Event/File.pm
@@ -0,0 +1,92 @@
+#we need Event.pm
+use Event;
+use IO::File;
+package Event::File;
+
+=head1 NAME
+
+Event::File is a wrapper module to write perl modules that deal with Files thru Event.
+It tries to mimics Event.pm model.
+
+=cut
+
+use strict;
+use vars qw($VERSION);
+$VERSION = '0.1.1';
+
+#we clone this from Event
+sub _load_watcher {
+ my $sub = shift;
+ eval { require "Event/File/$sub.pm" };
+ die if $@;
+
+ croak ("Event/File/$sub.pm did not define Event::File::$sub::new")
+ unless defined &$sub;
+ 1;
+}
+
+#we clone AUTOLOAD style from Event.pm
+sub AUTOLOAD {
+ my $sub = ($Event::File::AUTOLOAD =~ /(\w+)$/)[0];
+ _load_watcher($sub) or croak $@ . ', Undefined subroutine &' . $sub;
+
+ goto &$sub;
+}
+
+
+#The register routine
+#this will turn Event::File::foo into Event::File->foo() == Event::File::foo->new();
+sub register {
+ no strict 'refs';
+ my $package = caller;
+
+ my $name = $package;
+ $name =~ s/Event::File:://;
+
+ my $sub = \&{"$package\::new"};
+
+ die "can't find $package\::new"
+ if !$sub;
+ *{"Event::File::".$name} = sub {
+ shift;
+ $sub->("Event::File::".$name, @_);
+ };
+
+ #no hooks
+ #&Event::add_hooks if @_;
+}
+
+
+1;
+__END__
+
+=head1 Supported Events
+
+Right now only Event::File->tail is supported.
+For more information on it please refere to the Event::File::tail man page.
+
+=head1 External Modules
+
+This module makes use of
+
+=over
+
+=item *
+
+Event >= 0.80
+
+=item *
+
+IO::File
+
+=back
+
+=head1 SEE ALSO
+
+Event(3), File::File::tail(3), cmc
+
+=head1 AUTHOR
+
+Raul Dias, <raul@dias.com.br>
+
+=cut