root/trunk/plagger/t/plugins/Subscription-Feed/subscription.t

Revision 861 (checked in by miyagawa, 14 years ago)

Add Subscription::Feed to subscribe to feed entries.

Line 
1 use strict;
2 use FindBin;
3 use File::Spec;
4 use Test::More tests => 2;
5
6 use Plagger;
7 Plagger->bootstrap(config => \<<CONFIG);
8 global:
9   log:
10     level: error
11 plugins:
12   - module: Subscription::Feed
13     config:
14       url: file:///$FindBin::Bin/feed.xml
15   - module: Aggregator::Test
16 CONFIG
17
18 package Plagger::Plugin::Aggregator::Test;
19 use base qw( Plagger::Plugin );
20
21 sub register {
22     my($self, $context) = @_;
23     $context->register_hook(
24         $self,
25         'customfeed.handle' => \&load,
26         'aggregator.finalize' => \&test,
27     );
28 }
29
30 sub load {
31     my($self, $context, $args) = @_;
32     push @{$self->{feeds}}, $args->{feed}->url;
33     return 1;
34 }
35
36 sub test {
37     my($self, $context) = @_;
38     ::is $self->{feeds}->[0], "http://d.hatena.ne.jp/agw/20060526/1148633449#c";
39     ::is $self->{feeds}->[1], "http://d.hatena.ne.jp/nirvash/20060517/1147836803#c";
40 }
41
Note: See TracBrowser for help on using the browser.