line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
93080
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
63
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: add some text to the title of an RSS item |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package App::Rssfilter::Filter::MarkTitle; |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
$App::Rssfilter::Filter::MarkTitle::VERSION = '0.07'; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
1209
|
use Method::Signatures; |
|
1
|
|
|
|
|
904344
|
|
|
1
|
|
|
|
|
6
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
100
|
|
1
|
|
191310
|
func filter ( $item, $matcher, $explicit_prefix = $matcher ) { |
|
4
|
100
|
|
4
|
|
3031
|
|
|
3
|
100
|
|
|
|
5
|
|
|
3
|
100
|
|
|
|
14
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
13
|
|
16
|
1
|
|
|
|
|
10
|
$item->title->replace_content(uc($explicit_prefix) ." - ".$item->title->content_xml); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
1; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
__END__ |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=pod |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=encoding UTF-8 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 NAME |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
App::Rssfilter::Filter::MarkTitle - add some text to the title of an RSS item |
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::MarkTitle::filter( $item, 'HELLO' ); |
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 => 'MarkTitle[HELLO]', |
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><description>hi</description></item> |
73
|
|
|
|
|
|
|
# <item><title>HELLO - here we are again</title><description>hello</description></item> |
74
|
|
|
|
|
|
|
# </channel> |
75
|
|
|
|
|
|
|
# </rss> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 DESCRIPTION |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This module will add some uppercase text to the title of a L<Mojo::DOM> element. Use this module instead of L<App::Rssfilter::Filter::DeleteItem> when you wish to verify that your matchers are working correctly, as MarkTitle will simply mark the title of matched items with a specific string, or the name of the matching module. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 FUNCTIONS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 filter |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
App::Rssfilter::Filter::filter( $item, $matcher, $explicit_prefix ) |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Prefixes C<$item>'s title with C<$explicit_prefix> (or, if not specified, C<$matcher>) in uppercase. When called from L<App::Rssfilter::Rule/constrain>, C<$matcher> will be set to the nice name of the rule's condition, and C<$explicit_prefix> will be the first bracketed argument. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 SEE ALSO |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=over 4 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item * |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
L<App::Rssfilter> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item * |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
L<App::Rssfilter::Rule> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=back |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Daniel Holz <dgholz@gmail.com> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Daniel Holz. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
112
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |