/[Frey]/branches/mojo/lib/Frey/Feed.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /branches/mojo/lib/Frey/Feed.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 265 - (show annotations)
Tue Nov 4 23:25:29 2008 UTC (15 years, 5 months ago) by dpavlin
File size: 880 byte(s)
data should return arrayref, not array
1 package Frey::Feed;
2 use Moose;
3
4 =head1 NAME
5
6 Frey::Feed - represent RSS/Atom feed using L<Data::Feed>
7
8 =cut
9
10 use Data::Feed;
11 use Frey::Types;
12 use Data::Dump qw/dump/;
13
14 with 'Frey::Storage';
15
16 has uri => (
17 is => 'rw',
18 isa => 'Uri', coerce => 1,
19 required => 1,
20 default => 'https://blog.rot13.org/index.xml',
21 );
22
23 has feed => (
24 is => 'ro',
25 lazy => 1,
26 default => sub {
27 my ($self) = @_;
28 my $path = 'var/feed/' . $self->uri->host . '/' . $self->uri->path;
29 my $data = $self->load( $path );
30 if ( defined $data ) {
31 return $data;
32 }
33
34 warn "parse ", $self->uri;
35 my $feed = Data::Feed->parse( $self->uri );
36 $self->store( $path, $feed );
37 $feed;
38 },
39 );
40
41 has title => (
42 is => 'ro',
43 lazy => 1,
44 default => sub { $_[0]->feed->title },
45 );
46
47 sub entries { $_[0]->feed->entries }
48
49 sub data {
50 my ($self) = @_;
51 # data should return single element!
52 [ $self->entries ];
53 }
54
55 1;

  ViewVC Help
Powered by ViewVC 1.1.26