line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::Feed::Aggregator::Deduper; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
1788
|
$XML::Feed::Aggregator::Deduper::VERSION = '0.0401'; |
4
|
|
|
|
|
|
|
} |
5
|
1
|
|
|
1
|
|
9
|
use Moose::Role; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
6510
|
use MooseX::Types::Moose qw/Int HashRef/; |
|
1
|
|
|
|
|
80390
|
|
|
1
|
|
|
|
|
10
|
|
7
|
1
|
|
|
1
|
|
6095
|
use HTML::Scrubber; |
|
1
|
|
|
|
|
18781
|
|
|
1
|
|
|
|
|
33
|
|
8
|
1
|
|
|
1
|
|
12
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
requires 'add_entry'; |
11
|
|
|
|
|
|
|
requires 'all_entries'; |
12
|
|
|
|
|
|
|
requires 'grep_entries'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has body_register => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
isa => HashRef, |
17
|
|
|
|
|
|
|
default => sub { {} }, |
18
|
|
|
|
|
|
|
traits => ['Hash'], |
19
|
|
|
|
|
|
|
handles => { |
20
|
|
|
|
|
|
|
_register_body_sig => 'set', |
21
|
|
|
|
|
|
|
_body_sig_exists => 'exists' |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has title_register => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
isa => HashRef, |
28
|
|
|
|
|
|
|
default => sub { {} }, |
29
|
|
|
|
|
|
|
traits => ['Hash'], |
30
|
|
|
|
|
|
|
handles => { |
31
|
|
|
|
|
|
|
_register_title_sig => 'set', |
32
|
|
|
|
|
|
|
_title_sig_exists => 'exists' |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has id_register => ( |
37
|
|
|
|
|
|
|
is => 'ro', |
38
|
|
|
|
|
|
|
isa => HashRef, |
39
|
|
|
|
|
|
|
default => sub { {} }, |
40
|
|
|
|
|
|
|
traits => ['Hash'], |
41
|
|
|
|
|
|
|
handles => { |
42
|
|
|
|
|
|
|
_register_id => 'set', |
43
|
|
|
|
|
|
|
_id_exists => 'exists' |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub deduplicate { |
48
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
49
|
0
|
|
|
0
|
|
|
$self->grep_entries( sub { $self->_register($_) } ); |
|
0
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $self; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _register { |
54
|
0
|
|
|
0
|
|
|
my ($self, $entry) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
0
|
0
|
|
|
|
my $body = length($entry->content->body || '') |
|
|
|
0
|
|
|
|
|
57
|
|
|
|
|
|
|
>= length($entry->summary->body || '') |
58
|
|
|
|
|
|
|
? $entry->content->body : $entry->summary->body; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $body_sig = HTML::Scrubber->new->scrub($body); |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$body_sig =~ s/^\s+|\s+$//g; |
63
|
0
|
|
|
|
|
|
$body_sig =~ s/\s+/ /g; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $title_sig = $entry->title; |
66
|
0
|
|
|
|
|
|
$title_sig =~ s/^\s+|\s+$//g; |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
return if $self->_id_exists($entry->id); |
69
|
0
|
|
|
|
|
|
$self->_register_id($entry->id, 1); |
70
|
0
|
0
|
|
|
|
|
return if $self->_title_sig_exists($title_sig); |
71
|
0
|
|
|
|
|
|
$self->_register_title_sig($title_sig, 1); |
72
|
0
|
0
|
|
|
|
|
return if $self->_body_sig_exists($body_sig); |
73
|
0
|
|
|
|
|
|
$self->_register_body_sig($body_sig, 1); |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return 1; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=pod |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
XML::Feed::Aggregator::Deduper |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 VERSION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
version 0.0401 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
XML::Feed::Aggregator::Deduper - role for deduplication |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 METHODS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 deduplicate |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
deduplicates entries with an aggregator object. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 SEE ALSO |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
L<XML::Feed::Aggregator> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L<XML::Feed::Aggregator::Sort> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 AUTHOR |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Robin Edwards <robin.ge@gmail.com> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Robin Edwards. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
117
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__END__ |
123
|
|
|
|
|
|
|
|