summaryrefslogtreecommitdiffstats
path: root/lib/Crawl/Bot/Role/RSS.pm
blob: 8576a82bc0d50cce36a43e23ebebc79ad08ebc67 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package Crawl::Bot::Role::RSS;
use Moose::Role;

use XML::RAI;

with 'Crawl::Bot::Role::CachedItems';

requires 'rss_feed';

sub current_items {
    my $self = shift;
    my $rss = XML::RAI->parse_uri($self->rss_feed);
    # after the XML::RAI object goes out of scope, the item objects become
    # worthless. how dumb. capture the relevant data in some hashrefs instead.
    return map {
        my $item = $_;
        +{
            map { $_ => $item->$_ }
                qw(identifier title link creator)
         }
    } @{ $rss->items };
}

no Moose::Role;

1;