root/trunk/plagger/lib/Plagger/Plugin/Notify/Eject.pm

Revision 218 (checked in by ko, 15 years ago)

Added Notify::Eject

Line 
1 package Plagger::Plugin::Notify::Eject;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 sub init {
6     my $self = shift;
7     $self->SUPER::init(@_);
8
9     my $class = 'Plagger::Plugin::Notify::Eject::' . lc($^O);
10     eval "require $class;";
11     if ($@) {
12         Plagger->context->error("Eject plugin doesn't run on your platform $^O");
13     }
14     bless $self, $class;
15 }
16
17 sub register {
18     my($self, $context) = @_;
19     $context->register_hook(
20         $self,
21         'publish.feed' => \&update,
22         'publish.finalize' => \&finalize,
23     );
24     $self->{count} = 0;
25 }
26
27 sub update {
28     my($self, $context, $args) = @_;
29     $self->{count}++ if $args->{feed}->count;
30 }
31
32 sub finalize {
33     my($self, $context, $args) = @_;
34     $self->eject if $self->{count};
35 }
36
37 sub eject { $_[1]->log(warn => 'Subclass should override this') }
38
39 1;
40
41 __END__
42
43 =head1 NAME
44
45 Plagger::Plugin::Notify::Eject - Notify feed updates to CD Drive
46
47 =head1 SYNOPSIS
48
49   - module: Notify::Eject
50
51 =head1 DESCRIPTION
52
53
54 =head1 AUTHOR
55
56 Kazuhiro Osawa
57
58 =head1 SEE ALSO
59
60 L<Plagger>, L<Plagger::Plugin::Notify::Eject::linux>, L<Plagger::Plugin::Notify::Eject::freebsd>,
61 L<Plagger::Plugin::Notify::Eject::mswin32>, L<Plagger::Plugin::Notify::Eject::darwin>
62
63 =cut
Note: See TracBrowser for help on using the browser.