App::Rssfilter::Group - associate one or more rules with more than one feed
version 0.04
use App::RssFilter::Group; my $news_group = App::Rssfilter::Group->new( 'news' ); # shorthand for $news_group = App::Rssfilter::Group( name => 'news' ); $news_group->add_group( 'USA' ); # shorthand for $news_group->add_group( App::Rssfilter::Group->new( name => 'USA', ) ); my $uk_news_group = $news_group->add_group( name => 'UK' ); $uk_news_group->add_rule( 'Category[Politics]' => 'MarkTitle' ); # shorthand for $uk_news_group->add_rule( App::Rssfilter::Rule->new( condition => 'Category[Politics]', action => 'MarkTitle', ) ); my $dupe_rule = $news_group->group( 'USA' )->add_rule( condition => 'Duplicate', action => 'DeleteItem' ); $uk_news_group->add_rule( $dupe_rule ); $news_group->group( 'USA' )->add_feed( WashPost => 'http://feeds.washingtonpost.com/rss/national' ); # shorthand for $news_group->group( 'USA' )->add_feed( App::Rssfilter::Feed->new( name => 'WashPost', url => 'http://feeds.washingtonpost.com/rss/national', ) ); $news_group->group( 'USA' )->add_feed( name => 'NYTimes', url => 'http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml' ); $uk_news_group->add_feed( $news_group->group( 'USA' )->feed( 'WashPost' ) ); $news_group->update;
This module groups together feeds so that the same rules will be used to constrain them.
It consumes the App::Rssfilter::Logger role.
Use a group to:
allow rules which retain state (e.g. Duplicates) to constrain over multiple feeds
apply the same rules configuration to multiple feeds
This is a object used for logging; it defaults to a Log::Any object. It is provided by the App::Rssfilter::Logger role.
This is the name of the group. Group names are used when storing a feed so that feeds from the same group are kept together. The default value is '.' (a single period).
This is a feed storage object for feeds to use when they are updated. The default value is a fresh instance of App::Rssfilter::Feed::Storage. See "update" for details on when the default value is used.
This is an arrayref of subgroups attatched to this group.
This is an arrayref of rules to apply to the feeds in this group (and subgroups).
This is an arrayref of feeds.
$group->update( rules => $rules, storage => $storage );
Recursively calls update on the feeds and subgroups of this group.
update
$rules is an arrayref of additional rules to constrain the feed and groups, in addition to the group's current list of rules.
$rules
$storage is the feed storage object that feeds and subgroups will use to store their updated contents. If not specified, groups will use their default storage. The group's name is appended to the current path of $storage before being passed to feeds and subgroups.
$storage
storage
name
$group = $group->add_group( $app_rssfilter_group | %group_options );
Adds $app_rssfilter_group (or creates a new App::RssFilter::Group instance from the %group_options) to the list of subgroups for this group. Returns this group (for chaining).
$app_rssfilter_group
%group_options
my $subgroup = $group->group( $name );
Returns the last subgroup added to this group whose name is $name, or undef if no matching group.
$name
undef
$group = $group->add_rule( $app_rssfilter_rule | %rule_options )
Adds $app_rssfilter_rule (or creates a new App::RssFilter::Rule instance from the %rule_options) to the list of rules for this group. Returns this group (for chaining).
$app_rssfilter_rule
%rule_options
$group = $group->add_feed( $app_rssfilter_feed | %feed_options );
Adds $app_rssfilter_feed (or creates a new App::RssFilter::Feed instance from the %feed_options) to the list of feeds for this group. Returns this group (for chaining).
$app_rssfilter_feed
%feed_options
my $feed = $group->feed( $name );
Returns the last feed added to this group whose name is $name, or undef if no matching feed.
my $group = App::Rssfilter::Group::from_hash( %config );
Returns a new instance of this class with the feeds, rules, and subgroups specifed in %config. This method is provided by "from_hash" in App::Rssfilter::FromHash, which has additional documentation & examples.
%config
my $group = App::Rssfilter::Group::from_yaml( $yaml_config );
Returns a new instance of this class with the feeds, rules, and subgroups specifed in $yaml_config. This method is provided by "from_yaml" in App::Rssfilter::FromYaml, which has additional documentation & examples.
$yaml_config
App::RssFilter::Rule
App::RssFilter::Feed
App::RssFilter
Daniel Holz <dgholz@gmail.com>
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.
To install App::Rssfilter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Rssfilter
CPAN shell
perl -MCPAN -e shell install App::Rssfilter
For more information on module installation, please visit the detailed CPAN module installation guide.