NAME

App::Rssfilter::Feed - Get the latest or previous version of an RSS feed

VERSION

version 0.07

SYNOPSIS

use App::Rssfilter::Feed;

my $feed = App::Rssfilter::Feed->new( filename => 'http://get.your.files/here.rss' );
# shorthand for
$feed = App::Rssfilter::Feed->new(
    name => 'filename',
    url  => 'http://get.your.files/here.rss',
);

my $rule = App::RssFilter::Rule->new( 
    condition => 'A Matcher',
    action    => 'A Filter',
);
$feed->add_rule( $rule );

$feed->add_rule(
    condition => 'Another Matcher',
    action    => 'Another Filter',
);

$feed->update;

### or with App::Rssfilter::Group

use App::Rssfilter::Group;
my $group = App::RssFilter::Group->new( 'Tubular' );
$group->add_feed( RadName => 'http://r.a.d.i.c.al/feed.rss' );
# shorthand for
$group->add_feed(
    App::Rssfilter::Feed->new(
        RadName => 'http://r.a.d.i.c.al/feed.rss'
    )
);
$group->update;

DESCRIPTION

This module fetches the latest version of an RSS feed from a URL and constrains it with its list of rules.

It consumes the App::Rssfilter::Logger role.

ATTRIBUTES

logger

This is a object used for logging. It defaults to a Log::Any object. It is provided by the App::Rssfilter::Logger role.

name

This is the name of the feed to use when storing it, and is required. This will be used by the default storage as the filename to store the feed under.

url

This is the URL to fetch the latest feed content from, and is required.

rules

This is the arrayref of rules which will constrain newly-fetched feeds. It defaults to an empty arrayref.

user_agent

This is a Mojo::UserAgent to use to fetch this feed's url. It defaults to a new Mojo::UserAgent.

storage

This is the App::Rssfilter::Feed::Storage to store newly-fetched iRSS documents, or retrieve the previously-fetched version. It defaults to a new App::Rssfilter::Feed::Storage, with its name set to this feed's name.

METHODS

add_rule

$feed->add_rule( $rule )->add_rule( %rule_parameters );

Adds the $rule (or creates a new App::RssFilter::Rule from the passed parameters) to the rules.

update

$feed->update( rules => $rules, storage => $storage );

This method will:

  • download the RSS feed from the URL, if it is newer than the previously-saved version

  • apply the rules to the new RSS feed

  • save the new RSS feed

  • apply the rules to the old RSS feed

The old feed has rules applied to it so that any group-wide rules will always see all of the latest items, even if a feed does not have a newer version available.

The parameters are optional. $rules should be an arryref of additional rules to be added to the feed's rules for this update only. $storage should be an App::Rssfilter::Feed::Storage that will used instead of this feed's storage to load/save RSS doucments.

SEE ALSO

AUTHOR

Daniel Holz <dgholz@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Daniel Holz.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.