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