App-Rssfilter
view release on metacpan or search on metacpan
lib/App/Rssfilter/Group.pm view on Meta::CPAN
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;
=head1 DESCRIPTION
This module groups together feeds so that the same rules will be used to constrain them.
It consumes the L<App::Rssfilter::Logger> role.
Use a group to:
=over 4
=item *
allow rules which retain state (e.g. L<Duplicates|App::Rssfilter::Match::Duplicates>) to constrain over multiple feeds
=item *
apply the same rules configuration to multiple feeds
=back
=head1 ATTRIBUTES
=head2 logger
This is a object used for logging; it defaults to a L<Log::Any> object. It is provided by the L<App::Rssfilter::Logger> role.
=head2 name
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).
=head2 storage
This is a feed storage object for feeds to use when they are updated. The default value is a fresh instance of L<App::Rssfilter::Feed::Storage>. See L</update> for details on when the default value is used.
=head2 groups
This is an arrayref of subgroups attatched to this group.
=head2 rules
This is an arrayref of rules to apply to the feeds in this group (and subgroups).
=head2 feeds
This is an arrayref of feeds.
=head1 METHODS
=head2 update
$group->update( rules => $rules, storage => $storage );
Recursively calls C<update> on the feeds and subgroups of this group.
C<$rules> is an arrayref of additional rules to constrain the feed and groups, in addition to the group's current list of rules.
C<$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 C<storage>. The group's C<name> is appended to the current path of C<$storage> before being pass...
=head2 add_group
$group = $group->add_group( $app_rssfilter_group | %group_options );
Adds C<$app_rssfilter_group> (or creates a new App::RssFilter::Group instance from the C<%group_options>) to the list of subgroups for this group. Returns this group (for chaining).
=head2 group
my $subgroup = $group->group( $name );
Returns the last subgroup added to this group whose name is C<$name>, or C<undef> if no matching group.
=head2 add_rule
$group = $group->add_rule( $app_rssfilter_rule | %rule_options )
Adds C<$app_rssfilter_rule> (or creates a new App::RssFilter::Rule instance from the C<%rule_options>) to the list of rules for this group. Returns this group (for chaining).
=head2 add_feed
$group = $group->add_feed( $app_rssfilter_feed | %feed_options );
Adds C<$app_rssfilter_feed> (or creates a new App::RssFilter::Feed instance from the C<%feed_options>) to the list of feeds for this group. Returns this group (for chaining).
=head2 feed
my $feed = $group->feed( $name );
Returns the last feed added to this group whose name is C<$name>, or C<undef> if no matching feed.
=head2 from_hash
my $group = App::Rssfilter::Group::from_hash( %config );
Returns a new instance of this class with the feeds, rules, and subgroups specifed in C<%config>. This method is provided by L<App::Rssfilter::FromHash/from_hash>, which has additional documentation & examples.
=head2 from_yaml
my $group = App::Rssfilter::Group::from_yaml( $yaml_config );
Returns a new instance of this class with the feeds, rules, and subgroups specifed in C<$yaml_config>. This method is provided by L<App::Rssfilter::FromYaml/from_yaml>, which has additional documentation & examples.
=head1 SEE ALSO
=over 4
=item *
L<App::RssFilter::Rule>
=item *
L<App::RssFilter::Feed>
=item *
L<App::RssFilter>
=back
( run in 1.089 second using v1.01-cache-2.11-cpan-39bf76dae61 )