| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 1 |  |  | 1 |  | 101237 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 31 |  | 
| 2 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 55 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | # ABSTRACT: remove an RSS item from its channel | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | package App::Rssfilter::Filter::DeleteItem; | 
| 8 |  |  |  |  |  |  | { | 
| 9 |  |  |  |  |  |  | $App::Rssfilter::Filter::DeleteItem::VERSION = '0.07'; | 
| 10 |  |  |  |  |  |  | } | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 1 |  |  | 1 |  | 976 | use Method::Signatures; | 
|  | 1 |  |  |  |  | 69411 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  |  | 
| 15 | 1 | 100 |  | 1 |  | 147734 | func filter ( $item, $matcher = 'no reason' ) { | 
|  | 4 | 100 |  | 4 |  | 2715 |  | 
|  | 3 | 100 |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 9 |  | 
|  | 3 |  |  |  |  | 13 |  | 
| 16 | 2 |  |  |  |  | 15 | $item->replace(q{}); | 
| 17 |  |  |  |  |  |  | } | 
| 18 |  |  |  |  |  |  | 1; | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | __END__ | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | =pod | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | =encoding UTF-8 | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | =head1 NAME | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | App::Rssfilter::Filter::DeleteItem - remove an RSS item from its channel | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | =head1 VERSION | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | version 0.07 | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | use App::Rssfilter::Filter::MarkTitle; | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | use Mojo::DOM; | 
| 39 |  |  |  |  |  |  | my $rss = Mojo::DOM->new( <<"End_of_RSS" ); | 
| 40 |  |  |  |  |  |  | <?xml version="1.0" encoding="UTF-8"?> | 
| 41 |  |  |  |  |  |  | <rss> | 
| 42 |  |  |  |  |  |  | <channel> | 
| 43 |  |  |  |  |  |  | <item><title>it's hi time</title><description>hi</description></item> | 
| 44 |  |  |  |  |  |  | <item><title>here we are again</title><description>hello</description></item> | 
| 45 |  |  |  |  |  |  | </channel> | 
| 46 |  |  |  |  |  |  | </rss> | 
| 47 |  |  |  |  |  |  | End_of_RSS | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | $rss->find( 'item' )->each( | 
| 50 |  |  |  |  |  |  | sub { | 
| 51 |  |  |  |  |  |  | my $item = shift; | 
| 52 |  |  |  |  |  |  | if( $item =~ /hello/ ) { | 
| 53 |  |  |  |  |  |  | App::Rssfilter::Filter::DeleteItem::filter( $item ); | 
| 54 |  |  |  |  |  |  | } | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  | ); | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | # or with an App::Rssfilter::Rule | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | use App::Rssfilter::Rule; | 
| 61 |  |  |  |  |  |  | App::Rssfilter::Rule->new( | 
| 62 |  |  |  |  |  |  | condition => sub { shift =~ m/hello/xms }, | 
| 63 |  |  |  |  |  |  | action    => 'DeleteItem', | 
| 64 |  |  |  |  |  |  | )->constrain( $rss ); | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | # either way | 
| 67 |  |  |  |  |  |  | print $rss->to_xml; | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | # <?xml version="1.0" encoding="UTF-8"?> | 
| 70 |  |  |  |  |  |  | # <rss> | 
| 71 |  |  |  |  |  |  | #   <channel> | 
| 72 |  |  |  |  |  |  | #     <item><title>it's hi time</title>hi</item> | 
| 73 |  |  |  |  |  |  | #   </channel> | 
| 74 |  |  |  |  |  |  | # </rss> | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | This module will remove an RSS item from its channel. Actually, it will remove any L<Mojo::DOM> element from its parent. Use L<App::Rssfilter::Filter::MarkTitle> for a non-destructive filter. | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | =head1 FUNCTIONS | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | =head2 filter | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | App::Rssfilter::Filter::DeleteItem::filter( $item, $matcher ); | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | Removes C<$item> from its parent and discards it. | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | C<$matcher> is an optional string specifying the condition which caused C<$item> to be removed, and is ignored; it exists solely so that L<App::Rssfilter::Rule/constrain> can set it to the name of the condition causing the match. | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | =over 4 | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | =item * | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | L<App::Rssfilter> | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =item * | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | L<App::Rssfilter::Rule> | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | =back | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | =head1 AUTHOR | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | Daniel Holz <dgholz@gmail.com> | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | This software is copyright (c) 2013 by Daniel Holz. | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 113 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | =cut |