line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: match a BBC sport RSS item |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
104714
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
62
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package App::Rssfilter::Match::BbcSports; |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
$App::Rssfilter::Match::BbcSports::VERSION = '0.07'; |
10
|
|
|
|
|
|
|
} |
11
|
1
|
|
|
1
|
|
1432
|
use Method::Signatures; |
|
1
|
|
|
|
|
83534
|
|
|
1
|
|
|
|
|
9
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
100
|
|
1
|
|
197649
|
func match ( $item ) { |
|
6
|
100
|
|
6
|
|
4706
|
|
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
16
|
|
15
|
4
|
|
|
|
|
26
|
return $item->guid->text =~ qr{ www [.] bbc [.] co [.] uk / sport [1]? / }xms; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
1; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
__END__ |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=pod |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=encoding UTF-8 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 NAME |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
App::Rssfilter::Match::BbcSports - match a BBC sport RSS item |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 VERSION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
version 0.07 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use App::Rssfilter::Match::BbcSports; |
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> |
44
|
|
|
|
|
|
|
<guid>http://www.bbc.co.uk/sport/some_article</guid> |
45
|
|
|
|
|
|
|
<description>here is an article about a sporting event</description> |
46
|
|
|
|
|
|
|
</item> |
47
|
|
|
|
|
|
|
<item> |
48
|
|
|
|
|
|
|
<guid>http://www.bbc.co.uk/tech/new_rss_tool_changes_how_we_read_news</guid> |
49
|
|
|
|
|
|
|
<description>here is an article about an rss tool</description> |
50
|
|
|
|
|
|
|
</item> |
51
|
|
|
|
|
|
|
</channel> |
52
|
|
|
|
|
|
|
</rss> |
53
|
|
|
|
|
|
|
End_of_RSS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
print $_, "\n" for $rss->find( 'item' )->grep( \&App::Rssfilter::Match::BbcSports::match ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# or with an App::Rssfilter::Rule |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
use App::Rssfilter::Rule; |
60
|
|
|
|
|
|
|
App::Rssfilter::Rule->new( |
61
|
|
|
|
|
|
|
condition => 'BbcSports', |
62
|
|
|
|
|
|
|
action => sub { print shift->to_xml, "\n" }, |
63
|
|
|
|
|
|
|
)->constrain( $rss ); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# either way, prints |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# <item> |
68
|
|
|
|
|
|
|
# <guid>http://www.bbc.co.uk/tech/new_rss_tool_changes_how_we_read_news</guid> |
69
|
|
|
|
|
|
|
# <description>here is an article about an rss tool</description> |
70
|
|
|
|
|
|
|
# </item> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 DESCRIPTION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This module will match items from BBC RSS feeds which are about sporting events. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 FUNCTIONS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 match |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $item_is_BBC_sport = App::Rssfilter::Match::BbcSports::match( $item ); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Returns true if ther GUID of C<$item> looks like a BBC sport GUID (like C<http://www.bbc.co.uk/sport>). |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SEE ALSO |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=over 4 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
L<App::Rssfilter> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
L<App::Rssfilter::Rule> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Daniel Holz <dgholz@gmail.com> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Daniel Holz. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
107
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |