line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
80764
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: add some text to the title of an RSS item |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package App::Rssfilter::Filter::MarkTitle; |
8
|
|
|
|
|
|
|
$App::Rssfilter::Filter::MarkTitle::VERSION = '0.08'; # TRIAL |
9
|
1
|
|
|
1
|
|
981
|
use Method::Signatures; |
|
1
|
|
|
|
|
77012
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
100
|
|
1
|
|
164629
|
func filter ( $item, $matcher, $explicit_prefix = $matcher ) { |
|
5
|
100
|
|
5
|
|
3473
|
|
|
4
|
100
|
|
|
|
6
|
|
|
4
|
100
|
|
|
|
13
|
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
15
|
|
13
|
2
|
|
|
|
|
9
|
$item->at('title')->prepend_content(uc($explicit_prefix)." - "); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
1; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
__END__ |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=pod |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=encoding UTF-8 |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
App::Rssfilter::Filter::MarkTitle - add some text to the title of an RSS item |
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::MarkTitle::filter( $item, 'HELLO' ); |
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 => 'MarkTitle[HELLO]', |
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><description>hi</description></item> |
70
|
|
|
|
|
|
|
# <item><title>HELLO - here we are again</title><description>hello</description></item> |
71
|
|
|
|
|
|
|
# </channel> |
72
|
|
|
|
|
|
|
# </rss> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 DESCRIPTION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
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. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 FUNCTIONS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 filter |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
App::Rssfilter::Filter::filter( $item, $matcher, $explicit_prefix ) |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
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. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SEE ALSO |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=over 4 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L<App::Rssfilter> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
L<App::Rssfilter::Rule> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=back |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Daniel Holz <dgholz@gmail.com> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Daniel Holz. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
109
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |