| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
App::FeedDeduplicator::Aggregator - Aggregator class for App::FeedDeduplicator |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
This module is part of the App::FeedDeduplicator application. It is |
|
8
|
|
|
|
|
|
|
responsible for aggregating feeds from multiple sources. |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
It fetches the feeds using LWP::UserAgent and parses them using XML::Feed. |
|
11
|
|
|
|
|
|
|
The aggregated entries are stored in an array for further processing. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
It is designed to be used in conjunction with the Deduplicator and Publisher |
|
14
|
|
|
|
|
|
|
classes to provide a complete feed deduplication and publishing solution. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use App::FeedDeduplicator::Aggregator; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $aggregator = App::FeedDeduplicator::Aggregator->new( |
|
21
|
|
|
|
|
|
|
feeds => [{ |
|
22
|
|
|
|
|
|
|
name => 'Feed 1', |
|
23
|
|
|
|
|
|
|
feed => 'http://example.com/feed1', |
|
24
|
|
|
|
|
|
|
web => 'http://example.com', |
|
25
|
|
|
|
|
|
|
}, { |
|
26
|
|
|
|
|
|
|
name => 'Feed 2', |
|
27
|
|
|
|
|
|
|
feed => 'http://example.com/feed2', |
|
28
|
|
|
|
|
|
|
web => 'http://example.com', |
|
29
|
|
|
|
|
|
|
}], |
|
30
|
|
|
|
|
|
|
ua => LWP::UserAgent->new(), |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$aggregator->aggregate(); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 METHODS |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 new |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Creates a new instance of App::FeedDeduplicator::Aggregator. The constructor |
|
40
|
|
|
|
|
|
|
accepts a list of feeds and a user agent as parameters. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
The feeds should be an array reference containing hash references with the |
|
43
|
|
|
|
|
|
|
keys 'name', 'feed', and 'web'. |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
The user agent should be an instance of LWP::UserAgent. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 aggregate |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
The main method that aggregates feeds from the specified sources. It fetches |
|
50
|
|
|
|
|
|
|
each feed using the provided user agent and parses it using XML::Feed. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
It stores the aggregated entries in an array for further processing. The |
|
53
|
|
|
|
|
|
|
entries are stored as hash references containing the entry and the |
|
54
|
|
|
|
|
|
|
corresponding feed information. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
1
|
|
|
1
|
|
13
|
use v5.40; |
|
|
1
|
|
|
|
|
5
|
|
|
59
|
1
|
|
|
1
|
|
6
|
use feature 'class'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
156
|
|
|
60
|
1
|
|
|
1
|
|
7
|
no warnings 'experimental::class'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
133
|
|
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
class App::FeedDeduplicator::Aggregator { |
|
63
|
1
|
|
|
1
|
|
809
|
use XML::Feed; |
|
|
1
|
|
|
|
|
1032940
|
|
|
|
1
|
|
|
|
|
32
|
|
|
64
|
1
|
|
|
1
|
|
7
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
437
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
field $feeds :param; |
|
67
|
|
|
|
|
|
|
field $ua :param; |
|
68
|
|
|
|
|
|
|
field $entries :reader; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
method aggregate { |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
for (@$feeds) { |
|
73
|
|
|
|
|
|
|
my $response = $ua->get($_->{feed}); |
|
74
|
|
|
|
|
|
|
unless ($response->is_success) { |
|
75
|
|
|
|
|
|
|
warn "$_->{feed}\n"; |
|
76
|
|
|
|
|
|
|
warn $response->status_line, "\n"; |
|
77
|
|
|
|
|
|
|
next; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $feed = XML::Feed->parse(\$response->decoded_content); |
|
81
|
|
|
|
|
|
|
unless ($feed) { |
|
82
|
|
|
|
|
|
|
warn "Unable to parse $_->{feed}\n"; |
|
83
|
|
|
|
|
|
|
next; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
for my $entry ($feed->entries) { |
|
87
|
|
|
|
|
|
|
push @$entries, { |
|
88
|
|
|
|
|
|
|
entry => $entry, |
|
89
|
|
|
|
|
|
|
feed => $_, |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Dave Cross <dave@perlhacks.com> |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This software is copyright (c) 2025 Magnum Solutions Ltd. |
|
103
|
|
|
|
|
|
|
All rights reserved. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
|
106
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
See L<http://dev.perl.org/licenses/artistic.html> for more details. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |